1

I am using beamer class to make a presentaation. I am using minipage to get 4 figures in 2 by 2 arrangement.

When I give captions to the figures 2 problems arise:

  • The caption starts right from the figure instead of below
  • Instead of decreasing the size of the figure the caption will be cut by the figure.
  • I also get error: "\caption outside figure or table. \end{frame}"
\documentclass{beamer}
\usetheme{default}
\setbeamerfont{caption}{size=\footnotesize}
\begin{document}
  \begin{frame}
      \begin{columns}
          \column{0.5\textwidth}
          \begin{minipage}[c][0.4\textheight][c]{\linewidth}
              \centering
              \includegraphics[width=1\linewidth]{ETRM1042-epspdf-to}
              \caption{WT terminal voltage}
          \end{minipage}
          \begin{minipage}[c][0.4\textheight][c]{\linewidth}
              \centering
              \includegraphics[width=1\linewidth]{ITRM1042-epspdf-to}
              \caption{WT terminal current}
          \end{minipage}
          \column{0.5\textwidth}
          \begin{minipage}[c][0.4\textheight][c]{\linewidth}
                      \centering
                      \includegraphics[width=1\linewidth]{ETRM1042-epspdf-to}
                  \caption{Caption 3}
                  \end{minipage}
          \begin{minipage}[c][0.4\textheight][c]{\linewidth}
              \centering
              \includegraphics[width=1\linewidth]{VAACC-epspdf-to}
              \caption{previous Vterm angle}
          \end{minipage}
      \end{columns}
    \end{frame}
   \end{document}

enter image description here

  • 1
    is it intended that there are only three captions? it is very hard to see what is happening unless you make it a complete document so people can run it, you can use {example-image} as the image (it is in most tex distributions) – David Carlisle Feb 14 '16 at 17:12
  • note you have over-constrained the boxes, you have specified their height but also put in images scaled to full width and a caption. If that text does not fit into the box then tex has to over-print the surrounding text. It's rather rare to use that height option on minipage. – David Carlisle Feb 14 '16 at 17:16
  • @DavidCarlisle There are 4 captions. Would alternative can I use instead of height ? – Martin Bakardjiev Feb 14 '16 at 17:19
  • there are only three \caption in the code above. – David Carlisle Feb 14 '16 at 17:42
  • Without a figure you should be using captionof{figure} from the caption package (or possibly already in beamer). – John Kormylo Feb 14 '16 at 19:36
2

Less complication you will have with the following approach:

\documentclass{beamer}
    \usepackage{graphicx}
    \usepackage{tabularx}

\begin{document}
\begin{figure}
\begin{frame}
    \begin{tabularx}{\textwidth}{*{2}{>{\centering\arraybackslash}X}}
\includegraphics[width=0.9\linewidth,height=24mm]{example-image-a}
\caption{WT terminal voltage}
    &   \includegraphics[width=\linewidth,height=24mm]{example-image-a}
        \caption{???}
        \\  % new row
\includegraphics[width=0.9\linewidth,height=24mm]{example-image-b}
\caption{WT terminal current}
    &   \includegraphics[width=\linewidth,height=24mm]{example-image-b}
        \caption{previous Vterm angle}
    \end{tabularx}
\end{figure}
\end{frame}
\end{document}

enter image description here

Of course, to see captions, your images show appropriate limit their heights.

Edit: To have numbered captions, you need to add in preamble \setbeamertemplate{caption}[numbered].

Addendum: As asked in comment, the "captions" without word "Figure" is easy to obtain -- just not use \caption{...} :-). Possible solution is demonstrated in MWE below.

\documentclass{beamer}
    \usetheme{default}
%----
    \usepackage{graphicx}
    \usepackage{tabularx}

\begin{document}
\begin{frame}
    \begin{tabularx}{\textwidth}{*{2}{>{\centering\arraybackslash}X}}
\includegraphics[width=0.9\linewidth,height=24mm]{example-image-a}\newline\footnotesize
WT terminal voltage
    &   \includegraphics[width=\linewidth,height=24mm]{example-image-a}\newline\footnotesize
        ???
        \\[1em]  % new row
\includegraphics[width=0.9\linewidth,height=24mm]{example-image-b}\newline\footnotesize
WT terminal current
    &   \includegraphics[width=\linewidth,height=24mm]{example-image-b}\newline\footnotesize
        previous Vterm angle
    \end{tabularx}
\end{frame}
\end{document}

which gives:

enter image description here

  • Is it possible to remove the "Figure" and leave only the caption text, also it it possible to maximize more the figure sizes and reduce the white spaces in between ? – Martin Bakardjiev Feb 14 '16 at 19:28
  • Of course, just not use \caption{...}. It was actulally source of your problems ... I will add to my answer example, which fulfill what you ask. – Zarko Feb 14 '16 at 20:06
1

If I run your example I get

! LaTeX Error: \caption outside figure or table.

If you get an error it isn't really worth looking at the pdf output at all, teX tries to recover to error check more of the file but not to produce sensible output.

If I add tables as the error says the output looks OK to me:

enter image description here

\documentclass{beamer}
\usetheme{default}
\setbeamerfont{caption}{size=\footnotesize}
\begin{document}
  \begin{frame}
      \begin{columns}
          \column{0.5\textwidth}
          \begin{table}
              \centering
              \includegraphics[height=.3\textheight]{example-image}
              \caption{WT terminal voltage}
          \end{table}
          \begin{table}
              \centering
              \includegraphics[height=.3\textheight]{example-image-a}
              \caption{WT terminal current}
          \end{table}
          \column{0.5\textwidth}
          \begin{table}
                      \centering
                      \includegraphics[height=.3\textheight]{example-image-b}
                  \caption{Caption 3}
                  \end{table}
          \begin{table}
              \centering
              \includegraphics[height=.3\textheight]{example-image}
              \caption{previous Vterm angle}
          \end{table}
      \end{columns}
    \end{frame}
   \end{document}

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.