0

I'm trying to put pictures next to short paragraphs, such that their tops always align. like in the following image.

My initial code is this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{graphicx}

\begin{document}

\begin{wrapfigure}{r}{0.25\textwidth}
\includegraphics[width=0.2\textwidth]{Dark-Grey-Square.jpg}
\end{wrapfigure}
Here's some information about the figure that is shorter than the image.

\begin{wrapfigure}{r}{0.25\textwidth}
\includegraphics[width=0.2\textwidth]{Dark-Grey-Square.jpg}
\end{wrapfigure}
Here's some information about the figure that is longer than the image \lipsum[1]

\begin{wrapfigure}{r}{0.25\textwidth}
\includegraphics[width=0.2\textwidth]{Dark-Grey-Square.jpg}
\end{wrapfigure}
Shorter again

\end{document}

This obviously doesn't work. I tried to find a way to align the images to the paragraphs, but the one I did find only works when the height of each paragraph is greater than the image.

I've tried using tables but they cause more problems than they solve.

I've tried minipages, but they don't behave like I thought they would.

I don't necessarily need the text to wrap around the second image like in the picture.

Any ideas on how to accomplish this?

3

1 Answer 1

1

So the answer provided by @David Carlisle worked quite well, but after a lot of puzzling, I found a thing that works better for my particular purposes. I created an environment using top aligned mini pages.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}

%Create a new minipage environment where paragraphs have indents
\newlength{\currentparindent}
\newenvironment{minipageparindent}[2][c]
  {\setlength{\currentparindent}{\parindent}% save the value
   \noindent\begin{minipage}[#1]{#2}% open the minipage
   \setlength{\parindent}{\currentparindent}% restore the value
  }
  {\end{minipage}}

%Create an environment that creates a paragraph with a picture next to it, both being aligned at the top.
\newenvironment{pictureparagraph}[1]    %argument is an 'includegraphics' command
    {\newcommand\picturetoplace{#1}     % using variable directly gives an error
    \begin{minipageparindent}[t]{0.7\textwidth} %
    \vspace{0pt}    %Make sure that the top base is at the absolute top
    }   
    {
    \end{minipageparindent}
    \begin{minipage}[t]{0.3\textwidth}
    \vspace{0pt}    %Make sure that the top base is at the absolute top of the minipage
    \picturetoplace
    \end{minipage}\\}

\begin{document}

\begin{pictureparagraph}{\includegraphics[width=\textwidth]{Dark-Grey-Square.jpg}}
    Lalala this is a short piece of text to show that the thing works.
\end{pictureparagraph}

\begin{pictureparagraph}{\includegraphics[width=\textwidth]{Dark-Grey-Square.jpg}}
    \lipsum[1]
\end{pictureparagraph}

\begin{pictureparagraph}{\includegraphics[width=\textwidth]{Dark-Grey-Square.jpg}}
    Another short piece of text, but not too short, but not too short, but not too short, but not too short, but not too short, but not too short, but not too short, but not too short, but not too short, but not too short.
\end{pictureparagraph}

\lipsum[1]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .