Latex 表长名称和长注释

Latex 表长名称和长注释

我根据建议创建了下表这里。我点击该链接是因为我想处理列中的变量名称。

我想插入一些脚注但不幸的是我得到的是这样的:

在此处输入图片描述

问题出在表格底部的长注释上。当我删除此注释时,一切都很好。如下所示:

在此处输入图片描述

所以我的问题是如何制作一个像上面所示的好的表​​格,但保留脚注的灵活长度以及能够为每一列使用长名称。

以下是 MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage{booktabs,tabularx,ragged2e,dcolumn,caption} 
\newcolumntype{C}{>{\Centering\arraybackslash \hspace{0pt}}X}
\newcolumntype{d}[1]{D{.}{,}{#1}}
% handy shortcut macros
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand\MC[1]{\multicolumn{1}{C}{#1}}

\begin{document}
\begin{table}[H]
    \footnotesize
    \caption{Pension Fund Investments and Domestic Public Debt} \label{tab:paralela}
    \begin{tabularx}{\textwidth}{@{} l *{4}{d{2.4}} @{}}
        \toprule
        & \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\ 
        & \MC{Gov. Bond Investments (\% Total)} 
        & \MC{Gov. Bond Investments (\% GDP)} 
        & \MC{Value of Pension Funds Investments (\% GDP)} 
        & \MC{Domestic Public Debt (\% Total)} \\
        \midrule

AUT & 16.57 & 0.99  & 5.83   & 23.35 \\ 
GBR & 14.38 & 14.72 & 101.66 & 69.13 \\ 
HUN & 56.40 & 1.64  & 3.01   & 44.67 \\ 
ISL & 38.58 & 63.26 & 165.56 & 80.53 \\ 
LUX & 21.85 & 0.60  & 2.73   & 57.41 \\ 
NLD & 16.38 & 24.77 & 151.04 & 45.43 \\ 
PRT & 25.70 & 1.90  & 7.49   & 38.92 \\ 
SVK & 35.65 & 2.04  & 5.77   & 55.27 \\ 
SWE & 4.18  & 3.70  & 88.63  & 70.29 \\ 
USA & 13.14 & 16.80 & 128.17 & 63.91 \\ 
\hline
 Average & 24.28 & 13.04 & 65.99 & 54.9 \\
        \bottomrule
        \addlinespace
        \multicolumn{4}{@{}l}{\tiny Source: OECD Pension Statistics. OECD Data are sample averages from 2010 onwards.} \\ 
        \multicolumn{4}{@{}l}{\tiny Note 2 .............}
    \end{tabularx}
\end{table}
\end{document}

答案1

如果您将下表改为:

    \bottomrule
    \addlinespace
    \multicolumn{5}{@{}p{\linewidth}}{\scriptsize 
    Source: OECD Pension Statistics. OECD Data are sample averages from 2010 onwards.\par
    Note 2 .............}

并减少\tabcolsep到 3pt (使用\setlength\tabcolsep{3pt}),您将获得:

在此处输入图片描述

答案2

threeparttable这是使用包的解决方案

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{threeparttable}
\usepackage{booktabs,tabularx,ragged2e,dcolumn,caption}
\usepackage{makecell} 
\newcolumntype{C}{>{\Centering\arraybackslash \hspace{0pt}}X}
\newcolumntype{d}[1]{D{.}{,}{#1}}
% handy shortcut macros
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand\MC[1]{\multicolumn{1}{C}{#1}}

\begin{document}
\begin{table}
\begin{threeparttable}[b]
\caption{Pension Fund Investments and Domestic Public Debt} \label{tab:paralela}
    \begin{tabularx}{\textwidth}{@{} l *{4}{d{2.4}} @{}}
        \toprule
        & \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\ 
        & \MC{Gov. Bond Investments (\% Total)} 
        & \MC{Gov. Bond Investments (\% GDP)} 
        & \MC{Value of Pension Funds Investments (\% GDP)} 
        & \MC{Domestic Public Debt (\% Total)} \\
        \midrule
AUT & 16.57 & 0.99  & 5.83   & 23.35 \\ 
GBR & 14.38 & 14.72 & 101.66 & 69.13 \\ 
HUN & 56.40 & 1.64  & 3.01   & 44.67 \\ 
ISL & 38.58 & 63.26 & 165.56 & 80.53 \\ 
LUX & 21.85 & 0.60  & 2.73   & 57.41 \\ 
NLD & 16.38 & 24.77 & 151.04 & 45.43 \\ 
PRT & 25.70 & 1.90  & 7.49   & 38.92 \\ 
SVK & 35.65 & 2.04  & 5.77   & 55.27 \\ 
SWE & 4.18  & 3.70  & 88.63  & 70.29 \\ 
USA & 13.14 & 16.80 & 128.17 & 63.91 \\ 
\midrule
 Average & 24.28 & 13.04 & 65.99 & 54.9 \\
\bottomrule
    \end{tabularx}
\begin{tablenotes}
\item Source: OECD Pension Statistics. OECD Data are sample averages from 2010 onwards.
\item Note 2 .............
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

在此处输入图片描述

若要删除表格注释的缩进,可以将选项添加flushleft到包中threeparttable

相关内容