正确对齐子浮点数的标题

正确对齐子浮点数的标题

我正在使用以下代码,但列标题未在列的中心对齐,因此如果有人可以请提供建议:

\documentclass{report}
\usepackage{mwe}

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

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

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

\begin{document}
\centering%

\begin{figure}
\setlength{\tempheight}{0.15\textheight}
\settowidth{\tempwidth}{\includegraphics[height=\tempheight]{example-image-a}}%
\centering
\hspace{\baselineskip}
\columnname{Without Results}
\columnname{With Results}\\
\rowname{Row 1}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-a}}\label{1}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-b}}\label{11}\\
\rowname{Row 2}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-c}}\label{2}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-d}}\label{22}\\
\rowname{Row 3}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-e}}\label{3}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-f}}\label{33}\\
\rowname{Row 4}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-g}}\label{4}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-h}}\label{44}
\caption{capt1}
\label{fig1}
\end{figure}
\end{document}

答案1

\tempheight\tempwidth出错了。经过一些微调,我们得到了这个:

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

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

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

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

\begin{document}
\centering%

\begin{figure}
\setlength{\tempheight}{\heightof{\includegraphics[width=0.48\linewidth]{example-image-a}}}
\setlength{\tempwidth}{0.48\linewidth}%
\centering
\hspace{0.52\baselineskip}
\columnname{Without Results}
\columnname{With Results}\\
\rowname{Row 1}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-a}}\label{1}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-b}}\label{11}\\
\rowname{Row 2}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-c}}\label{2}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-a}}\label{22}\\
\rowname{Row 3}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-b}}\label{3}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-c}}\label{33}\\
\rowname{Row 4}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image}}\label{4}
\subfloat{\includegraphics[width=0.48\linewidth]{example-image-a}}\label{44}
\caption{capt1}
\label{fig1}
\end{figure}
\end{document}

在此处输入图片描述

另一方面,由于您没有使用subcaptions,因此您tabular也可以使用。

\documentclass{report}
\usepackage{graphicx,calc}

\newlength{\tempheight}

\setlength{\tempheight}{\heightof{\includegraphics[width=0.48\linewidth]{example-image-a}}}

\newcommand{\rowname}[1]% #1 = text
{\rotatebox{90}{\parbox{\tempheight}{\centering #1}}}


\begin{document}
\centering%

\begin{figure}
\begin{tabular}{ccc}
& Without Results & With Results\\
\rowname{Row 1} &\includegraphics[width=0.48\linewidth]{example-image-a}
& \includegraphics[width=0.48\linewidth]{example-image-b}\\
\rowname{Row 2} &
\includegraphics[width=0.48\linewidth]{example-image-c} &
\includegraphics[width=0.48\linewidth]{example-image-a}\\
\rowname{Row 3} &
\includegraphics[width=0.48\linewidth]{example-image-b}&
\includegraphics[width=0.48\linewidth]{example-image-c}\\
\rowname{Row 4}&
\includegraphics[width=0.48\linewidth]{example-image}&
\includegraphics[width=0.48\linewidth]{example-image-a}
\end{tabular}
\caption{capt1}
\label{fig1}
\end{figure}
\end{document}

在此处输入图片描述

相关内容