2

I am trying to format a booktabs table with multirow content. I am aware that vertical rules go against the booktabs style. However, in this table, it seems to me that some kind of vertical guide would help parsing across multiple rows. So I came up with huge curly brackets. My code and a figure of the current table is below. Is there a better (and nicer) way to aid parsing in this table - an alternative to what I have done below?

\documentclass{article}
\usepackage{amsthm,amsmath,amssymb,booktabs,array, multirow, rotating}

% For the huge curly brackets
\makeatletter
\newcommand{\Vast}{\bBigg@{2.5}}
\makeatother
\makeatletter
\newcommand{\Vastt}{\bBigg@{4.3}}
\makeatother
\makeatletter
\newcommand{\Vasttt}{\bBigg@{5.4}}
\makeatother
\makeatletter
\newcommand{\Vastttt}{\bBigg@{9.6}}
\makeatother

\begin{document}

\begin{sidewaystable}[!htb]

\caption{\textbf{Title of the table}}\label{tab2}
\begin{tabular}{@{}llllll@{}}
\midrule
\multicolumn{1}{l}{\textbf{Charac1}} 
& \multicolumn{2}{c}{\textbf{Characteristics II}} 
& \multicolumn{1}{c}{\textbf{Thing1}}
& \multicolumn{1}{c}{\textbf{Thing2}} 
& \multicolumn{1}{c}{\textbf{Thing3}}\\\cmidrule(lr){2-3}

& \multicolumn{1}{c}{\textbf{Subthing1}} 
&  \multicolumn{1}{c}{\textbf{Subthing2}} & & &\\
\midrule

\multicolumn{1}{l}{XXX}
&\multicolumn{1}{c}{$\pi_{XXX}$}
&\multicolumn{1}{l}{None}
&\multicolumn{1}{c}{}

&\multicolumn{1}{l}{}
&\multicolumn{1}{>{}c}{} \\\cmidrule(lr){1-2} 

\multicolumn{1}{l}{XX}
&\multicolumn{1}{c}{$\eta_{XX}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.5em]{{\Vast\}}Something here}}
&\multicolumn{1}{c}{}
&\multicolumn{1}{>{}c}{} \\\cmidrule(lr){1-2}

\multicolumn{1}{l}{XX}
&\multicolumn{1}{c}{$\zeta_{XXX}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{}
&\multicolumn{1}{>{}l}{}\\\cmidrule(lr){1-2}


\multicolumn{1}{l}{XX}
&\multicolumn{1}{c}{$\epsilon$}
&\multicolumn{1}{l}{\multirow{-3}{*}[1.4em]{{\Vastt\}}Something}}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.7em]{{\Vast\}}Something else}}
&\multicolumn{1}{c}{}
&\multicolumn{1}{>{}l}{} \\\cmidrule(lr){1-2}

\multicolumn{1}{l}{XX}
&\multicolumn{1}{c}{$\omega_{XX}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{Something else}
&\multicolumn{1}{c}{}
&\multicolumn{1}{c}{} \\\cmidrule(lr){1-2}

\multicolumn{1}{l}{XX}
&\multicolumn{1}{c}{$\epsilon_{XXX}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{c}{}
&\multicolumn{1}{c}{}
&\multicolumn{1}{>{}l}{}\\\cmidrule(lr){1-2}

\multicolumn{1}{l}{XX}
&\multicolumn{1}{c}{$\alpha$}
&\multicolumn{1}{l}{\multirow{-3}{*}[1.1em] {{\Vastt\}}Something}}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{\multirow{-7}{*}[3em]{{\Vastttt\}} Thing1+Thing3)}}
&\multicolumn{1}{>{}c}{\multirow{-7}{*}[1.5em]{\textit{Something else}}} \\\cmidrule(lr){1-2}

\multicolumn{1}{l}{XXX}
&\multicolumn{1}{c}{$XYZ=1$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{}
&\multicolumn{1}{>{}l}{}\\\cmidrule(lr){1-2}

\multicolumn{1}{l}{XXXX}
&\multicolumn{1}{c}{$XYZ_{AB}$}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.5em]{{\Vast\}}Attribute}}
&\multicolumn{1}{l}{\multirow{-4}{*}[1.6em]{{\Vasttt\}}Something else}}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.5em]{{\Vast\}}Things (thing1 \& thing2)}}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.5em]{\textit{Something more}}}\\
\midrule
 \end{tabular}
 \\
\footnotesize{\textbf Some footnote}
\end{sidewaystable}\clearpage
\end{document}

Currently the output looks thus: Multirow booktabs table

I am running up against a blank wall on ideas. Thanks for any guidance on this.

--------EDIT with a somewhat cleaner-looking solution----------------

Thanks to guidance from @ChrisS, @Werner and @cfr in the comments below, I coded a small redesign to the table, and it definitely looks much cleaner - even without the vertical rules. Code and final table below for reference (this was for an article here):

\documentclass[11pt]{article}
\usepackage[margin=0.75in]{geometry}

\usepackage[utf8]{inputenc}
\usepackage{amsthm,amsmath,amssymb,booktabs,array, multirow,rotating}


\makeatletter
\newcommand{\Vast}{\bBigg@{2.5}}
\makeatother
\makeatletter
\newcommand{\Vastt}{\bBigg@{4.3}}
\makeatother
\makeatletter
\newcommand{\Vasttt}{\bBigg@{5.4}}
\makeatother
\makeatletter
\newcommand{\Vastttt}{\bBigg@{9.6}}
\makeatother

\thispagestyle{empty}

\begin{document}
\begin{sidewaystable}[!htb]
\renewcommand\thetable{2}
\caption{\textbf{Summary of the modeling approaches included in the evaluation}}\label{tab2}
\begin{tabular}{@{}llllll@{}}
\midrule
\multicolumn{1}{l}{\textbf{Model}} 
& \multicolumn{2}{c}{\textbf{Ensemble Characteristics}} 
& \multicolumn{1}{c}{\textbf{Output}}
& \multicolumn{1}{c}{\textbf{Paradigm}} 
& \multicolumn{1}{c}{\textbf{R Package}}\\\cmidrule(lr){2-3}

& \multicolumn{1}{c}{\textbf{Tuning parameter}} 
&  \multicolumn{1}{c}{\textbf{Model Space Construction}} & & &\\
\midrule

\multicolumn{1}{l}{ENC}
&\multicolumn{1}{c}{$\lambda_{ENC}$}
&\multicolumn{1}{l}{None}
&\multicolumn{1}{l}{Influential variables}
&\multicolumn{1}{l}{}
&\multicolumn{1}{>{}c}{} \\\cmidrule(lr){1-4} 

\multicolumn{1}{l}{PS}
&\multicolumn{1}{c}{$\lambda_{MB}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{Influential variables}
&\multicolumn{1}{c}{}
&\multicolumn{1}{>{}c}{} \\\cmidrule(lr){1-2}\cmidrule(lr){4-4}

\multicolumn{1}{l}{LS}
&\multicolumn{1}{c}{$\lambda_{ENC}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{Inclusion probabilities}
&\multicolumn{1}{l}{}
&\multicolumn{1}{>{}l}{}\\\cmidrule(lr){1-2}\cmidrule(lr){4-4}

\multicolumn{1}{l}{SS}
&\multicolumn{1}{c}{$\Lambda$}
&\multicolumn{1}{l}{\multirow{-3}{*}[1.2em]{{\Vastt\}}Subsampling}}
&\multicolumn{1}{l}{Inclusion probabilities}
&\multicolumn{1}{c}{}
&\multicolumn{1}{>{}l}{} \\\cmidrule(lr){1-4}

\multicolumn{1}{l}{PR}
&\multicolumn{1}{c}{$\lambda_{MB}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{Influential variables}
&\multicolumn{1}{c}{}
&\multicolumn{1}{c}{} \\\cmidrule(lr){1-2}\cmidrule(lr){4-4}

\multicolumn{1}{l}{LR}
&\multicolumn{1}{c}{$\lambda_{ENC}$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{Inclusion probabilities}
&\multicolumn{1}{c}{}
&\multicolumn{1}{>{}l}{}\\\cmidrule(lr){1-2}\cmidrule(lr){4-4}

\multicolumn{1}{l}{SR}
&\multicolumn{1}{c}{$\Lambda$}
&\multicolumn{1}{l}{\multirow{-3}{*}[1.2em] {{\Vastt\}}Resampling}}
&\multicolumn{1}{l}{Inclusion probabilities}
&\multicolumn{1}{l}{\multirow{-7}{*}[3em]{{\Vastttt\}} Frequentist ($l_{1}, l_{2}$ penalties)}}
&\multicolumn{1}{>{}c}{\multirow{-7}{*}[1.7em]{\textit{quadrupen, glmnet}}} \\\cmidrule(lr){1-6}

\multicolumn{1}{l}{BMA}
&\multicolumn{1}{c}{$EMS=1$}
&\multicolumn{1}{c}{}
&\multicolumn{1}{l}{Inclusion probabilities}
&\multicolumn{1}{l}{}
&\multicolumn{1}{>{}l}{}\\\cmidrule(lr){1-2}\cmidrule(lr){4-4}

\multicolumn{1}{l}{BMAC}
&\multicolumn{1}{c}{$EMS_{CV}$}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.5em]{{\Vast\}}MCMC}}
&\multicolumn{1}{l}{Inclusion probabilities}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.5em]{{\Vast\}}Bayesian (Spike \& slab prior)}}
&\multicolumn{1}{l}{\multirow{-2}{*}[0.2em]{\textit{BoomSpikeSlab}}}\\ 
\midrule
 \end{tabular}
