3

I'm trying to include a small table into my LaTeX. I would like it to be centered on the page.

My problem is that my fourth column has huge spaces to the right and to the left, I assume to compensate for the text I have written in the note underneath the table. Could you please help me shrink the size of my table, so it's not so obnoxious?

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

That's how I would do it:

table

\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}
  • I like this. Except, I would prefer, perhaps, to have the "Table 1: blah blah" at the same size as the table text. To do this, could I simply move up "\footnotesize" to before the "\caption"? – Zatchet09 Sep 21 '17 at 9:16
  • @Zatchet09 I've improved the whole thing a bit. – TeXnician Sep 21 '17 at 9:22
5

Without extra packages, you can do it like this. I used babel, but it's not really required, provided you use \raggedright for the note, as it won't introduce wrong hyphenation for German.

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

Note that numbers should not be input with the comma for separating thousands. They can be inserted, if preferred, in options to sisetup (see the manual of siunitx for information).

enter image description here

4

An easier alternative to write notes under the table is to use the threeparttable package. See the answer to this question Add notes under the table. Using it you don't have to manually set the width of the notes.

\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}
  • This is more of a commentary than anything else. You should elaborate on the answer (making it complete with some code) or convert it into a comment. – TeXnician Sep 21 '17 at 9:33
  • Ok. I've added the code to my answer. – joão gândara Sep 21 '17 at 9:39
  • \centering should go before \begin{threeparttable}; remove the flushleft option and use \begin{tablenotes}[para], without \item. Probably \raggedright is better as the text is in German and the hyphenation allowed by \RaggedRight can be wrong for the language. – egreg Sep 21 '17 at 9:59
  • Thanks for the suggestions. However if I change \RaggedRight to \raggedright the text will be justified. – joão gândara Sep 21 '17 at 15:23
2

Here is a solution using the tabularx package:

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

I have as well included the caption package to globally set the font size of all captions to footnotesize.

  • 1
    The caption package was already included. And you should definitely not use tabularx if you do not have a X column. – TeXnician Sep 21 '17 at 9:22
  • 1
    @ TeXnician: In this case I used the X column for the multicolumn at the bottom of the table. For me this has worked well every time I used this. – leandriis Sep 21 '17 at 9:26
  • Well, at least it is not the intended and recommended use. – TeXnician Sep 21 '17 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.