2

I'm trying to fit the images in a mulitrow cell, but the image is too large for the cell. Hpw do I adjust the size of the cell to fit the image fully?

My code is

\documentclass[11pt]{report} 
\begin{landscape}
\begin{longtable}{|c|c|c|c|c|c|c|c|c|}
\caption{Table with transformation details}
\label{appendix:tableindicators}
\hline
\footnotesize Theme & \footnotesize Indicator & \footnotesize Method of Calculation & \footnotesize Transformation & \footnotesize Polarity & \footnotesize Type & \footnotesize Skewness & \footnotesize Kurtosis & \footnotesize Distributions \\ \hline

\multirow{8}{*}{\rotatebox[origin=c]{90}{Transportation}} &
\multirow{2}{*}{\footnotesize Train Station} & \multirow{2}{*}{\scriptsize Walking distance to nearest} & \multirow{2}{*}{\scriptsize \begin{tabular}[c]{@{}l@{}}1) Natural Logarithm(x)\\ 2) Winsorisation(6, 11)\end{tabular}} & \multirow{2}{*}{-} & \scriptsize Raw Data & 2.397 & 10.552 & \multirow{2}{*}{\includegraphics[width=50mm]{Images/dist/distributions_station1.png}} \\ \cline{6-8}
 &  &  &  &  & \scriptsize Transformed & -0.528 & 2.469 &  \\ \cline{2-9} 

 & \multirow{2}{*}{\footnotesize Bus Stop} & \multirow{2}{*}{\scriptsize Walking distance to nearest} & \multirow{2}{*}{\scriptsize 1) Winsorize(0, 1000)} & \multirow{2}{*}{-} & \scriptsize Raw Data & 3.871 &  37.268 & \multirow{2}{*}{\includegraphics[width=50mm]{Images/dist/distributions_bustop1.png}} \\ \cline{6-8}
 &  &  &  &  & \scriptsize Transformed &  -1.189 & 4.368  &  \\ \cline{2-9} 
 
 & \multirow{2}{*}{\footnotesize \makecell{Bus Stop with\\ Frequent Services}} & \multirow{2}{*}{\scriptsize Walking distance to nearest} & \multirow{2}{*}{\scriptsize 1) Winsorize(0, 3500)} & \multirow{2}{*}{-} & \scriptsize Raw Data &  2.817   & 15.448  & \multirow{2}{*}{\includegraphics[width=50mm]{Images/dist/distributions_freqbusstop1.png}} \\ \cline{6-8}
 &  &  &  &  & \scriptsize Transformed &  -1.682 & 5.843  &  \\ \cline{2-9} 
 
 & \multirow{2}{*}{\footnotesize Bikeability} & \multirow{2}{*}{\scriptsize \makecell{Total length of bikeable \\ paths/roads, divided by area}} & \multirow{2}{*}{\scriptsize \begin{tabular}[c]{@{}l@{}}1) Box-Cox ($\lambda=-2$) \\ 2) Winsorisation(-50, -25)\end{tabular}} & \multirow{2}{*}{+} & \scriptsize Raw Data &  1.560 & 7.246  & \multirow{2}{*}{\includegraphics[width=60mm]{Images/dist/distributions_bikeability1.png}} \\ \cline{6-8}
 &  &  &  &  &\scriptsize Transformed &  0.576  & 3.431 &  \\ \hline 
 
\end{longtable}
\end{landscape}
\end{document}

enter image description here

Thank you!

1
  • Welcome to TeX.SE! Could you edit your code to begin with your \documentclass and end with \end{document} , a Minimal Working Example (MWE) please. It makes copy and pasting easier when the code can be compiled and also we do not need to guess what commands or packages you are using. Also, we do not have access to your images you are including
    – JamesT
    Feb 17 at 16:40

1 Answer 1

4

Like this?

enter image description here

  • simpler, far more concise table code can be obtained by use of the longtblr of tabularray package
  • table is huge, so you may consider to reduce page borders that table would have more space and in it can be use bigger font size, for example \footnotesize
\documentclass[11pt]{report}
\usepackage[margin=25mm]{geometry}  % or other suitable page layout
\usepackage[export]{adjustbox}

\usepackage{enumitem}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\UseTblrLibrary{siunitx,
                varwidth}
\usepackage{pdflscape}

\begin{document}
    \begin{landscape}

\begingroup
    \setlist[enumerate]{nosep,
                      itemsep=0.5ex,
                      leftmargin=*}
\settowidth\rotheadsize{Transportation}    % from makecell
\setkeys{Gin}{width=\linewidth}
\begin{longtblr}[
caption = {Table with transformation details},
  label = {appendix:tableindicators}
                ]{hlines, vlines,
                  colsep  = 4pt,
                  colspec = {c  X[1.3, c, m] 
                                X[1.5, c, m]   X[2,l, m]
                                Q[c,m, mode=math]      
                                Q[c,m]  
                                Q[c, si={table-format=-1.3}]
                                Q[c, si={table-format= 2.3}]
                                X[2,c]
                             },
                 measure = vbox,
                    rows = {font=\footnotesize},
                  row{1} = {guard, font=\scriptsize\bfseries, c, mode=text},
                  cell{even[2]}{2-5,Z} = {r=2}{},
                   vspan = even,
                 stretch = -1,
                 rowhead = 1,
                  }
% columns headers               
Theme   & Indicator 
            & Method of Calculation 
                & Transformation 
                    & Polarity 
                        & Type 
                            & Skewness 
                                & Kurtosis 
                                    & Distributions         \\ 
%  table body                                  
\SetCell[r=8]{c, cmd=\rothead}  Transportation
    &   Train Station
        &   Walking distance to nearest
            &   \begin{enumerate}
            \item   Natural Logarithm(x)
            \item   Winsorisation(6, 11)
                \end{enumerate}
                & - &   Raw Data
                        & 2.397
                            & 10.552
                                &   \includegraphics{example-image-duck}
                                            \\
    &   &   &   &   &   Transformed
                        & -0.528
                            & 2.469
                                &       \\
    &   Bus Stop
        & Walking distance to nearest
            &   \begin{enumerate}
            \item   Winsorize(0, 1000)
                \end{enumerate}
                & - &   Raw Data
                        & 3.871
                            &  37.268
                                &   \includegraphics{example-image-duck}
                                            \\
    &   &   &   &   &   Transformed
                        & -1.189 
                            & 4.368  
                                &           \\
   &   Bus Stop with Frequent Services
        &   Walking distance to nearest
            &   \begin{enumerate}
            \item   Winsorize(0, 3500)
                \end{enumerate}
                & - &   Raw Data 
                        & 2.817   
                            & 15.448  
                                &   \includegraphics{example-image-duck}
                                            \\
    &   &   &   &   &   Transformed 
                        & -1.682 
                            & 5.843  
                                &           \\
    &   Bikeability
        &   Total length of bikeable paths/roads, divided by area
            &   \begin{enumerate}
            \item   Box-Cox ($\lambda=-2$) 
            \item   Winsorisation(-50, -25)
                \end{enumerate} 
                & + &   Raw Data 
                        & 1.560 
                            & 7.246 
                                &   \includegraphics{example-image-duck}
                                                \\
    &   &   &   &   &   Transformed 
                        & 0.576  
                            & 3.431 
                                &               \\
\end{longtblr}
\endgroup
    \end{landscape}
\end{document}

Addendum:
Regarding your comment you should be aware, that table can breaks only between rows. This means, that in in your case you can have a problems with handling of multirow cells:

  • For correct table breaking between multirow cells try to terminate rows with inserted images with \\*. It prevent table break after this row.
  • You may consider to turn first column into row with table parts "subtitles".
  • It may also helped to reduce for a wee bit of images heights.

An example of such table redesign is:

enter image description here

\documentclass[11pt]{report}
\usepackage[margin=25mm]{geometry}  % or other suitable page layout
\usepackage[export]{adjustbox}

\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,
                siunitx,
                varwidth}
\NewTableCommand\subtitle{%
\SetCell[r=2, c=8]{l, m, bg=gray!10,
                   font=\large\bfseries\itshape,
                   cmd=\rule[-1ex]{0pt}{4ex}
                   }
                            }
\usepackage{pdflscape}

\begin{document}
    \begin{landscape}
\small
    \setlist[enumerate]{nosep,
                      itemsep=0.5ex,
                      leftmargin=*}
\setkeys{Gin}{width=\linewidth, height=17mm}
\begin{longtblr}[
caption = {Table with transformation details},
  label = {appendix:tableindicators}
                ]{hline{even[3]} = {dashed},
                  hline{Z} = {solid, \heavyrulewidth},
                  colsep  = 4pt,
                  colspec = {@{}
                             X[1.3, l, m]
                             X[1.6, c, m]
                             X[2,l, m]
                             Q[c,m, mode=math, font=\Large]
                             Q[c]
                             Q[c, si={table-format=-1.3}]
                             Q[c, si={table-format= 2.3}]
                             X[2,c]
                             @{} },
                 measure = vbox,
                  rowsep = 3pt,
                  row{1} = {guard, font=\footnotesize\bfseries, c, mode=text},
                  cell{even[2]}{1-4,Z} = {r=2}{},
                   vspan = even,
                 stretch = -1,
                 rowhead = 1,
                  }