\footnotesize{\textbf{ENC:} The baseline penalized regression model. Elastic net with $\lambda_{optimal} =\lambda_{ENC}$ derived from cross-validation (CV), \textbf{Ensembles based on 100 subsamples:} \textbf{PS:} Meinshausen \& B{\"u}hlmann's algorithm with a single $\lambda_{optimal} = \lambda_{MB}$ selected to minimize the expected number of false positives, \textbf{LS:} Single $\lambda_{optimal} = \lambda_{ENC}$ with no variable selection, \textbf{SS:} Stability selection across the entire 100 $\lambda \in \Lambda$ grid with no variable selection, \textbf{Ensembles based on 100 resamples: }\textbf{PR, LR, SR:} Identical to PS, PR and LR, respectively, with model space constructed through resampling. \textbf{BMA:} Bayesian model averaging with expected model size ($EMS$) = 1, \textbf{BMAC:} BMA with EMS determined by CV ($EMS_{CV}$).}
\end{sidewaystable}\clearpage
\end{document}

This is how it looks now: (Not bad at all. :-)

14
  • 1
    Since there is no strict hierarchy, I think your current way is clearest, but you could also just repeat the items on each row.
    – ChrisS
    Feb 7, 2015 at 2:47
  • The grouping across columns doesn't seem hierarchical. Does Things (thing1 & thing2) brace the same scope as Attribute?
    – Werner
    Feb 7, 2015 at 2:52
  • 1
    @Ariel: Thing3 seems superfluous...
    – Werner
    Feb 7, 2015 at 3:08
  • 1
    @cfr What do you think? First thing i thought looking at the material was TikZ. You have a lot of tikzperience, maybe you can provide an alternative solution?
    – Johannes_B
    Oct 4, 2015 at 14:21
  • 1
    @Johannes_B I'm not sure. Without really understanding the job the presentation needs to do, it is difficult to suggest coherent ways of restructuring it. The modified version added in the edit is reasonably clear, although I'd omit most of the horizontal lines, I think. I don't know how important the column headings are. If that information can be conveyed implicitly (i.e. will be obvious to the readers anyway), a tree or schema might work better. But if the information is essential, maybe a table is the best option. It would help if the subsampling/resampling/etc. could be outside the table.
    – cfr
    Oct 4, 2015 at 15:57

1 Answer 1

5

Here is a rather different way of presenting the information which may or may not be suitable. Unlike the modified table, this fits within the confines of the text area. (The other produces overfull boxes.)

tree presentation

This is essentially a forest tree, as justtrees is an experimental wrapper for forest. This may make it unacceptable for submission purposes, but you can include the code, if necessary, and load forest directly instead. There is a copy of justtrees.sty around somewhere but ask me for version 0.04 if you actually want to try this out.

\documentclass[11pt]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{rotating,lmodern,justtrees}% version 0.04 of justtrees
\usetikzlibrary{calc,decorations.pathreplacing}

\begin{document}
\thispagestyle{empty}
\begin{sidewaysfigure}
  \caption{\textbf{Summary of the modeling approaches included in the evaluation}}\label{fig2}% it would be better to use \captionsetup to format captions globally
  \begin{center}
    \begin{justtree}{
        right justifiers,
        for tree={
          edge path={
            \noexpand\path [\forestoption{edge}] (!u.parent anchor) -- +(0,-10pt) -| (.child anchor)\forestoption{edge label};
          },
          just format={font=\bfseries},
          l sep+=5pt,
          s sep+=5pt,
          if n children=3{
            calign child=2,
            calign=child
          }{},
          if level=3{font=\itshape}{},
          if level=5{math content}{},
        },
      }
      [Modelling Approaches,
        [{Frequentist ($l_{1}, l_{2}$ penalties)}, just=Paradigm
          [{quadrupen, glmnet}, just=R Package
            [None, just=Model Space Construction
              [\lambda_{ENC}
                [ENC,
                tikz={
                  \draw (.south) |- ($(.south)!1/2!(iv2.south) - (10pt,35pt)$) coordinate (a) -- ++(0,-15pt) coordinate (b) ++(10pt,0) node (iv) [anchor=north] {Influential variables};
                  \draw (!>.south) |- ([xshift=10pt, yshift=10pt]a) -- ([xshift=10pt]b);
                  \draw (iv2.south) |- ([xshift=20pt]a) -- ([xshift=20pt]b);
                  \node [anchor=mid west, justifier format] at (right just 2.mid west |- iv.mid) {Output};
                }
                ]
              ]
            ]
            [Subsampling
              [\lambda_{MB}
                [PS
                ]
              ]
              [\lambda_{ENC}
                [LS,
                tikz={
                  \draw (.south) |- ($(.south)!1/2!(ip2.south) - (25pt,25pt)$) coordinate (c) -- ++(0,-25pt) coordinate (d) ++(25pt,0) node (ip) [anchor=north] {Inclusion probabilities};
                  \draw (!>.south) |- ([xshift=10pt, yshift=10pt]c) -- ([xshift=10pt]d);
                  \draw (!>>>.south) |- ([xshift=20pt, yshift=20pt]c) -- ([xshift=20pt]d);
                  \draw (!>>>>.south) |- ([xshift=30pt, yshift=10pt]c) -- ([xshift=30pt]d);
                  \draw (!>>>>>.south) |- ([xshift=40pt]c) -- ([xshift=40pt]d);
                  \draw (ip2.south) |- ([xshift=50pt,yshift=-10pt]c) -- ([xshift=50pt]d);
                }
                ]
              ]
              [\Lambda
                [SS
                ]
              ]
            ]
            [Resampling
              [\lambda_{MB}
                [PR, name=iv2
                ]
              ]
              [\lambda_{ENC}
                [LR
                ]
              ]
              [\Lambda
                [SR
                ]
              ]
            ]
          ]
        ]
        [Bayesian (Spike \& slab prior)
          [BoomSpikeSlab
            [MCMC
              [{EMS=1}
                [BMA, just=Model
                ]
              ]
              [EMS_{CV}, just=Tuning parameter
                [BMAC, name=ip2,
                tikz={
                  \draw [decorate, decoration={brace, amplitude=5pt}, thick]  (right just 4.north east) +(5pt,0) coordinate (e) -- (e |- right just 5.south) node [midway, right, xshift=5pt, justifier format, align=left] {Ensemble\\Characteristics};
                }
                ]
              ]
            ]
          ]
        ]
      ]
    \end{justtree}
  \end{center}
  \footnotesize% note that this is a switch - it does not take an argument
  \textbf{ENC:} The baseline penalized regression model. Elastic net with $\lambda_{optimal} =\lambda_{ENC}$ derived from cross-validation (CV), \textbf{Ensembles based on 100 subsamples:} \textbf{PS:} Meinshausen \& B{\"u}hlmann's algorithm with a single $\lambda_{optimal} = \lambda_{MB}$ selected to minimize the expected number of false positives, \textbf{LS:} Single $\lambda_{optimal} = \lambda_{ENC}$ with no variable selection, \textbf{SS:} Stability selection across the entire 100 $\lambda \in \Lambda$ grid with no variable selection, \textbf{Ensembles based on 100 resamples: }\textbf{PR, LR, SR:} Identical to PS, PR and LR, respectively, with model space constructed through resampling. \textbf{BMA:} Bayesian model averaging with expected model size ($EMS$) = 1, \textbf{BMAC:} BMA with EMS determined by CV ($EMS_{CV}$).
\end{sidewaysfigure}

\end{document}
4
  • this looks very good.
    – Johannes_B
    Oct 5, 2015 at 11:25
  • @Johannes_B Thanks. I gave up once but then decided to have another go. It can out better than I feared :).
    – cfr
    Oct 5, 2015 at 17:31
  • Wow - this is beautiful. Thank you @Johannes_B for reviving this question and to cfr for posting such an inspired answer. I wish I could go back in time and resubmit this figure to the journal (okay, not really, I am glad the paper's done, but this figure is a nice alternative way to present the same information with no redundancy. Will keep this mind for the future. Thanks again!
    – Ariel
    Oct 29, 2015 at 2:34
  • 1
    @Ariel Probably just as well. My code is rather experimental - I'm not sure that would go down well with a journal! (But I'm trying to improve it by finding interesting questions to try it out on, and this came out better than I expected.) Glad you like it - may come in useful another time....
    – cfr
    Oct 29, 2015 at 2:56

You must log in to answer this question.

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