1

I am using tabular environment to insert subplots. Here is the output

enter image description here

My only issue is that I need entries in left most column to be in middle as indicated by the red arrows. It seems like a straight forward thing but somehow I am not able to fix it.

Secondly, right now individual images take more horizontal space within the table. How do I adjust their size so that they are perfect squares instead of rectangles.

Here is code:

\documentclass{article}

\usepackage{adjustbox}
\usepackage{booktabs,rotating,bigstrut}

\begin{document}

\begin{center}
    \begin{tabular}{cccc}
    {}&
    $\frac{\sigma_1}{\sigma_2}=0.5$ &
    $\frac{\sigma_1}{\sigma_2}=1$&
    $\frac{\sigma_1}{\sigma_2}=2$\\
    $\rho=0$ &
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio5_Rho0}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio1_Rho0}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio2_Rho0}\\
    $\rho=0.5$&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio5_Rho50}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio1_Rho50}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio2_Rho50}\\
    \end{tabular}
\end{center}

\end{document}

3 Answers 3

3

Using the valign key of adjustbox you can get what you want (note that I used another image, as I don't have access to your images):

\documentclass{article}

\usepackage{adjustbox}
\usepackage{booktabs,rotating,bigstrut}

\begin{document}

\begin{center}
    \begin{tabular}{cccc}
    &
    $\frac{\sigma_1}{\sigma_2}=0.5$ &
    $\frac{\sigma_1}{\sigma_2}=1$&
    $\frac{\sigma_1}{\sigma_2}=2$\\
    \noalign{\smallskip}
    $\rho=0$ &
    \adjustimage{width=.25\textwidth,valign=c}{example-image-duck}&
    \adjustimage{width=.25\textwidth,valign=c}{example-image-duck}&
    \adjustimage{width=.25\textwidth,valign=c}{example-image-duck}\\
    \noalign{\smallskip}
    $\rho=0.5$&
    \adjustimage{width=.25\textwidth,valign=c}{example-image-duck}&
    \adjustimage{width=.25\textwidth,valign=c}{example-image-duck}&
    \adjustimage{width=.25\textwidth,valign=c}{example-image-duck}\\
    \end{tabular}
\end{center}

\end{document}

enter image description here

2
  • Could you suggest a way to add caption to each subplot in your solution. I get error "You can't use `\hrule' here except with leaders.\caption@hrule ->\hrule " when I add caption like "\adjustimage{width=.25\textwidth,valign=c}{example-image-duck}\caption{1}"
    – NAASI
    Commented Sep 18, 2018 at 18:59
  • (Untested) Maybe something like \begin{minipage}{<your width>}\captionof{figure}{<your caption>}\end{minipage} in an extra row (if you get an undefined control sequence \captionof error, load the capt-of package)?
    – Skillmon
    Commented Sep 18, 2018 at 19:07
1

similar to Skillmon answer but with little bit shorter code:

\documentclass{article}

\usepackage[demo]{adjustbox} % in real document remove option "demo"

\begin{document}

\begin{center}
\adjustboxset{width=.25\textwidth,valign=c, margin=0pt 3pt 0pt 3pt} % <---
    \begin{tabular}{cccc}
    {}&
    $\frac{\sigma_1}{\sigma_2}=0.5$ &
    $\frac{\sigma_1}{\sigma_2}=1$&
    $\frac{\sigma_1}{\sigma_2}=2$\\
    $\rho=0$ &
    \adjustimage{}{ChannelContourPlot_VarRatio5_Rho0}&
    \adjustimage{}{ChannelContourPlot_VarRatio1_Rho0}&
    \adjustimage{}{ChannelContourPlot_VarRatio2_Rho0}\\
    $\rho=0.5$&
    \adjustimage{}{ChannelContourPlot_VarRatio5_Rho50}&
    \adjustimage{}{ChannelContourPlot_VarRatio1_Rho50}&
    \adjustimage{}{ChannelContourPlot_VarRatio2_Rho50}
    \end{tabular}
\end{center}

\end{document}

enter image description here

0

Same key: valign=c. Since you load booktabs, I suggest inserting \addlinespace to have a blank space between the rows. Also, I think using the medium-sized fractions from nccmath look nicer:

\documentclass{article}

\usepackage[demo]{adjustbox}
\usepackage{array, booktabs,rotating,bigstrut}
\usepackage{nccmath}

\begin{document}

\begin{center}
    \adjustboxset{valign=c}
    \begin{tabular}{cccc}
    {}&
    $\mfrac{\sigma_1}{\sigma_2}=0.5$ &
    $\mfrac{\sigma_1}{\sigma_2}=1$&
    $\mfrac{\sigma_1}{\sigma_2}=2$\\
    \addlinespace
    $\rho=0$ &
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio5_Rho0}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio1_Rho0}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio2_Rho0}\\
    \addlinespace[1.5ex]
    $\rho=0.5$&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio5_Rho50}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio1_Rho50}&
    \adjustimage{width=.25\textwidth}{ChannelContourPlot_VarRatio2_Rho50}\\
    \end{tabular}
\end{center}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .