threeparttable / siunitx - 获取等宽的列

threeparttable / siunitx - 获取等宽的列

我想要一个有 6 列的表格,其中最后 5 列宽度相等。正如这里多位用户所建议的,我正在尝试让 threeparttable 和 siunitx 一起工作。从输出来看,我认为我没有正确理解如何实现这一点。如果您能在这方面帮助我,我将非常高兴。

如果您需要更多详细信息,请告诉我。非常感谢您的帮助和时间!

\documentclass[review,authoryear,11pt]{elsarticle}
\usepackage{threeparttable}
\usepackage{siunitx}
\begin{document}

    \begin{small}
    \begin{singlespace}
    \begin{center}
    \vspace*{\fill}
    \rotatebox{90}{

    \begin{threeparttable}

    \caption{\label{tab:tab_worldbank} tbd}

    \begin{tabular}{l*{5}{S}}

        \toprule
        \multicolumn{1}{c}{\textbf{Country}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[x]{@{}c@{}}Strength of\\Insolvency (0-16)\end{tabular}}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[x]{@{}c@{}}Resolving\\Insolvency (rank)\end{tabular}}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[x]{@{}c@{}}Recovery\\Rate s(\%)\end{tabular}}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[x]{@{}c@{}}Recovery\\Time (years)\end{tabular}}} & \multicolumn{1}{c}{\textbf{\begin{tabular}[x]{@{}c@{}}Insolvency\\Cost (\%)\end{tabular}}} \\
        \midrule
        Austria & 11.0  & 20    & 82.8\% & 1.1   & 10.0\% \\
        Belgium & 11.5  & 10    & 89.9\% & 0.9   & 3.5\% \\
        Denmark & 12.0  & 8     & 88.0\% & 1.0   & 4.0\% \\
        Finland & 14.5  & 1     & 90.3\% & 0.9   & 3.5\% \\
        France & 11.0  & 24    & 78.5\% & 1.9   & 9.0\% \\
        Germany & 15.0  & 3     & 84.4\% & 1.2   & 8.0\% \\
        Greece & 12.0  & 52    & 35.6\% & 3.5   & 9.0\% \\
        Ireland & 10.5  & 17    & 87.7\% & 0.4   & 9.0\% \\
        Italy & 13.5  & 25    & 63.9\% & 1.8   & 22.0\% \\
        Luxembourg & 7.0   & 82    & 43.7\% & 2.0   & 14.5\% \\
        Netherlands & 11.5  & 11    & 89.3\% & 1.1   & 3.5\% \\
        Portugal & 14.5  & 7     & 74.2\% & 2.0   & 9.0\% \\
        Spain & 12.0  & 18    & 78.3\% & 1.5   & 11.0\% \\
        Sweden & 12.0  & 19    & 77.9\% & 2.0   & 9.0\% \\
        United Kingdom & 11.0  & 13    & 88.6\% & 1.0   & 6.0\% \\
        \textbf{EU15 average} & \textbf{11.9} & \textbf{21} & \textbf{76.9\%} & \textbf{1.5} & \textbf{8.7\%} \\
              &       &       &       &       &  \\
        Brazil & 13.0  & 67    & 15.8\% & 4.0   & 12.0\% \\
        China & 11.5  & 53    & 36.9\% & 1.7   & 22.0\% \\
        India & 6.0   & 136   & 26.0\% & 4.3   & 9.0\% \\
        Russia & 11.5  & 51    & 38.6\% & 2.0   & 9.0\% \\
        \textbf{BRIC average} & \textbf{10.5} & \textbf{77} & \textbf{29.3\%} & \textbf{3.0} & \textbf{13.0\%} \\
              &       &       &       &       &  \\
        United States of America & 15.0  & 5     & 78.6\% & 1.5   & 10.0\% \\
        \bottomrule
        \end{tabular}%



    \begin{tablenotes}[flushleft]\labelsep.0em
    \item tbd
    \end{tablenotes}

    \end{threeparttable}

    }
    \vspace*{\fill}
    \end{center}
    \end{singlespace}
    \end{small}
\end{document}

在此处输入图片描述

答案1

编辑 唉,我忘记了半张表,里面有粗体数字……现在加了

像这样?

在此处输入图片描述