% columns headers
    \toprule
Indicator
    & Method of Calculation
        & Transformation
            & Polarity
                & Type
                    & Skewness
                        & Kurtosis
                            & Distributions \\
%  table body
    \midrule
\subtitle   Theme: Transportation
    &   &   &   &   &   &  &                \\*
    &   &   &   &   &   &  &                \\
Train Station
    &   Walking distance to nearest
        &   \begin{enumerate}
        \item   Natural Logarithm(x)
        \item   Winsorisation(6, 11)
            \end{enumerate}
            & - &   Raw Data
                    & 2.397
                        & 10.552
                            &   \includegraphics{example-image-duck}
                                            \\*
    &   &   &   &   Transformed
                        & -0.528
                            & 2.469
                                &           \\
Bus Stop
    & Walking distance to nearest
        &   \begin{enumerate}
        \item   Winsorize(0, 1000)
            \end{enumerate}
            & - &   Raw Data
                    & 3.871
                        &  37.268
                            &   \includegraphics{example-image-duck}
                                            \\
    &   &   &   &   Transformed
                        & -1.189
                            & 4.368
                                &           \\
Bus Stop with Frequent Services
    &   Walking distance to nearest
        &   \begin{enumerate}
        \item   Winsorize(0, 3500)
            \end{enumerate}
            & - &   Raw Data
                    & 2.817
                        & 15.448
                            &   \includegraphics{example-image-duck}
                                            \\
    &   &   &   &   Transformed
                        & -1.682
                            & 5.843
                                &           \\
Bikeability
    &   Total length of bikeable paths/roads, divided by area
        &   \begin{enumerate}
        \item   Box-Cox ($\lambda=-2$)
        \item   Winsorisation(-50, -25)
            \end{enumerate}
            & + &   Raw Data
                    & 1.560
                        & 7.246
                            &   \includegraphics{example-image-duck}
                                                \\
    &   &   &   &   Transformed
                        & 0.576
                            & 3.431
                                &               \\
bla bla bla
    &   Total length of bikeable paths/roads, divided by area
        &   \begin{enumerate}
        \item   Box-Cox ($\lambda=-2$)
        \item   Winsorisation(-50, -25)
            \end{enumerate}
            & + &   Raw Data
                    & 1.560
                        & 7.246
                            &   \includegraphics{example-image-duck}
                                                \\
    &   &   &   &   Transformed
                        & 0.576
                            & 3.431
                                &               \\

\subtitle   Theme: Other transportation
    &   &   &   &   &   &  &                \\
    &   &   &   &   &   &  &                \\
Uber
    &   Total length of bikeable paths/roads, divided by area
        &   \begin{enumerate}
        \item   Box-Cox ($\lambda=-2$)
        \item   Winsorisation(-50, -25)
            \end{enumerate}
            & + &   Raw Data
                    & 1.560
                        & 7.246
                            &   \includegraphics{example-image-duck}
                                                \\*
    &   &   &   &   Transformed
                        & 0.576
                            & 3.431
                                &               \\
Car Sharing
    &   Total length of bikeable paths/roads, divided by area
        &   \begin{enumerate}
        \item   Box-Cox ($\lambda=-2$)
        \item   Winsorisation(-50, -25)
            \end{enumerate}
            & + &   Raw Data
                    & 1.560
                        & 7.246
                            &   \includegraphics{example-image-duck}
                                                \\*
    &   &   &   &   Transformed
                        & 0.576
                            & 3.431
                                &               \\
Bike Sharing
    &   Total length of bikeable paths/roads, divided by area
        &   \begin{enumerate}
        \item   Box-Cox ($\lambda=-2$)
        \item   Winsorisation(-50, -25)
            \end{enumerate}
            & + &   Raw Data
                    & 1.560
                        & 7.246
                            &   \includegraphics{example-image-duck}
                                                \\*
    &   &   &   &   Transformed
                        & 0.576
                            & 3.431
                                &               \\
%        \bottomrule
\end{longtblr}
    \end{landscape}
\end{document}
4
  • That's perfect, thanks a lot! Also, I'm adding more rows and when the table goes to the next page - the table breaks. How can I break it over multiple pages so that it breaks nicely? At the moment it looks like this: paste.pics/LPSJB Feb 18 at 9:42
  • @JanMagnuszewski, see addendum to answer.
    – Zarko
    Feb 18 at 19:08
  • This is brilliant, thanks so much for your help! Feb 22 at 12:26
  • @JanMagnuszewski, you are welcome! Happy TeXing!
    – Zarko
    Feb 22 at 13:14

You must log in to answer this question.

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