2

I am currently writing a report and have some problems with an extra wide table. I Would like to have it centered on the page, however it always algins left due to the overfull \hbox. I have made progress in making the table thinner, but not enough.

I have also seen the answers in How can I center a too wide table? and How do I center this wide table in LaTeX?, however I have not been capable to implement the solution proposed. Maybe there is some incomaptibility with some packages I use.

I have tried to put below a MWE of my problem, I have however inserted all the packages I use in case anybody sees where the incompatibility is.

\documentclass[a4paper,12pt]{report} %EINSEITIG
\usepackage[a4paper , lmargin = {3cm} , rmargin = {3cm} , tmargin = {2.5cm} , bmargin = {2.5cm}, headheight=14.5pt]{geometry} %für PC Ansicht


\usepackage[ngerman, english]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{amsfonts} 
\usepackage{textcomp,gensymb} 
\usepackage{upgreek}
\usepackage{amsmath}
\usepackage{cite}
\usepackage[gen]{eurosym} 
\usepackage{wrapfig}
\usepackage{pdfpages}
\usepackage{nicefrac}
\usepackage[onehalfspacing]{setspace}

\usepackage[font=small,format=hang]{caption} 

\pagestyle{fancy}
\usepackage{booktabs} 
\usepackage{tabularx} 
\usepackage{subcaption} 
\usepackage{colortbl} 
\usepackage{rotating} 
\usepackage{multirow}
\usepackage{pifont} 
\usepackage{selectp} 
\usepackage[inline]{enumitem}
\usepackage[version=4]{mhchem} 


% SI-Unit
\usepackage[per-mode=symbol,exponent-product=\cdot]{siunitx}


% HyperRef Formatting
\usepackage[pdftex, colorlinks, linkcolor=black, frenchlinks, unicode]{hyperref} 
\hypersetup{citecolor=black}
\hypersetup{urlcolor=blue}


\usepackage{uarial}
\renewcommand{\familydefault}{\sfdefault}



\definecolor{light-gray}{gray}{0.75} %Definition der neuen Farbe Grau


    \usepackage{titlesec}
\titleformat{\chapter}{\bfseries\Huge}{\thechapter.\quad}{0em}{} 
\AtBeginDocument{\renewcommand{\chaptername}{}}



\setcounter{secnumdepth}{4}

\begin{document}
\chapter{Test}

%%PDF-Einstellungen

\fancyhead[L]{Version 1.4 - \today}
\fancyfoot[L]{}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{}

\pagenumbering{roman} %Römische Ziffern

%%

%
A tabular listing with DIN standards and corresponding ASTM standards for the aforementioned testing methods is given in \autoref{Tab:test}.


\begin{table}[htbp]
\centering
\caption{DIN and ASTM Test Method Standards Comparison}
\begin{tabular}{llcc}
\toprule 
Field & Test & DIN-Standard & ASTM-Standard \\
\toprule
\multirow{3}{*}{Concrete} & Compressive strength (UCS) & EN~12390-3 & C39/C39M Bananenequark \\ 
& Young's modulus & EN 12390-13 &  C469/C469M \\
& Triaxial Tests & - & C801* \\
\bottomrule
\multicolumn{4}{l}{\begin{scriptsize}  * = standard withdrawn \end{scriptsize}} \\
\end{tabular}
\label{Tab:test}
\end{table}

\end{document}

I have tried many options but still have no look and the table is aligned to the left of the text.

Can somebody provide me with a solution how I can center the table on the page and not align it left in the text?

Many thanks in advance for your help!

  • 1
    Both the options given in the accepted answer to tex.stackexchange.com/q/39435 work for your table, that is either \makebox[\textwidth][c]{\begin{tabular}{llcc} ... \end{tabular}} or \begin{adjustbox}{center} \begin{tabular}{llcc} ... \end{tabular} \end{adjustbox}. – Torbjørn T. May 8 '18 at 16:48
  • Just out of idle curiosity: What's a "Bananenequark"? :-) – Mico May 8 '18 at 20:13
  • 1
    @Mico: Banenquark ist just a word I invented, because I have citations within the table, which I have taken out in the MWE. A Bananenquark is a banana curd actually ;) – magicdivadd Jun 10 '18 at 13:29
  • @TorbjørnT. Great! That actually worked for me... Don´t know why i didn#manage that beforee! Many thanks! :) – magicdivadd Jun 10 '18 at 13:32
3

your table can be fit in text width with use of the tabular* table environment and left adjust \colsep to it. using \small font size make table even nicer:

\documentclass[a4paper,12pt]{report} %EINSEITIG
\usepackage[hmargin = {3cm},
            vmargin = {2.5cm} ,
            headheight=14.5pt]{geometry} %für PC Ansicht
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{uarial}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[onehalfspacing]{setspace}

\usepackage[font=small,format=hang]{caption}

\usepackage{ragged2e}
\usepackage{booktabs, multirow}
\usepackage[colorlinks, frenchlinks, unicode]{hyperref}
\hypersetup{linkcolor=black, citecolor=black, urlcolor=blue}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
A tabular listing with DIN standards and corresponding ASTM standards for the aforementioned testing methods is given in \autoref{Tab:test}.

    \begin{table}[htbp]
\caption{Comparison of DIN and ASTM Test Method Standards}
\label{Tab:test}
    \setlength\tabcolsep{0pt}
    \small% works also with normal font size
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}llll}
    \toprule
Field & Test & DIN Standard & ASTM Standard \\
    \midrule
\multirow{3}{*}{Concrete} & Compressive strength (UCS)
& EN~12390-3 & C39/C39M Bananen\-equark \\
& Young's modulus & EN 12390-13 & C469/C469M \\
& Triaxial Tests  & --           & C801* \\
    \bottomrule
    \addlinespace
