如何在 \multirow 中正确使用表格?

如何在 \multirow 中正确使用表格?

为了

\multirow{3}*{\minitab[c]{India \\ Canada}}

我在下面的代码中收到各种错误消息;而两者

\multirow{3}*{India Canada}

\multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\

只是工作。

我看不出哪里出了问题,请帮忙。谢谢!

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{eurosym}
\usepackage{multirow}
\newcommand{\minitab}[2][c]{\begin{tabular}{#1}#2\end{tabular}}

\renewcommand{\arraystretch}{1.2}
%\sisetup{round-mode=places,round-precision=1, add-decimal-zero=true, add-integer-zero=true, round-integer-to-decimal}

\begin{document}

\begin{table}




\begin{tabular}{|c|c|}
\hline
\multirow{4}{1in}{Common g text} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline

\multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabular}

\noindent
\begin{tabulary}{\textwidth}{|C|C|}
\hline
\multirow{4}{1in}{Common g text} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline

\multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabulary}

\end{table}

bla

\begin{table}
\centering
\begin{threeparttable}
\caption{Cricket results 2013}
\sisetup{round-mode=off, add-decimal-zero=false, add-integer-zero=false}

\begin{tabulary}{\textwidth}{@{}*{1}{L}*{2}{S[table-format=5.0]}*{1}{S[table-format=2.0]}@{}} \toprule

& \multicolumn{2}{c}{Ticket price (\euro)}  &\multicolumn{1}{c}{Chance to win (\%)}\\

\cmidrule(lr){2-3}

& {from}    &{until}    & \\
\midrule
\multirow{3}*{\minitab[c]{India \\ Canada}}
& {0} & 25000   &22\\
& 25001 & 42000 &32 \\
& 42001 & {$\infty$}    &42 \\
&&& \\
\multirow{3}*{Tasmania}
& {0} & 50000   &26\\
& 50001 & {$\infty$}    &33 \\
\bottomrule
\end{tabulary}

\begin{tablenotes}
\item [1] Average.

\end{tablenotes}

\end{threeparttable}
\end{table}

\end{document}

答案1

不知道为什么,但是 mutirow 似乎不喜欢 tabularary 的试运行,所以您可以在试用期间省略其内容。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{eurosym}
\usepackage{multirow}
\newcommand{\minitab}[2][c]{\begin{tabular}{#1}#2\end{tabular}}

\renewcommand{\arraystretch}{1.2}
%\sisetup{round-mode=places,round-precision=1, add-decimal-zero=true, add-integer-zero=true, round-integer-to-decimal}

\begin{document}

\begin{table}




\begin{tabular}{|c|c|}
\hline
\multirow{4}{1in}{Common g text} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline

\multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabular}

\noindent
\begin{tabulary}{\textwidth}{|C|C|}
\hline
\multirow{4}{1in}{Common g text} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline

\multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\
      & Column g2b \\
      & Column g2c \\
      & Column g2d \\
\hline
\end{tabulary}

\end{table}

bla

\begin{table}
\centering
\begin{threeparttable}
\caption{Cricket results 2013}
\sisetup{round-mode=off, add-decimal-zero=false, add-integer-zero=false}

\begin{tabulary}{\textwidth}{@{}*{1}{L}*{2}{S[table-format=5.0]}*{1}{S[table-format=2.0]}@{}} \toprule

& \multicolumn{2}{c}{Ticket price (\euro)}  &\multicolumn{1}{c}{Chance to win (\%)}\\

\cmidrule(lr){2-3}

& {from}    &{until}    & \\
\midrule
\multirow{3}*{\ifx\[$\else\minitab[c]{India\\Canada}\fi}
& {0} & 25000   &22\\
& 25001 & 42000 &32 \\
& 42001 & {$\infty$}    &42 \\
&&& \\
\multirow{3}*{Tasmania}
& {0} & 50000   &26\\
& 50001 & {$\infty$}    &33 \\
\bottomrule
\end{tabulary}

\begin{tablenotes}
\item [1] Average.

\end{tablenotes}

\end{threeparttable}
\end{table}

\end{document}

实际上,它似乎是与 threeparttable 的交互,它最终会尝试在多行内的内部表格末尾排版 threepart 表格标题。因此,允许 tabulary 查看和测量内部表格的更好的解决方法是保存 tabular 的原始定义并将其重置为嵌套表格:

将其放入序言中:

\let\xxx\tabular
\let\endxxx\endtabular

然后

\multirow{3}*{%
\let\tabular\xxx
\let\endtabular\endxxx
\minitab[c]{India\\Canada}
}

相关内容