0


In each row in my table, I have a multirow that spans two columns, and also in the last column I am adding an image.

The table looks something like this: enter image description here

Now, you'll notice the horizontal line separating the multirow is not symmetrically aligned to the image. I'd like to have equal amount of space in the upper and lower 'sub-row' of each row. How can I do this?

The code I am using looks something like this (the example has only one row):

\documentclass[11pt]{report} 
\begin{document}
\begin{table}[]
\caption{Table with transformation details}
\label{transformations}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{lllllll}
\hline
Variable & Transformation & Skewness & Kurtosis & Winsorisation & Polarity & Distributions \\ \hline
\multirow{2}{*}{Crime} & Raw Data & 6.945 & 57.658 & \multirow{2}{*}{maxval = 0.002} & \multirow{2}{*}{-} & \multirow{2}{*}{} \\ \cmidrule{2-4}
 & Transformed & -1.581 & 5.385 &  &  & \begin{minipage}{.3\textwidth}\includegraphics[width=\linewidth, height=25mm]{Images/dist/distributions_crime1.png} \end{minipage} \\ \hline
\end{tabular}%
}
\end{table}
\end{document}

Cheers!

1 Answer 1

1

Something like this below?

Note, your table is much wider than the available space, hence I have applied sidewaystable to add rotation, instead of scaling the whole table, which is not recommended. If you prefer upright table, perhaps re-consider changing long content in headers and cells with texts.

The centring in bottom cells is achieved by moving baseline of images to the middle point via extra optional argument valign=c (requires to load adjustbox with optional [export]).

\vcorrection is to correct multirow which sometimes needs an extra offset if extra spacing is introduced in the table. The factor -0.5 might need slight tuning.

A couple of minor changes and suggestions. Consider using prefix in labels, s.a. tab:... for tables or fig:... for figures. You can shorten repeated column definition, e.g. *{n}{<col-type>}, e.g. *{7}{l}--if n is one digit, it can be even shorter: *7{l}. If you load booktabs, you have access to other custom rules: \toprule, \bottomrule, \midrule, each of which accept optional argument rule width, e.g. \midrule[1.2pt]; they differ in adding extra space above or/and below rules.

\documentclass[11pt]{report}
\usepackage{booktabs}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{caption}

\newlength\vcorrection


\begin{document}
\begin{sidewaystable}
    \setlength\vcorrection{-0.5\dimexpr\aboverulesep+\belowrulesep}
    \captionsetup{skip=3pt}
    \renewcommand{\arraystretch}{1.25}
    \caption{Table with transformation details}
    \label{tab:transformations}
    \centering
    \begin{tabular}{*7{l}}
        \toprule
        Variable & Transformation & Skewness & Kurtosis & Winsorisation & Polarity & Distributions \\
        \hline
        \multirow{2}*[\vcorrection]{Crime}
        & Raw Data
        & 6.945
        & 57.658
        & \multirow{2}*[\vcorrection]{maxval = 0.002}
        & -
        & \\
        \cmidrule{2-4}
              & Transformed & -1.581 & 5.385  &                &   & \includegraphics[width=4\dimexpr25mm/3, height=25mm, valign=c]{Images/dist/distributions_crime1.png} \\
        \midrule
        \multirow{2}*[\vcorrection]{Train station}
        & Raw Data
        & 2.398
        & 10.558
        & \multirow{2}*[\vcorrection]{maxval = 50000}
        & -
        & \\
        \cmidrule{2-4}
              & Transformed & -0.528 & 2.470  &                &   & \includegraphics[width=4\dimexpr25mm/3, height=25mm, valign=c]{Images/dist/distributions_crime1.png} \\
        \bottomrule
    \end{tabular}
\end{sidewaystable}
\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 .