在子浮动框中添加行和列的标题

在子浮动框中添加行和列的标题

我有这个 6x3 子浮点数,我想给它们的每一行添加垂直标题,给每一列添加水平标题。如果有人能告诉我如何做到这一点。我还想把这个图放在一页里。

这是我的身材:

\documentclass[12pt]{report}
\begin{figure}
\centering
\subfloat[0.2]{\includegraphics[width=.32\linewidth {a.png}}\label{a}
\subfloat[0.2]{\includegraphics[width=.32\linewidth]{b.png}}\label{b}
\subfloat[0.3]{\includegraphics[width=.32\linewidth]{c.png}}\label{c}\\
\subfloat[0.5]{\includegraphics[width=.32\linewidth]{d.png}}\label{d}
\subfloat[0.4]{\includegraphics[width=.32\linewidth]{e.png}}\label{e}
\subfloat[0.6]{\includegraphics[width=.32\linewidth]{f.png}}\label{f}\\
\subfloat[0.5]{\includegraphics[width=.32\linewidth]{g.png}}\label{g}
\subfloat[0.5]{\includegraphics[width=.32\linewidth]{h.png}}\label{h}
\subfloat[0.7]{\includegraphics[width=.32\linewidth]{i.png}}\label{i}\\
\subfloat[0.5]{\includegraphics[width=.32\linewidth]{j.png}}\label{j}
\subfloat[0.6]{\includegraphics[width=.32\linewidth]{k.png}}\label{k}
\subfloat[0.7]{\includegraphics[width=.32\linewidth]{l.png}}\label{l}\\
\subfloat[0.5]{\includegraphics[width=.32\linewidth]{m.png}}\label{m}
\subfloat[0.6]{\includegraphics[width=.32\linewidth]{n.png}}\label{n}
\subfloat[0.7]{\includegraphics[width=.32\linewidth]{o.png}}\label{o}\\
\subfloat[0.5]{\includegraphics[width=.32\linewidth]{p.png}}\label{p}
\subfloat[0.6]{\includegraphics[width=.32\linewidth]{q.png}}\label{q}
\subfloat[0.7]{\includegraphics[width=.32\linewidth]{r.png}}\label{r}
\caption{results}
\label{figure1}
\end{figure}

答案1

由于 \captionof 使用 \par 和 \vskip,因此您无法在表格中使用它。编写自己的标题宏会更简单,只要您不希望所有这些子浮点数都出现在图形列表中即可。

\documentclass{memoir}
\usepackage{mwe}

\newlength{\tempdima}
\newcommand{\rowname}[1]% #1 = text
{\rotatebox{90}{\makebox[\tempdima][c]{\textbf{#1}}}}

\newcounter{subfigure}[figure]
\renewcommand{\thesubfigure}{\alph{subfigure}}
\newcommand{\mycaption}[1]% #1 = caption
{\refstepcounter{subfigure}\textbf{(\thesubfigure) }{\ignorespaces #1}}

\begin{document}
\centering%
\begin{figure}
\settoheight{\tempdima}{\includegraphics[width=.32\linewidth]{example-image-a}}%
\centering\begin{tabular}{@{}c@{ }c@{ }c@{ }c@{}}
&\textbf{Trial A} & \textbf{Trial B} & \textbf{Trial C} \\
\rowname{Exp 1}&
\includegraphics[width=.3\linewidth]{example-image-a}&
\includegraphics[width=.3\linewidth]{example-image-b}&
\includegraphics[width=.3\linewidth]{example-image-c}\\[-1ex]
&\mycaption{0.2} & \mycaption{0.2} & \mycaption{0.3}\\
\rowname{Exp 2}&
\includegraphics[width=.3\linewidth]{example-image-a}&
\includegraphics[width=.3\linewidth]{example-image-b}&
\includegraphics[width=.3\linewidth]{example-image-c}\\[-1ex]
&\mycaption{0.5} & \mycaption{0.4} & \mycaption{0.6}\\
\rowname{Exp 3}&
\includegraphics[width=.3\linewidth]{example-image-a}&
\includegraphics[width=.3\linewidth]{example-image-b}&
\includegraphics[width=.3\linewidth]{example-image-c}\\[-1ex]
&\mycaption{0.5} & \mycaption{0.5} & \mycaption{0.7} \\
\rowname{Exp 4}&
\includegraphics[width=.3\linewidth]{example-image-a}&
\includegraphics[width=.3\linewidth]{example-image-b}&
\includegraphics[width=.3\linewidth]{example-image-c}\\[-1ex]
&\mycaption{0.5} & \mycaption{0.6} & \mycaption{0.7} \\
\rowname{Exp 5}&
\includegraphics[width=.3\linewidth]{example-image-a}&
\includegraphics[width=.3\linewidth]{example-image-b}&
\includegraphics[width=.3\linewidth]{example-image-c}\\[-1ex]
&\mycaption{0.5} & \mycaption{0.6} & \mycaption{0.7} \\
\rowname{Exp 6}&
\includegraphics[width=.3\linewidth]{example-image-a}&
\includegraphics[width=.3\linewidth]{example-image-b}&
\includegraphics[width=.3\linewidth]{example-image-c}\\[-1ex]
&\mycaption{0.5} & \mycaption{0.6} & \mycaption{0.7} \\
\end{tabular}
\caption{results}%
\label{figure1}
\end{figure}
\end{document}

表格标题


是的,不使用表格也可以实现这一点。

\documentclass{report}
\usepackage{subfig}
\usepackage{mwe}

\newlength{\tempheight}
\newlength{\tempwidth}

\newcommand{\rowname}[1]% #1 = text
{\rotatebox{90}{\makebox[\tempheight][c]{\textbf{#1}}}}

\newcommand{\columnname}[1]% #1 = text
{\makebox[\tempwidth][c]{\textbf{#1}}}

\begin{document}
\begin{figure}
\setlength{\tempwidth}{.3\linewidth}
\settoheight{\tempheight}{\includegraphics[width=\tempwidth]{example-image-a}}%
\centering
\hspace{\baselineskip}
\columnname{Test A}\hfil
\columnname{Test B}\hfil
\columnname{Test C}\\
\rowname{Exp 1}
\subfloat[0.2]{\includegraphics[width=\tempwidth]{example-image-a}}\label{a}\hfil
\subfloat[0.2]{\includegraphics[width=\tempwidth]{example-image-b}}\label{b}\hfil
\subfloat[0.3]{\includegraphics[width=\tempwidth]{example-image-c}}\label{c}\\
\rowname{Exp 2}
\subfloat[0.5]{\includegraphics[width=\tempwidth]{example-image-a}}\label{d}\hfil
\subfloat[0.4]{\includegraphics[width=\tempwidth]{example-image-b}}\label{e}\hfil
\subfloat[0.6]{\includegraphics[width=\tempwidth]{example-image-c}}\label{f}\\
\rowname{Exp 3}
\subfloat[0.5]{\includegraphics[width=\tempwidth]{example-image-a}}\label{g}\hfil
\subfloat[0.5]{\includegraphics[width=\tempwidth]{example-image-b}}\label{h}\hfil
\subfloat[0.7]{\includegraphics[width=\tempwidth]{example-image-c}}\label{i}\\
\rowname{Exp 4}
\subfloat[0.5]{\includegraphics[width=\tempwidth]{example-image-a}}\label{j}\hfil
\subfloat[0.6]{\includegraphics[width=\tempwidth]{example-image-b}}\label{k}\hfil
\subfloat[0.7]{\includegraphics[width=\tempwidth]{example-image-c}}\label{l}\\
\rowname{Exp 5}
\subfloat[0.5]{\includegraphics[width=\tempwidth]{example-image-a}}\label{m}\hfil
\subfloat[0.6]{\includegraphics[width=\tempwidth]{example-image-b}}\label{n}\hfil
\subfloat[0.7]{\includegraphics[width=\tempwidth]{example-image-c}}\label{o}\\
\rowname{Exp 6}
\subfloat[0.5]{\includegraphics[width=\tempwidth]{example-image-a}}\label{p}\hfil
\subfloat[0.6]{\includegraphics[width=\tempwidth]{example-image-b}}\label{q}\hfil
\subfloat[0.7]{\includegraphics[width=\tempwidth]{example-image-c}}\label{r}
\caption{results}
\label{figure1}
\end{figure}
\end{document}

带有列名和行名的子浮点数


在准备这个 \hfil 演示时,我发现事情并不像我想象的那么简单。具体来说,\\ 和 \newline 似乎在右侧增加了一些额外的空间,而不仅仅是 \hfil。然而,在 \centering 之后,\\ 会丢失额外的空间(但 \newline 不会)。

最后要记住的是,由于一行中的所有 \hfil 都扩展为相同的大小,如果 \hfil 之间的内容大小不一样,那么它们将不会精确对齐。

\documentclass{article}
\begin{document}

\begin{figure}[t]
\rule{\textwidth}{1pt}
\hfil\fbox{centered}\linebreak[4]
\hfil\fbox{skewed}\\
\indent\hfil\fbox{recentered}\\
\hfil\fbox{two}\hfil\fbox{columns}\linebreak[4]
\hfil\fbox{now}\hfil\fbox{three}\hfil\fbox{columns}\linebreak[4]
\centering\fbox{centered}\\
\fbox{skewed}\newline
\fbox{two}\hfil\fbox{columns}\\
\fbox{now}\hfil\fbox{three}\hfil\fbox{columns}\\
\fbox{left}\hfill\fbox{center}\hfill\fbox{right}\\
\leavevmode\rlap{\fbox{left}}\hfill\fbox{center}\hfill\llap{\fbox{right}}\\
\rule{\textwidth}{1pt}
\end{figure}

\end{document}

相关内容