Take the 2-minute tour ×
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.

I have a slide with an enumerate that's partially in the main slide and partially in a column on the same slide. Here's a minimal example to show my intention:

\documentclass{beamer}
\begin{document}
\begin{frame}{Lorem ipsum}
\begin{enumerate}
\item Lorem
\item ipsum
\begin{columns}
\begin{column}{0.5\textwidth}
\item dolor
\item sit
\end{column}
\begin{column}{0.5\textwidth}
% something else here
\end{column}
\end{columns}
\end{enumerate}
\end{frame}
\end{document}

In the screenshot below, how can I get 3 and 4 to also be indented exactly as 1 and 2? I typically use 0.45\textwidth for the column width, but for the purposes of this question, I'd like the indentation to be decided independent of the column width (or done programmatically so that I don't have to calculate it). enter image description here

share|improve this question
    
May I ask why you want to do this? If for vertical alignment purposes there are other ways to do this. I'm just asking in case there is an XY problem here. –  percusse Jul 29 '12 at 10:01
    
@percusse Points 3 and 4 talk about a figure in the right column, but 1–4 are all part of the same theme, so I don't want to split the list. I'm open to other solutions... this was the first thing that popped into my mind –  Lorem Ipsum Jul 29 '12 at 10:06
    
Well, one thing is to use [b] placement option in the second column (or in the columns environment for both) such that the bottom of the image is always aligned with the item 4 (without breaking the enumeration). Is that a kind of a solution you might use? (this is in page 127 of the manual) –  percusse Jul 29 '12 at 10:11
    
@percusse I don't see how that would align 3 & 4 with 1 & 2... or am I missing something/misunderstanding you? I'm fine with anything that aligns the last two items with the first two. The alignment of the figure in the right column is not that important –  Lorem Ipsum Jul 29 '12 at 10:14
    
@yoda I understand that percusse is suggesting to put the four items in the same column, and align the figure to bottom so that it relates to the last items. –  JLDiaz Jul 29 '12 at 11:15
show 1 more comment

2 Answers 2

I guess that you objective is to have a figure aligned with some items, and that is the resason why you introduced a columns environment inside a enumerate, which in general is not a good idea.

A different approach is to put your whole enumerate into a minipage of half the width of the frame (or in a column, if you prefer, but since you won't use a second column, a minipage is appropiate also), and put the figure to the right of one of the items, using a picture environment of size zero.

For example, the following code will put a figure (given as parameter) at a point 0.5\textwidth units to the right of the point where the command is used. The second parameter is the size of the figure:

\def\putfigure#1#2{% 1=graphic file, 2=width of the graphic
\begin{picture}(0,0)\setlength{\unitlength}{0.5\textwidth}%
\put(1,0){\vbox{\hbox{\includegraphics[width=#2]{#1}}}}%
\end{picture}}

The figure will be bottom-aligned with the line in which the command is used, so the idea is to put this command at the beginning of the last \item you want to align the figure with. In your example, this would be at the fourth item:

\item\putfigure{myfigure}{0.3\textwidth}sit

The following is a MWE desgined to be tested in LaTeX previewer. This previewer doesn't have beamer package, so I cannot use frames, but you can adapt this to your presentation without difficulty.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\def\putfigure#1#2{%
\begin{picture}(0,0)\setlength{\unitlength}{0.5\textwidth}%
\put(1,0){\vbox{\hbox{\includegraphics[width=#2]{#1}}}}%
\end{picture}}

%\begin{frame}{Lorem ipsum}
\begin{minipage}{.5\textwidth}
\begin{enumerate}
\item Lorem
\item ipsum
\item dolor
\item\putfigure{star.mps}{0.2\textwidth}sit
\item and some
\item more
\end{enumerate}
\end{minipage}
\end{document}

Resulting in:

figure aligned with fourth item

UPDATE: A different approach.

If you want to take into account the vertical space taken by the figure, another idea is to use a tabular to separate the different "parts" of the enumerate in different rows, using the second column of the table to put the figure. Some points to note:

  1. The enumerate is broken in several enumerates, but the numeration of the items should be continued from the previous one.
  2. The figure and the corresponding items should be vertically aligned at the center of the cells, which requires to put the figure inside a $\vcenter{}$

Minimal working example:

\documentclass{beamer}
\usepackage{graphics}
\newcounter{saveenum}
\begin{document}
\begin{frame}{Lorem ipsum}
\begin{tabular}{p{.4\textwidth}p{.4\textwidth}}
  \parbox{.4\textwidth}{\begin{enumerate}
    \item Lorem
    \item ipsum
    \setcounter{saveenum}{\value{enumi}}
  \end{enumerate}}  & \\
  \parbox{.4\textwidth}{\begin{enumerate}
    \setcounter{enumi}{\value{saveenum}}
    \item dolor
    \item sit
    \setcounter{saveenum}{\value{enumi}}
  \end{enumerate}} &
  $\vcenter{\includegraphics[width=.3\textwidth]{elephant}}$ \\
  \begin{enumerate}
    \setcounter{enumi}{\value{saveenum}}
    \item And some
    \item more
  \end{enumerate} & \\
\end{tabular}
\end{frame}
\end{document}

Which produces:

Output

(The elephant figure comes from Flickr).

share|improve this answer
    
You got the idea partially, but it doesn't work quite as well. Sure, you can align it well for a small figure, but for larger ones, I have to fiddle with the vertical spacing. Also, the reason for splitting it that way was because items 1 and 2 stretch all the way to the end, which is not possible if put in only a half mini page –  Lorem Ipsum Jul 29 '12 at 16:14
add comment

You don't have to break the enumeration if it is not needed. For example, the following MWE has a single enumerate and the image is pushed into position using a combination of \hspace and overlap. Additionally, to remove any vertical re-adjustment from the image height, you can \smash it before you move it up/down (using \raisebox{<length>}{<stuff>}).

enter image description here

\documentclass{beamer}% http://ctan.org/pkg/beamer
%\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\begin{frame}{Lorem ipsum}
  \begin{enumerate}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc pellentesque egestas 
      orci non tempor. Mauris dapibus congue turpis, ut egestas quam dignissim vel. Nam condimentum 
      ornare eleifend.
    \item ipsum
    \item \leavevmode\rlap{dolor}\hspace*{.5\textwidth}%
      \rlap{\smash{\raisebox{-\height}{\includegraphics[width=.3\linewidth]{example-image-a}}}}
    \item sit
  \end{enumerate}
\end{frame}
\end{document}

Some explanation around item dolor: \leavevmode "starts" the enumeration and subsequently sets a zero-width dolor as a right overlap. This is followed by a .5\textwidth gap, followed by another right overlap of the \smashed image example-image-a, dropped by its total height \height.

share|improve this answer
add comment

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.