
答えが見つかると思ったここしかし、この特定のケースでは解決策が機能しないようです...
一般的に: tikz ノード内の図のキャプションをどのように配置しますか? 次の MWE を作成しましたが、これはプレゼンテーションで使用するレイアウトではなく、単なるランダムなレイアウトなので、この例だけでなく、一般的なソリューションが必要です...
この例では、図 B のすぐ下にキャプションを配置したいのですが、どうすればよいでしょうか?
MWE:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage[labelformat=empty,font=scriptsize,skip=0pt,
justification=raggedright,singlelinecheck=false]{caption}
\begin{document}
\begin{frame}
\begin{figure}
\begin{tikzpicture}[remember picture, every node/.style={inner sep=0,outer sep=0}]
\node[anchor=west] (A) at (0,0) {\includegraphics[width=2.25cm]{example-image-a}};
\node[right=0.75cm of A.east, anchor=west] (B) {\includegraphics[width=2.25cm]{example-image-b}
%\captionof{figure}{my caption here}%I was hoping this would work...
};
\node[below=\belowcaptionskip of B,text width=\linewidth]
{\captionof{figure}{my caption here}};%And this doesn't work either...
\node [right=0.75cm of B.east, anchor=west] (C) {\includegraphics[width=2.25cm]{example-image-c}};
\node [below=0.75cm of A.south east, anchor=north west] (D) {\includegraphics[width=2.25cm]{example-image}};
\node [right=0.75cm of D.east, anchor=west] (E) {\includegraphics[width=2.25cm]{example-image}};
\node [right=0.75cm of E.east, anchor=west] (F) {\includegraphics[width=2.25cm]{example-image}};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
生産:
答え1
キャプションが 1 行しかない場合は、caption
パッケージとfigure
環境を使用せずに目的の結果を得ることができます。
\documentclass{beamer}
\usepackage{lmodern,tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}[node distance=2mm and 5mm]
\node (A) {\includegraphics[width=2.25cm]{example-image-a}};
\node [right=of A] (B) {\includegraphics[width=2.25cm]{example-image-b}};
\node [right=of B] (C) {\includegraphics[width=2.25cm]{example-image-c}};
\node (capt) [below=of B,text width=\linewidth, align=center,font=\scriptsize]
{my caption here};
\node [below=of A |- capt.south] (D) {\includegraphics[width=2.25cm]{example-image}};
\node [right=of D] (E) {\includegraphics[width=2.25cm]{example-image}};
\node [right=of E] (F) {\includegraphics[width=2.25cm]{example-image}};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
ただし、TikZ 画像を 2 つの部分に分割できます。
\documentclass{beamer}
\usepackage{lmodern,tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}
\begin{figure}\centering
\begin{tikzpicture}[node distance=2mm and 5mm]
\node (A) {\includegraphics[width=2.25cm]{example-image-a}};
\node [right=of A] (B) {\includegraphics[width=2.25cm]{example-image-b}};
\node [right=of B] (C) {\includegraphics[width=2.25cm]{example-image-c}};
\end{tikzpicture}
\caption{my caption here}
\begin{tikzpicture}[node distance=2mm and 5mm]
\node (D) {\includegraphics[width=2.25cm]{example-image}};
\node [right=of D] (E) {\includegraphics[width=2.25cm]{example-image}};
\node [right=of E] (F) {\includegraphics[width=2.25cm]{example-image}};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
キャプションにラベルを付けたくない場合はFigure
、それに応じてテンプレートを設定するだけで済みますcaption
。たとえば、プリアンブルに以下を追加します。
\setbeamerfont{caption}{size=\scriptsize}
\setbeamertemplate{caption}{\insertcaption\par}
付録: TikZ ノードの目的が何なのか、私にはよく分かりません。ノード内の画像は、ノードがなくても以前と同じフレーム形式で配置できます。
\documentclass{beamer}
\setbeamerfont{caption}{size=\scriptsize}
\setbeamertemplate{caption}{\insertcaption\par}
\begin{document}
\begin{frame}
\begin{figure}\centering
\includegraphics[width=2.25cm]{example-image-a}\hfil
\includegraphics[width=2.25cm]{example-image-b}\hfil
\includegraphics[width=2.25cm]{example-image-c}
\caption{my caption here}
\includegraphics[width=2.25cm]{example-image}\hfil
\includegraphics[width=2.25cm]{example-image}\hfil
\includegraphics[width=2.25cm]{example-image}
\end{figure}
\end{frame}
\end{document}
フレームのイメージは以前と同じですが、コードはよりシンプルで簡潔になっています。
答え2
justification=centering
パッケージ内のオプションを使用しますcaption
。
\documentclass{beamer}
\usepackage{lmodern,tikz}
\usetikzlibrary{positioning,calc}
\usepackage[labelformat=empty,font=scriptsize,skip=0pt,
justification=centering,singlelinecheck=false]{caption}
\begin{document}
\begin{frame}
\begin{figure}\centering
\begin{tikzpicture}
\node [anchor=west] (A) at (0,0) {\includegraphics[width=2.25cm]{example-image-a}};
\node [right=0.75cm of A.east, anchor=west] (B) {\includegraphics[width=2.25cm]{example-image-b}};
\node [below=\belowcaptionskip of B,text width=\linewidth]{\captionof{figure}{my caption here}};
\node [right=0.75cm of B.east, anchor=west] (C) {\includegraphics[width=2.25cm]{example-image-c}};
\node [below=0.75cm of A.south, anchor=north] (D) {\includegraphics[width=2.25cm]{example-image}};
\node [right=0.75cm of D.east, anchor=west] (E) {\includegraphics[width=2.25cm]{example-image}};
\node [right=0.75cm of E.east, anchor=west] (F) {\includegraphics[width=2.25cm]{example-image}};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}