5

Creating beamer presentations I want to display an itemize environment in the second column of a tabular. My aim is to have the first item on the same baseline as the content in the first column. My MWE is (tikz is just used to show the baseline of left content)

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}
\newcommand{\tikzmark}[2]{
\tikz[baseline=(#1.base), remember picture]{
\node(#1)[inner sep=0pt]{#2};
}
}

\begin{frame}[t]{Title}
\begin{tabular}{p{0.08\linewidth}p{0.8\linewidth}}
    \tikzmark{left}{left text} & 
    \vspace*{-1\topskip}\vspace*{-0.50\itemsep} 
    \begin{itemize}
        \item \tikzmark{right}{number 1} \\ (with possibly two lines) 
        \item number 2 
    \end{itemize}
\end{tabular}
\tikz[overlay, remember picture]{
    \draw[red, line width=0.05pt](left.south west)--(right.south east|-left.south west);
    \draw[blue](right.south east)--(right.south east|-left.south east);
}
\end{frame}
\end{document}

MWE

I shifted the itemize environment up by 1\topskip+0.5\itemsep which looked to be the perfect distance at first sight. Looking closer shows that actually the first item is printed a bit lower than the content in the left column. zoomed MWE

My question is, what is the correct distance that I have to shift here or is there a better way to do this? I already read this and that, but as I'm using beamer, I can't use the enumitem package, so those solution don't work for me. The last solution given by Matthew Leingang also doesn't work as I want to be able to put more lines in each item.


EDIT: As explained in the answers, the correct distance would be -\baselineskip. Of course I had already testet this before, but didn't succeed (see my comment). It took quite a long time to find out, why it works in the MWE but not in my case. Finally I figured it out: It is the documentclass option 9pt that I'm using! Why is it like that and how can I avoid this? Is this a beamer bug? New MWE:

\documentclass[9pt]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}
\newcommand{\tikzmark}[2]{
\tikz[baseline=(#1.base), remember picture]{
\node(#1)[inner sep=0pt]{#2};
}
}   
\begin{frame}[t]{Title}
\begin{tabular}[t]{p{0.08\linewidth}p{0.8\linewidth}}
\tikzmark{left}{left text b} & \vspace*{-1\baselineskip}%\vspace*{-0.50\itemsep}
\begin{itemize}
\item \tikzmark{right}{b number 1} \\ (with possibly two lines) 
\item number 2 
\end{itemize}
\end{tabular}
\tikz[overlay, remember picture]{
\draw[red, line width=0.05pt](left.south west)--(right.south east|-left.south west);
\draw[blue](right.south east)--(right.south east|-left.south east);
}
\end{frame}
\end{document}

9pt bug

Another problem occurs, nesting this into an itemize environment:

\documentclass[9pt]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}
\newcommand{\tikzmark}[2]{
\tikz[baseline=(#1.base), remember picture]{
\node(#1)[inner sep=0pt]{#2};
}
}   
\begin{frame}[t]{Title}
\begin{itemize}
\item a
\item b
\begin{tabular}[t]{p{0.08\linewidth}p{0.8\linewidth}}
\tikzmark{left}{left text b} & \vspace*{-1\baselineskip}%\vspace*{-0.50\itemsep}
\begin{itemize}
\item \tikzmark{right}{b number 1} \\ (with possibly two lines) 
\item number 2 
\end{itemize}
\end{tabular}
\tikz[overlay, remember picture]{
\draw[red, line width=0.05pt](left.south west)--(right.south east|-left.south west);
\draw[blue](right.south east)--(right.south east|-left.south east);
}
\end{itemize}
\end{frame}
\end{document}

nested in itemize

Here the distance obviously has to be adjusted somehow. How can I do this? AND: (I'm sorry for making this question longer and longer) there is another problem: \renewcommand{\baselinestretch}{1.15} shifts everything upwards!


EDIT: as the described problems are somehow different from the original question, I accepted the answer and ask a new questions for the nesting and the change of linespread.

5

It seems that correct distance is \baselineskip:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}
\newcommand{\tikzmark}[2]{
\tikz[baseline=(#1.base), remember picture]{
\node(#1)[inner sep=0pt]{#2};
}
}

\begin{frame}[t]{Title}
\begin{tabular}{p{0.08\linewidth}p{0.8\linewidth}}
    \tikzmark{left}{left text} &
    \vskip-\baselineskip% <---
    \begin{itemize}
        \item \tikzmark{right}{t number 1} \\ (with possibly two lines)
        \item number 2
    \end{itemize}
\end{tabular}
\tikz[overlay, remember picture]{
    \draw[red, line width=0.05pt](left.south west)--(right.south east|-left.south west);
    \draw[blue](right.south east)--(right.south east|-left.south east);
}
\end{frame}
    \end{document}

enter image description here

Addendum: Above solution works with beamer font size options 12pt, 11pt (default size) and 10 pt. With option 9pt compilation fail, since I haven't installed package extsize yet (I don't need it), which is necessary for fonts 8pt and 9pt. I assume, that your problem is caused by this package.

As stated in manual (pp 159), fonts 8pt and 9pt are to small (so they haven't native beamer support), and "If you really need to fit more onto each frame, use 10pt option (which works without extsize)".

Solution: See, if you can stick with 10pt. Benefits: (i) nicer and more clear presentation as at font size 9pt and (ii) you have solved your problem.

  • Answers seem so trivial sometimes. Unfortunately, the solution only works for the MWE here, but not for my actual code. Everything is nested in macros there, I didn't notice my MWE produces a different result, I'm sorry. I'll rework it! Is it possible that I somehow change baselineskip without noticing? – Ktree Dec 17 '15 at 17:47
  • I finally figured out. I adjusted my question, would be glad if you could explain this... – Ktree Dec 18 '15 at 7:42
  • See my answer upgrade. – Zarko Dec 18 '15 at 9:33
  • Thanks for that, actually I didn't know about that extsize package. I'll think about that. What about nesting in itemize environments and changing the linspread? Indeed this is the biggest problem of all :( – Ktree Dec 18 '15 at 9:50
  • I strongly encourage you to increase font size to 10pt. As I say before, this will solve your problem and will look nicer than now. You can some part, where you have more text (as is necessary for presentation) just use small or footnotesize if needed. Really, rethink again your presentation design. The public will appreciated this very much :-). – Zarko Dec 18 '15 at 14:47
4

Use -1\baselineskip instead. I added a t before number just to compare with the left one. This is because itemize starts in a new line by itself.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}
\newcommand{\tikzmark}[2]{
\tikz[baseline=(#1.base), remember picture]{
\node(#1)[inner sep=0pt]{#2};
}
}

\begin{frame}[t]{Title}
\begin{tabular}{p{0.08\linewidth}p{0.8\linewidth}}
    \tikzmark{left}{left text} & 
    \vspace*{-1\baselineskip}%\vspace*{-0.50\itemsep} 
    \begin{itemize}
        \item \tikzmark{right}{tnumber 1}  \\ (with possibly two lines) 
        \item number 2 
    \end{itemize}
\end{tabular}
\tikz[overlay, remember picture]{
    \draw[red, line width=0.05pt](left.south west)--(right.south east|-left.south west);
    \draw[blue](right.south east)--(right.south east|-left.south east);
}
\end{frame}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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