我尝试制作一个框架,在右侧显示一个图形,在左侧添加关于它的描述。我希望描述顶部对齐,图形居中对齐,但我很难像这样输出。这是我第一次尝试的:
\documentclass[10pt,aspectratio=1610,t]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}\frametitle{Minimum Working Exaple}
\begin{columns}[t,onlytextwidth]
\begin{column}{.5\textwidth}
This is the first column.
\end{column}
\begin{column}{.5\textwidth}
\begin{figure}[h]
\centering
\parbox[c][\textheight][c]{\columnwidth}{
\begin{tikzpicture}
\useasboundingbox (0, 0) rectangle (5, 5); % assign a bounding box
\fill (current bounding box.south west) rectangle (current bounding box.north east); % fill the current bounding box
\end{tikzpicture}
\caption{Enter the caption here}
}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\end{document}
使用代码 avobe,我得到
为了将图形放置在我想要的位置,我在 Google 上搜索解决方案并找到了这个答案\parbox
。我尝试将的第二个参数更改为.7\textheight
。然后,我得到
这次图形向上移动(虽然我不知道它是否精确地垂直居中)。但是,尽管如此,图形仍然在右列水平居中\centering
。
如何使图形垂直和水平居中?
更新
贡萨洛·梅迪纳 (Gonzalo Medina) 推荐我使用minipage
环境而不是columns
环境并且此替换输出了所需的结果。但是,我仍然不知道为什么\centering
我的代码(即在column(s)
环境中)无法正常工作。如果有人能告诉我原因,我将不胜感激。
答案1
一种选择是使用固定高度minipage
而不是column
环境:
代码:
\documentclass[10pt,aspectratio=1610,t]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}\frametitle{Minimum Working Exaple}
\begin{minipage}[t][.8\textheight][t]{.5\textwidth}
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
\end{minipage}%
\begin{minipage}[t][.8\textheight][c]{.5\textwidth}
\begin{figure}
\vfill
\centering
\begin{tikzpicture}[baseline]
\useasboundingbox (0, 0) rectangle (5,5); % assign a bounding box
\fill (current bounding box.south west) rectangle (current bounding box.north east); % fill the current bounding box
\end{tikzpicture}
\caption{Enter the caption here}
\vfill
\end{figure}
\end{minipage}
\end{frame}
\end{document}
使用\frame
for eachminipage
将允许您查看它们以进行微小的调整;一旦对齐达到所需的水平,您就可以删除命令\frame
:
\documentclass[10pt,aspectratio=1610,t]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}\frametitle{Minimum Working Exaple}
\frame{\begin{minipage}[t][.8\textheight][t]{.5\textwidth}
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
This is the first column.\par
\end{minipage}}%
\frame{\begin{minipage}[t][.8\textheight][c]{.5\textwidth}
\begin{figure}
\vfill
\centering
\begin{tikzpicture}[baseline]
\useasboundingbox (0, 0) rectangle (5,5); % assign a bounding box
\fill (current bounding box.south west) rectangle (current bounding box.north east); % fill the current bounding box
\end{tikzpicture}
\caption{Enter the caption here}
\vfill
\end{figure}
\end{minipage}}
\end{frame}
\end{document}
结果:
更新
关于\centering
原始代码中不起作用,这个命令在 之前\parbox
,所以它使 parbox 在列内居中,但不是 的内容\parbox
,所以\centering\parbox{<length>}{<content>}
你需要的\parbox{<length>}{\centering <content>}
是 的宽度是否\parbox
等于列的宽度或\centering\parbox{<length>}{\centering <content>}
其他。