\multicolumn{4}{@{}l}{\scriptsize * = standard withdrawn}\\
\end{tabular*}
    \end{table}
\end{document}

enter image description here

  • Impressive solution, and actually pretty much ideal. It's pretty tight with the spacing in my table with normal font, but a great solution. Will definitely be handy for other tables! – magicdivadd Jun 10 '18 at 13:43
5

Since you're already loading the tabularx package, you might consider employing a tabularx environment instead of a tabular environment. I suggest using a (modified) X column type for the final column and allowing line breaks in that column.

enter image description here

\documentclass[a4paper,12pt]{report} %EINSEITIG
\usepackage[hmargin = {3cm}, vmargin = {2.5cm} ,
    headheight=14.5pt]{geometry} %für PC Ansicht

\usepackage[ngerman, english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{amsmath, amssymb}
\usepackage{textcomp,gensymb}
\usepackage[table]{xcolor}
%\definecolor{light-gray}{gray}{0.75} % neue Farbe Grau

\usepackage{upgreek}
\usepackage{cite}
\usepackage[gen]{eurosym}
\usepackage{wrapfig}
\usepackage{pdfpages}
\usepackage{nicefrac}
\usepackage[onehalfspacing]{setspace}

\usepackage[font=small,format=hang]{caption}

\usepackage{booktabs}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\usepackage{subcaption}

\usepackage{rotating}
\usepackage{multirow}
\usepackage{pifont}
\usepackage{selectp}
\usepackage[inline]{enumitem}
\usepackage[version=4]{mhchem}

% SI-Unit
\usepackage[per-mode=symbol,exponent-product=\cdot]{siunitx}

\usepackage{uarial}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{titlesec}
\titleformat{\chapter}{\bfseries\Huge}{\thechapter.\quad}{0em}{}
\AtBeginDocument{\renewcommand{\chaptername}{}}

% HyperRef Formatting (load 'hyperref' package LAST)
\usepackage[colorlinks, frenchlinks, unicode]{hyperref}
\hypersetup{linkcolor=black, citecolor=black, urlcolor=blue}

\setcounter{secnumdepth}{4}
\pagenumbering{roman} % Römische Ziffern

%%PDF-Einstellungen
\fancyhead[L]{Version 1.4 -- \today}
\fancyfoot[L]{}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{}


\begin{document}
\chapter{Test}

A tabular listing with DIN standards and corresponding ASTM standards for the aforementioned testing methods is given in \autoref{Tab:test}.

\begin{table}[htbp]
\caption{Comparison of DIN and ASTM Test Method Standards}
\label{Tab:test}

\begin{tabularx}{\textwidth}{@{}lllL@{}}
\toprule
Field & Test & DIN Standard & ASTM Standard \\
\midrule
\multirow{4}{*}{Concrete} & Compressive strength (UCS) 
& EN~12390-3 & C39/C39M Bananen\-equark \\
& Young's modulus & EN 12390-13 & C469/C469M \\
& Triaxial Tests  & --           & C801* \\
\bottomrule \addlinespace
\multicolumn{4}{@{}l}{\scriptsize * = standard withdrawn}\\
\end{tabularx}
\end{table}

\end{document} 
  • Thanks for your solution. As mentioned above "Bananequark" is actually a placeholder for \cite{..} that's why your solution doesn't work for my purpouse (I can't split my literature style abbrv in two lines). But it might be useful to seombedoy else ;) – magicdivadd Jun 10 '18 at 13:36
4

I know that this will trigger some comments but you could just use \centerline and wrap it around your table. This does what you seem to be looking for. Whether or not this is good style is a different question.

\centerline{\begin{tabular}{llcc}
\toprule 
Field & Test & DIN-Standard & ASTM-Standard \\
\toprule
\multirow{3}{*}{Concrete} & Compressive strength (UCS) & EN~12390-3 & C39/C39M Bananenequark \\ 
& Young's modulus & EN 12390-13 &  C469/C469M \\
& Triaxial Tests & - & C801* \\
\bottomrule
\multicolumn{4}{l}{\begin{scriptsize}  * = standard withdrawn \end{scriptsize}} \\
\end{tabular}}
  • So you're not disappointed by lack of comments: You seem to have some feeling that \centerline is not good style, so why post an answer with it, when other options are available (and linked to in the question)? (tex.stackexchange.com/a/163576 by the way.) – Torbjørn T. May 8 '18 at 17:20
  • @TorbjørnT. Sorry, I simply do not share the sentiments of your link. Did you read what is written there? It says one should use \centering, which however does not achieve what the OP wants. What I meant by style is having tables overshoot, not the use of \centerline. So far I have been left completely in the dark why \centerline is not to be used. – user121799 May 8 '18 at 17:27
  • I know what is written there, and I know it doesn't answer the "why". If you look in the comments though, you'll see mentioned \makebox[\textwidth]{<tabular>} just as in tex.stackexchange.com/q/39435 which is mentioned in the question. The purpose of the link was mainly to point to someone with a bit more authority than me, saying that \centerline should not be used in LaTeX. (I don't know the technical reason for it, so cannot help with that.) – Torbjørn T. May 8 '18 at 17:34
  • @TorbjørnT. So we are stuck at this point, right? We can either assume that this authority is always absolutely right, which may be a good assumption, or question why he did not bother to reply to the comments asking this. I personally agree 99% with that authority, but I also do have a few disagreements, It might well be that \makebox is better, I do not know enough to judge this. In any case, your comment is well-taken, and will provide additional information to those who read these lines. – user121799 May 8 '18 at 17:41
  • Some more technical info here (and now I'll stop making noise): tex.stackexchange.com/questions/311293/… – Torbjørn T. May 8 '18 at 19:04

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.