図のキャプションは下ではなく横に表示されます

図のキャプションは下ではなく横に表示されます

私は、Beamer クラスを使用してプレゼンテーションを作成しています。Minipage を使用して、2 x 2 の配置で 4 つの図を取得しています。

図にキャプションを付けるときに、2 つの問題が発生します。

  • キャプションは図の下ではなく、図のすぐ下から始まります
  • 図のサイズを縮小する代わりに、キャプションは図によって切り取られます。
  • また、次のエラーも発生します: 「\caption が図または表の外側にあります。\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}

ここに画像の説明を入力してください

答え1

次のアプローチを使用すると、複雑さが軽減されます。

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

ここに画像の説明を入力してください

もちろん、キャプションを表示するには、画像の高さを適切に制限する必要があります。

編集: 番号付きキャプションを使用するには、プリアンブルを追加する必要があります\setbeamertemplate{caption}[numbered]

補遺: コメントで尋ねられているように、「図」という単語のない「キャプション」は簡単に取得できますが、使用しないでください\caption{...}:-)。 可能な解決策は、以下の MWE で示されています。

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

これにより、次のようになります。

ここに画像の説明を入力してください

答え2

あなたの例を実行すると、

! LaTeX Error: \caption outside figure or table.

エラーが発生した場合、PDF 出力を見る価値はまったくありません。TeX はファイルのエラー チェックをさらに実行して回復を試みますが、意味のある出力を生成するわけではありません。

エラーのとおりにテーブルを追加すると、出力は問題ないように見えます。

ここに画像の説明を入力してください

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

関連情報