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}
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.
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}
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}
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.
Best Answer
It seems that correct distance is
\baselineskip
:Addendum: Above solution works with beamer font size options
12pt
,11pt
(default size) and10 pt
. With option9pt
compilation fail, since I haven't installed packageextsize
yet (I don't need it), which is necessary for fonts8pt
and9pt
. I assume, that your problem is caused by this package.As stated in manual (pp 159), fonts
8pt
and9pt
are to small (so they haven't native beamer support), and "If you really need to fit more onto each frame, use10pt
option (which works withoutextsize
)".Solution: See, if you can stick with
10pt
. Benefits: (i) nicer and more clear presentation as at font size9pt
and (ii) you have solved your problem.