答案1
尝试下面的解决方案。在代码中:
\adjustboxset
将adjustbox
设置全局应用于每个图像或本地环境valign=c
,来自的附加键adjustbox
,在中间点设置图像基线\cellspacetoplimit
并\cellspacebottomlimit
强制在其自己的列类型中行与行之间有cellspace
最小间距S{x}
,其中x
可以是l
、、或任何常规列类型c
r
p{...}
\multicolmn
S{x}
取消标题中的效果。
为了使\adjustbox
本示例能够正常工作,可选操作[Export]
是必需的。
代码如下:
\documentclass{article}
\usepackage{graphicx}
\usepackage[Export]{adjustbox}
\usepackage{tabularx}
\usepackage{cellspace}
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{0pt}
\renewcommand\tabularxcolumn[1]{>{\centering\arraybackslash}S{p{#1}}}
\begin{document}
\begin{figure}[tbh]
\setlength\tabcolsep{6pt}
\adjustboxset{width=\linewidth,valign=c}
\centering
\begin{tabularx}{1.0\linewidth}{@{}
l
X @{\hspace{6pt}}
X
@{}}
& \multicolumn{1}{c}{\textbf{1994}}
& \multicolumn{1}{c}{\textbf{2007}} \\
\rotatebox[origin=c]{90}{\textbf{Risk score}}
& \includegraphics{example-image}
& \includegraphics{example-image} \\
\rotatebox[origin=c]{90}{\textbf{Caseload size}}
& \includegraphics{example-image}
& \includegraphics{example-image}
\end{tabularx}
\end{figure}
\end{document}
答案2
下列的这个答案,我只是将列标题从其子图空间的底部移到了顶部。结果如下:
\documentclass{article}
\usepackage[draft]{graphicx}
\usepackage{subcaption}
\newcommand\myrowlabel[1]{%
\rotatebox[origin=c]{90}{#1}%
}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[c]{0.30\textwidth}\raggedleft
\caption{model A}
\myrowlabel{$R=1$}
\raisebox{-.5\height}{\includegraphics[width=.9\textwidth]
{example-image-a}}\\
\myrowlabel{$R=2$}
\raisebox{-.5\height}{\includegraphics[width=.9\textwidth]
{example-image-a}}\\
\myrowlabel{$R=3$}
\raisebox{-.5\height}{\includegraphics[width=.9\textwidth]
{example-image-a}}
\end{subfigure}%
\hspace{1em}
\begin{subfigure}[c]{0.30\textwidth}\raggedleft
\caption{model B}
\includegraphics[width=.9\textwidth]
{example-image-b}
\includegraphics[width=.9\textwidth]
{example-image-b}
\includegraphics[width=.9\textwidth]
{example-image-b}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[c]{0.30\textwidth}\centering
\caption{model C}
\includegraphics[width=.9\textwidth]
{example-image-c}
\includegraphics[width=.9\textwidth]
{example-image-c}
\includegraphics[width=.9\textwidth]
{example-image-c}
\end{subfigure}
\caption{Grid test}
\end{figure}
\end{document}