具有多行的 Booktabs 表:垂直规则的替代?

具有多行的 Booktabs 表:垂直规则的替代?

我正在尝试格式化包含多行内容的 booktabs 表。我知道垂直规则与 booktabs 样式相悖。但是,在这个表中,我认为某种垂直参考线有助于跨多行进行解析。所以我想出了巨大的花括号。我的代码和当前表的图表如下。有没有更好(和更漂亮)的方法来帮助解析这个表 - 替代我下面所做的?

\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}

目前的输出如下: 多行书本标签表

我的想法一团糟。感谢您的指导。

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

感谢@ChrisS、@Werner 和@cfr 在下面的评论中的指导,我对表格进行了小幅重新设计,它看起来确实干净多了——即使没有垂直规则。下面的代码和最终表格供参考(这是这里有一篇文章):

\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}

现在看起来是这样的: (一点也不差。 :-)

答案1

这是呈现信息的一种相当不同的方式,可能合适也可能不合适。与修改后的表格不同,这种方式适合文本区域的范围。(另一种方式会产生过满的框。)

树形展示

这本质上是一forest棵树,也是justtrees的实验性包装器forest。这可能使其无法用于提交目的,但您可以根据需要包含代码,然后forest直接加载。某处有 的副本justtrees.sty,但如果您真的想尝试一下,请向我索要 0.04 版本。

\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}

相关内容