TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In several documents I have to put side by side a list and a figure.

I use two minipages environments for that, but as the list is too long, I need to divide it and continue outside the minipage environment (with continuous numbering, hence the utilization of key series of the enumitem package). But, as we may see, the separation between the first item in the enumerate environment outside the minipage and the last item inside the minipage is different from the separation between any other itens.

So, my question is: Is there any way of assure equal separation between all the itens?

Naturally, I appreciate any hint on a different and better way of doing this.

\documentclass{article}

\usepackage{enumitem} 
\setlist[enumerate,1]{leftmargin=*,label=\arabic*.}
\setlist[enumerate,2]{leftmargin=*,itemsep=.3cm,label=(\alph*)}

\begin{document}

\begin{enumerate}
\item Algum texto com referencia a uma figura.

\begin{minipage}[t]{0.55\linewidth}
 Uma lista.
\begin{enumerate}[series=exercicio]
 \item primeiro item
 \item segundo item
 \item terceiro item
\end{enumerate}
\end{minipage}\hfill
\begin{minipage}[t][2cm][c]{0.35\linewidth}
 \centering
 \rule{50pt}{50pt}
\end{minipage}
\begin{enumerate}[resume*=exercicio]
 \item quarto item com bastante texto. mais texto e mais texto e mais
  texto
 \item quinto item
\end{enumerate}

\end{enumerate}

\end{document}

enter image description here

share|improve this question

You could simply overlay the image and use \rightskip. Alas, \hangindent doesn't seem to work with item.

\documentclass{article}
\usepackage{mwe}
\usepackage{enumitem} 
\setlist[enumerate,1]{leftmargin=*,label=\arabic*.}
\setlist[enumerate,2]{leftmargin=*,itemsep=.3cm,label=(\alph*)}

\begin{document}

\begin{enumerate}
\item Algum texto com referencia a uma figura.

Uma lista.\hfill\llap{\raisebox{-\height}[0pt][0pt]{%
\begin{minipage}[t][2cm][c]{0.3\textwidth}% \linewidth is constantly changing here
 \centering
 \rule{50pt}{50pt}
\end{minipage}}}
\begin{enumerate}[series=exercicio]
 \par\rightskip=0.3\textwidth
 \item primeiro item.  Just to demonstrate the effect of \verb$\rightskip$ I am going to add more text here.
 \item segundo item.
 \par\rightskip=0pt
 \item terceiro item.
 \item quarto item com bastante texto. mais texto e mais texto e mais
  texto
 \item quinto item
\end{enumerate}

\end{enumerate}

\end{document}

overlay

share|improve this answer

Use the package wrapfig:

\documentclass{article}

\usepackage{enumitem,wrapfig}
\usepackage{graphicx}

\begin{document}

\begin{wrapfigure}{r}{0.5\textwidth}
  \begin{center}
     \rule{50pt}{50pt}
  \end{center}
\end{wrapfigure}

Algúm texto que não é parte de uma lista.

\begin{enumerate}
\item Algum texto com referencia a uma figura.

 Uma lista.
  \begin{enumerate}
   \item primeiro item
   \item segundo item
   \item terceiro item
   \item quarto item com bastante texto. mais texto e mais texto e mais texto
   \item quinto item
  \end{enumerate}
\end{enumerate}

\end{document}

Screenshot

The wrapfig documentation starts with this caution:

You must not specify a wrapfigure in any type of list environment or immediately before or immediately after one. It is OK to follow a list if there is a blank line (\par) in between.

That's why I've added a line of text before the list.

I guess you can play a little so the figure actually appears besides your lists, but the lists cannot be the first or only things wrapping around the figure.

share|improve this answer

The way text/boxes are laid out is to use a minimum spacing of \baselineskip between two consecutive baselines, or \lineskip between the lower and upper boundaries of two boxes (whichever is larger).

One way to achieve a relatively constant spacing is to place the baseline for the first minipage at the bottom and the baseline of the second minipage at the top.

Another way is to start and end every minipage with a \strut.

In the case of enumitem, adding \strut or \null produces way too much space between the two minipages. Instead you just need to add about 12pt of space between the default minipages (less if you add a \strut to the last \item). I'm not sure precisely how enumitem comes up with this 12pt, but this is my best guess.

It should be noted that text inside a minipage is not stretched or squeezed in order to fit the bottom of the page. You will also need to use \raggedbottom or throw in a \vfil somewhere, or put both minipages inside a common \vbox.

Demo:

\documentclass{article}
\usepackage{paracol}
\usepackage{enumitem}

\begin{document}
\begin{paracol}{2}

\noindent
\begin{minipage}{\columnwidth}
\begin{enumerate}[series=test1]
\item One
\item Two
\end{enumerate}
\end{minipage}
\begin{minipage}{\columnwidth}
\begin{enumerate}[resume*=test1]
\item Three
\item Four
\end{enumerate}
\end{minipage}
\switchcolumn

\noindent
\begin{minipage}{\columnwidth}
\begin{enumerate}[series=test2]
\item One
\item Two\strut
\end{enumerate}
\end{minipage}
\vskip\partopsep\vskip\itemsep\vskip\parsep\noindent
\begin{minipage}{\columnwidth}
\begin{enumerate}[resume*=test2]
\item Three
\item Four
\end{enumerate}
\end{minipage}
\bigskip
\switchcolumn*

\noindent
\begin{minipage}{\columnwidth}
We need at least two lines here in order for this to work, so I hope that this is enough.
\end{minipage}
\begin{minipage}{\columnwidth}
We need at least two lines here in order for this to work, so I hope that this is enough.
\end{minipage}
\switchcolumn

\noindent
\begin{minipage}[b]{\columnwidth}
We need at least two lines here in order for this to work, so I hope that this is enough.
\end{minipage}
\begin{minipage}[t]{\columnwidth}
We need at least two lines here in order for this to work, so I hope that this is enough.
\end{minipage}
\bigskip
\switchcolumn*

\noindent
\begin{minipage}{\columnwidth}
We need at least two lines here in order for this to work, so I hope that this is enough.
\end{minipage}
\begin{minipage}{\columnwidth}
We need at least two lines here in order for this to work, so I hope that this is enough.
\end{minipage}
\switchcolumn

\noindent
\begin{minipage}{\columnwidth}
\strut
We need at least two lines here in order for this to work, so I hope that this is enough.
\strut
\end{minipage}
\begin{minipage}{\columnwidth}
\strut
We need at least two lines here in order for this to work, so I hope that this is enough.
\strut
\end{minipage}
\bigskip
\switchcolumn*


\end{paracol}
\end{document}

minipage spacing

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.