\documentclass[authoryear,11pt]{elsarticle}
\usepackage{booktabs, makecell, threeparttable}
\renewcommand\theadfont{\normalsize\bfseries}
\newcommand\mcc[1]{\multicolumn{1}{c}{\thead[b]{#1}}}
\usepackage{siunitx} 

\usepackage{etoolbox} % added

\begin{document}

    \begin{center}
\renewcommand{\bfseries}{\fontseries{b}\selectfont} % <--
\newrobustcmd{\B}{\bfseries}                        % <-- schortcut
    \rotatebox{90}{
    \sisetup{table-column-width=13ex,
             detect-weight}
    \begin{threeparttable}
    \caption{Table caption}
    \label{tab:tab_worldbank}
    \begin{tabular}{l S[table-format=2.1]
                      S[table-format=2.0]
                      S[table-format=2.1,table-space-text-post={\,\%}]<{\,\%}
                      S[table-format=1.1]
                      S[table-format=2.1,table-space-text-post={\,\%}]<{\,\%}
                         }
        \toprule
\thead[b]{Country}
    &   {\thead[b]{Strength of\\ Insolvency\\ (0-16)}}
        &   {\thead[b]{Resolving\\ Insolvency\\ (rank)}}
            &   \mcc{Recovery\\ Rate\\ s(\%)}
                &   {\thead[b]{Recovery\\ Time\\ (years)}}
                    &   \mcc{Insolvency\\ Cost\\ (\%)}      \\
        \midrule
Austria         & 11.0  & 20    & 82.8  & 1.1   & 10.0  \cr
Belgium         & 11.5  & 10    & 89.9  & 0.9   &  3.5  \cr
Denmark         & 12.0  & 8     & 88.0  & 1.0   &  4.0  \cr
Finland         & 14.5  & 1     & 90.3  & 0.9   &  3.5  \cr
France          & 11.0  & 24    & 78.5  & 1.9   &  9.0  \cr
Germany         & 15.0  & 3     & 84.4  & 1.2   &  8.0  \cr
Greece          & 12.0  & 52    & 35.6  & 3.5   &  9.0  \cr
Ireland         & 10.5  & 17    & 87.7  & 0.4   &  9.0  \cr
Italy           & 13.5  & 25    & 63.9  & 1.8   & 22.0  \cr
Luxembourg      & 7.0   & 82    & 43.7  & 2.0   & 14.5  \cr
Netherlands     & 11.5  & 11    & 89.3  & 1.1   &  3.5  \cr
Portugal        & 14.5  & 7     & 74.2  & 2.0   &  9.0  \cr
Spain           & 12.0  & 18    & 78.3  & 1.5   & 11.0\ \cr
Sweden          & 12.0  & 19    & 77.9  & 2.0   &  9.0  \cr
United Kingdom  & 11.0  & 13    & 88.6  & 1.0   &  6.0  \cr
\textbf{EU15 average}
&   \B 11.9
    &   \B 21
        &   \B 76.9
            &   \B 1.5
                &      \B 8.7                           \cr
\addlinespace
Brazil          & 13.0  & 67    & 15.8  & 4.0   & 12.0  \cr
China           & 11.5  & 53    & 36.9  & 1.7   & 22.0  \cr
India           & 6.0   & 136   & 26.0  & 4.3   &  9.0  \cr
Russia          & 11.5  & 51    & 38.6  & 2.0   &  9.0  \cr
\textbf{BRIC average}
&   \B 10.5
    &   \B 77
        &   \B 29.3
            &   \B 3.0
                &   \B 13.0                             \cr
\addlinespace
United States of America
                & 15.0  & 5     & 78.6  & 1.5   & 10.0  \cr

    \end{tabular}
    \end{threeparttable}
    }

笔记:你的姆韦由于其序言中缺少包而无法工作。因此我review\documentclass选项中删除了表格可以放在一页上的选项。

也许解决方案的使用sidewaystable对你来说很有趣。对于它,只有上面的以下更改姆韦必须要做的事情:

...
\usepackage{rotating} % <-- add

\begin{document}

    \begin{sidewaystable} % <---
    \centering
\renewcommand{\bfseries}{\fontseries{b}\selectfont} % <--
\newrobustcmd{\B}{\bfseries}                        % <-- schortcut
\sisetup{table-column-width=13ex,
         detect-weight}
    \begin{threeparttable}

 % ... table content

    \end{tabular}
    \end{threeparttable}
    \end{sidewaystable}   % <---
\end{document}

相关内容