サブ図: 各行と各列のキャプション

サブ図: 各行と各列のキャプション

異なるパラメータ設定でテストするモデルが3つあります。各列がモデルに対応する図を作成しました。各行の左側にパラメータの値を追加したいと思います。この答え、 これが私がすることです:

\documentclass{article}

\usepackage[draft]{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
    \rotatebox[origin=c]{90}{$R=1$}
    \includegraphics[width=\textwidth]
    {test.png}
    \rotatebox[origin=c]{90}{$R=2$}
    \includegraphics[width=\textwidth]
    {test.png}
    \rotatebox[origin=c]{90}{$R=3$}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model A}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[t]{0.30\textwidth}
    \includegraphics[width=\textwidth]  
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model B}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[t]{0.30\textwidth}
    \includegraphics[width=\textwidth]  
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model C}
\end{subfigure}
\caption{Grid test}
\end{figure}

しかし、私はこれを理解します: テスト

どうすれば直せるでしょうか?

答え1

1 つの可能性 (%不必要な空白スペースを抑制する標識が必須です):

アップデート

修正バージョン (構造全体がテキスト幅内に収まるようになりました):

\documentclass{article}
\usepackage[draft]{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% just for visiual guide

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[t]{\dimexpr0.30\textwidth+20pt\relax}
    \makebox[20pt]{\raisebox{40pt}{\rotatebox[origin=c]{90}{$R=1$}}}%
    \includegraphics[width=\dimexpr\linewidth-20pt\relax]
    {test.png}
    \makebox[20pt]{\raisebox{40pt}{\rotatebox[origin=c]{90}{$R=2$}}}%
    \includegraphics[width=\dimexpr\linewidth-20pt\relax]
    {test.png}
    \makebox[20pt]{\raisebox{40pt}{\rotatebox[origin=c]{90}{$R=3$}}}%
    \includegraphics[width=\dimexpr\linewidth-20pt\relax]
    {test.png}
    \caption{model A}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.30\textwidth}
    \includegraphics[width=\textwidth]  
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model B}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.30\textwidth}
    \includegraphics[width=\textwidth]  
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model C}
\end{subfigure}
\caption{Grid test}
\end{figure}

\end{document}

結果:

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

最初のバージョン

(ラベルは左余白にはみ出します):

\documentclass{article}
\usepackage[draft]{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
    \makebox[0pt][r]{\makebox[30pt]{\raisebox{40pt}{\rotatebox[origin=c]{90}{$R=1$}}}}%
    \includegraphics[width=\textwidth]
    {test.png}
    \makebox[0pt][r]{\makebox[30pt]{\raisebox{40pt}{\rotatebox[origin=c]{90}{$R=2$}}}}%
    \includegraphics[width=\textwidth]
    {test.png}
    \makebox[0pt][r]{\makebox[30pt]{\raisebox{40pt}{\rotatebox[origin=c]{90}{$R=3$}}}}%
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model A}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[t]{0.30\textwidth}
    \includegraphics[width=\textwidth]  
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model B}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[t]{0.30\textwidth}
    \includegraphics[width=\textwidth]  
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \includegraphics[width=\textwidth]
    {test.png}
    \caption{model C}
\end{subfigure}
\caption{Grid test}
\end{figure}

\end{document}

結果:

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

必要に応じて、\raiseboxes と内側のesの長さを調整します。\makebox

答え2

コードには 2 つの問題があります。まず、 を使用しているためwidth=\textwidth、ラベルと画像が 1 行に収まらず、画像用に新しい行が開始されます。2 つ目の問題は、画像のベースラインが垂直方向の中央にないことです。これは によってシフトできます\raisebox。すべての画像の幅と高さが同じであると仮定すると、次の方法が役立つ可能性があります。

\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
    \myrowlabel{$R=1$}
    \raisebox{-.5\height}{\includegraphics[width=.9\textwidth]
    {test.png}}\\
    \myrowlabel{$R=2$}
    \raisebox{-.5\height}{\includegraphics[width=.9\textwidth]
    {test.png}}\\
    \myrowlabel{$R=3$}
    \raisebox{-.5\height}{\includegraphics[width=.9\textwidth]
    {test.png}}
    \caption{model A}
\end{subfigure}%
\hspace{1em}
\begin{subfigure}[c]{0.30\textwidth}\raggedleft
    \includegraphics[width=.9\textwidth]  
    {test.png}
    \includegraphics[width=.9\textwidth]
    {test.png}
    \includegraphics[width=.9\textwidth]
    {test.png}
    \caption{model B}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[c]{0.30\textwidth}\centering
    \includegraphics[width=.9\textwidth]  
    {test.png}
    \includegraphics[width=.9\textwidth]
    {test.png}
    \includegraphics[width=.9\textwidth]
    {test.png}
    \caption{model C}
\end{subfigure}
\caption{Grid test}
\end{figure}
\end{document}

\textwidthが小さい場合は、width=.9\textwidthラベル用のスペースが十分に残らない可能性があることに注意してください。さらに、が小さい場合は、\hspace{\fill}の代わりにを使用することを検討してください。 \hspace{1em}\textwidthここに画像の説明を入力してください

関連情報