
Tengo tres modelos que pruebo bajo diferentes configuraciones de parámetros. Creé una figura donde cada columna corresponde a un modelo. Me gustaría agregar el valor del parámetro a la izquierda de cada fila. Despues de leeresta respuesta, esto es lo que hago:
\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}
Pero entiendo esto:
¿Cómo puedo hacerlo bien?
Respuesta1
Una posibilidad (los %
signos que suprimen los espacios en blanco falsos son esenciales):
Actualizar
Una versión modificada (la construcción completa ahora permanece dentro del ancho del texto):
\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}
El resultado:
Primera versión
(las etiquetas sobresalen hacia el margen izquierdo):
\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}
El resultado:
Ajuste las longitudes en las \raisebox
es y \makebox
en las interiores según sus necesidades.
Respuesta2
Hay dos problemas con su código: primero, dado que usa width=\textwidth
, la etiqueta y la imagen no caben en una línea y, por lo tanto, se inicia una nueva línea para la imagen. El segundo problema es que la línea base de la imagen no está en su centro vertical. Esto se puede cambiar por \raisebox
. Suponiendo que todas sus imágenes tengan el mismo ancho y alto, lo siguiente podría ayudar:
\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}
Tenga en cuenta que si \textwidth
es pequeño, width=.9\textwidth
es posible que tampoco deje suficiente espacio para la etiqueta. Además, podrías considerar usar \hspace{\fill}
en lugar de \hspace{1em}
si tienes un archivo \textwidth
.