3

I try to make a frame in which I indicate a figure on the right side and add a description about it on the left side. I want the description top-aligned and the figure center-aligned, but I have difficulty in outputting like this. Here is what I first tried:

\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}

With the code avobe, I get MWE1

To place the figure where I want it to be, I googled for solution and found this answer. I tried changing the second parameter of \parbox to .7\textheight. Then, I get MWE2

This time the figure goes upward (although I do not know whether it is EXACTLY vertically centered). However, the figure remains to be horizontally centered in the right column in spite of \centering.

How can I center the figure both vertically and horizontally?

Update

Gonzalo Medina suggested me using minipage environment instead of columns environment and this substitution output the desired result. However, I still do not know why \centering in my code (i.e. in column(s) environment) does not work well. I would highly appreciate it if anyone taught me the reason.

  • I added a little explanation in the update to my answer regarding the \centering issue. – Gonzalo Medina Jul 10 '15 at 2:18
2

One option would be to use fixed height minipage's instead of column environments:

enter image description here

The code:

\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}

Using a \frame for each minipage will let you see them for minor adjustments; once the alignment is the desired one, you can remove the \frame commands:

\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}

The result:

enter image description here

Update

Regarding the \centering not working in the original code, this command is before the \parbox, so it centers the parbox inside the column, but not the contents of the \parbox, so instead of \centering\parbox{<length>}{<content>} you needed \parbox{<length>}{\centering <content>} if the width of the \parbox was equal to the one of the column or \centering\parbox{<length>}{\centering <content>} otherwise.

  • This is what I wanted, but I have two questions. 1. When I change the coefficient of \textheight, the figure vertically moves although the third parameter of minipage environment is set to c. Why is this? 2. What does two \vfills do? After romving these, the output seems to be the same to me. – Merzong Jul 9 '15 at 22:10
  • @Merzong Please see my updated answer. Adding the frames will show you what exactly is happening with the minipages. To answer your questions: 1) Since the vertical alignment for the content of the minipage to the is c, if you increse the totle height, the image will move downwards to remain vertically centered with respect to the new (bigger) height. 2) Those \vfills are stretchable vertical spaces to guarantee vertical centering; since c was used here, as you discovered, they can be safely deleted. – Gonzalo Medina Jul 9 '15 at 22:16
  • Do you mean as follows? The figure is center-aligned in the minipage. However, since the upper side of the minipage is fixed, the minipage itself is not vertically centered to the whole frame unless I adjust the height manually. – Merzong Jul 9 '15 at 23:54
  • This usage of \frame is very useful in various purposes because it visualizes the canvas I am handling! – Merzong Jul 9 '15 at 23:58
  • @Merzong To your firest remark, yes. Regarding \frame, yes it's very useful; I prefer it over \fbox since \frame doesn't add the \fboxsep padding. – Gonzalo Medina Jul 10 '15 at 1:05

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.