我不喜欢我的桌子

我不喜欢我的桌子

我正在尝试将一个小表格添加到我的 LaTeX 中。我希望它位于页面中央。

我的问题是,我的第四列左右两侧留有很大空白,我想这是为了弥补我在表格下方注释中写下的文本。你能帮我缩小表格的尺寸,让它不那么碍眼吗?

\documentclass[12pt]{article} 

\usepackage{geometry} 
\geometry{a4paper} 
\usepackage[toc,page]{appendix} 

% Some Tables packages 
\usepackage{tabularx,dcolumn,ragged2e,caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[inline]{enumitem}

\begin{document}
\noindent
\begin{table}[h]
  \caption{Migration of Non-EU-State citizens from 2010 to 2016}
  \label{tab:one}
  \footnotesize
  \begin{tabular}{cccc}
    \toprule
    Year & Immigration & Emigration & Net Migration\\
    \midrule
    2010 & 232,007 & 138,404 & 93,603 \\
    2011 & 265,728 & 140,665 & 125,063 \\
    2012 & 305,595 & 141,490 & 164,105 \\
    2013 & 362,984 & 146,040 & 216,944 \\
    2014 & 518,802 & 181,381 & 337,421 \\
    2015 & 1,125,419 & 265,603 & 859,816 \\
    2016 & 673,217 & 324,333 & 348,884 \\   
    \midrule[0.8pt]
    \multicolumn{4}{p{\dimexpr\linewidth-2\tabcolsep\relax}}{\RaggedRight %
    See: Bundesamt f\"{u}r Migration und Fl\"{u}chtlinge. Forschungszentrum Migration, Integration und Asyl. \textit{Wanderungsmonitoring: Erwerbsmigration nach Deutschland. Bericht f\"{u}r das Jahr 2016}. Table 1.
    }
  \end{tabular}
\end{table}

\end{document}

答案1

我会这样做:

桌子

\documentclass[12pt]{article} 

\usepackage{geometry} 
\geometry{a4paper} 
\usepackage[toc,page]{appendix} 

% Some Tables packages 
\usepackage{tabularx,dcolumn,ragged2e,caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[inline]{enumitem}

\captionsetup[table]{font=footnotesize}

\begin{document}
\noindent
\begin{table}[h]
  \caption{Migration of Non-EU-State citizens from 2010 to 2016}
  \label{tab:one}
  \centering
  \footnotesize
  \begin{tabular}{cS[group-separator={,},input-ignore={,},input-decimal-markers={.},table-format=7.0]S[group-separator={,},input-ignore={,},input-decimal-markers={.},table-format=7.0]S[group-separator={,},input-ignore={,},input-decimal-markers={.},table-format=7.0]}
    \toprule
    Year & \multicolumn{1}{l}{Immigration} & \multicolumn{1}{l}{Emigration} & \multicolumn{1}{l}{Net Migration}\\
    \midrule
    2010 & 232,007 & 138,404 & 93,603 \\
    2011 & 265,728 & 140,665 & 125,063 \\
    2012 & 305,595 & 141,490 & 164,105 \\
    2013 & 362,984 & 146,040 & 216,944 \\
    2014 & 518,802 & 181,381 & 337,421 \\
    2015 & 1,125,419 & 265,603 & 859,816 \\
    2016 & 673,217 & 324,333 & 348,884 \\   
    \bottomrule
  \end{tabular}\\[.5\baselineskip]
  \parbox{.56\textwidth}{\RaggedRight See: Bundesamt f\"{u}r Migration und Fl\"{u}chtlinge. Forschungszentrum Migration, Integration und Asyl. \textit{Wanderungsmonitoring: Erwerbsmigration nach Deutschland. Bericht f\"{u}r das Jahr 2016}.}
\end{table}

\end{document}

答案2

无需额外的软件包,您可以这样做。我使用了babel,但这并不是必需的,只要您使用\raggedright注释,因为它不会引入错误的德语连字符。

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,english]{babel}
\usepackage{booktabs,siunitx, caption}

\captionsetup[table]{font=footnotesize}

\newsavebox{\tabularbox}

\begin{document}

\begin{table}[htp]
\centering
\caption{Migration of Non-EU-State citizens from 2010 to 2016}
\label{tab:one}
\footnotesize

\sisetup{table-format=7.0}

\sbox{\tabularbox}{%
  \begin{tabular}{cSSS}
  \toprule
  Year & {Immigration} & {Emigration} & {Net Migration}\\
  \midrule
  2010 &  232007 & 138404 &  93603 \\
  2011 &  265728 & 140665 & 125063 \\
  2012 &  305595 & 141490 & 164105 \\
  2013 &  362984 & 146040 & 216944 \\
  2014 &  518802 & 181381 & 337421 \\
  2015 & 1125419 & 265603 & 859816 \\
  2016 &  673217 & 324333 & 348884 \\
  \bottomrule
  \end{tabular}}
\begin{minipage}{\wd\tabularbox}
  \usebox{\tabularbox}

  \medskip

  \raggedright
  \begin{otherlanguage*}{ngerman}
  See: Bundesamt f\"{u}r Migration und Fl\"{u}chtlinge. 
  Forschungszentrum Migration, Integration und Asyl.
  \textit{Wanderungsmonitoring: Erwerbsmigration nach
  Deutschland. Bericht f\"{u}r das Jahr 2016}
  \end{otherlanguage*}
\end{minipage}

\end{table}

\end{document}

请注意,输入数字时不应使用逗号分隔千位。如果愿意,可以将它们插入到选项中sisetup(有关信息,请参阅手册siunitx)。

在此处输入图片描述

答案3

在桌子底下写笔记的一个更简单的替代方法是使用包装threeparttable。查看此问题的答案在表格下添加注释。使用它你不必手动设置音符的宽度。

\documentclass[12pt]{article}

\usepackage{booktabs,ragged2e,siunitx, caption}
\usepackage{threeparttable}

\captionsetup[table]{font=footnotesize}

\begin{document}
\noindent
\begin{table}[h]
\centering
\begin{threeparttable}
\caption{Migration of Non-EU-State citizens from 2010 to 2016}
\label{tab:one}
\footnotesize
\begin{tabular}{cSSS}
\toprule
Year & \multicolumn{1}{l}{Immigration} & \multicolumn{1}{l}{Emigration} & \multicolumn{1}{l}{Net Migration}\\
\midrule
2010 & 232,007 & 138,404 & 93,603 \\
2011 & 265,728 & 140,665 & 125,063 \\
2012 & 305,595 & 141,490 & 164,105 \\
2013 & 362,984 & 146,040 & 216,944 \\
2014 & 518,802 & 181,381 & 337,421 \\
2015 & 1125,419 & 265,603 & 859,816 \\
2016 & 673,217 & 324,333 & 348,884 \\
\bottomrule
\end{tabular}
\begin{tablenotes}[para]
{\RaggedRight
See: Bundesamt f\"{u}r Migration und Fl\"{u}chtlinge. Forschungszentrum Migration, Integration und Asyl. \textit{Wanderungsmonitoring: Erwerbsmigration nach Deutschland. Bericht f\"{u}r das Jahr 2016}
}
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

答案4

以下是使用该tabularx包的解决方案:

\documentclass[12pt]{article} 

\usepackage{geometry} 
\geometry{a4paper} 
\usepackage[toc,page]{appendix} 

% Some Tables packages 
\usepackage{tabularx,dcolumn,ragged2e,caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[inline]{enumitem}

\usepackage[font={footnotesize}]{caption}


\begin{document}
\noindent
\begin{table}[h]
  \caption{Migration of Non-EU-State citizens from 2010 to 2016}
  \label{tab:one}
  \footnotesize
  \centering
  \begin{tabularx}{0.6\textwidth}{cccc}
    \toprule
    Year & Immigration & Emigration & Net Migration\\
    \midrule
    2010 & 232,007 & 138,404 & 93,603 \\
    2011 & 265,728 & 140,665 & 125,063 \\
    2012 & 305,595 & 141,490 & 164,105 \\
    2013 & 362,984 & 146,040 & 216,944 \\
    2014 & 518,802 & 181,381 & 337,421 \\
    2015 & 1,125,419 & 265,603 & 859,816 \\
    2016 & 673,217 & 324,333 & 348,884 \\   
    \midrule[0.8pt]
    \multicolumn{4}{X}{\RaggedRight %
    See: Bundesamt f\"{u}r Migration und Fl\"{u}chtlinge. Forschungszentrum Migration, Integration und Asyl. \textit{Wanderungsmonitoring: Erwerbsmigration nach Deutschland. Bericht f\"{u}r das Jahr 2016}. Table 1.
    }
  \end{tabularx}
\end{table}

\end{document}

我还包含了caption用于全局设置所有标题的字体大小的包footnotesize

相关内容