1

enter image description here

enter image description here

I have table A.3 that I want to convert into a layout more like table A.4 so that it fits the text width. I know this is best attained by using tabular. I actually had a solution similar to A.4 before shifting to tabulary but it was too wide at the time. In advance, many thanks for your suggestions on fitting the table to the textwidth with tabular (maybe there is a better solution with tabulary, although I doubt it).

documentclass[12pt]{report}
    \usepackage{multirow}
    \usepackage{bigstrut}
\usepackage{booktabs}
\usepackage{tabulary}
\makeatletter
\def\hlinewd#1{%
  \noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
   \reserved@a\@xhline}
\makeatother

    \begin{document}

      \begin{tabulary}{\textwidth}{L|RRR|RRRR}
    \hline
          & \multicolumn{3}{c|}{\textbf{Associations}} & \multicolumn{4}{c}{\textbf{Gymnasts}} \bigstrut\\
    \hline
    \multicolumn{1}{l|}{Nation} & Total & km2 per association & Inhabitants per association & Total & per 100 km2 & Inhabitants per gymnast & per association \bigstrut\\
    \hline
    \multicolumn{1}{l}{Germany} & 6'915 & 94    & \multicolumn{1}{r}{8'297} & 692'765 & 105   & 83    & 100 \bigstrut[t]\\
    \multicolumn{1}{l}{France} & 700   & 766   & \multicolumn{1}{r}{55'030} & 100'000 & 18    & 385   & 143 \\
    \multicolumn{1}{l}{Czech countries} & 573   & 138   & \multicolumn{1}{r}{15'227} & 47'500 & 61    & 1'884 & 83 \\
    \multicolumn{1}{l}{Switzerland} & 590   & 70    & \multicolumn{1}{r}{5'617} & 43'475 & 104   & 71    & 73 \\
    \multicolumn{1}{l}{Belgium} & 169   & 174   & \multicolumn{1}{r}{38'970} & 14'704 & 50    & 448   & 87 \\
    \multicolumn{1}{l}{Italy} & 106   & 2'704 & \multicolumn{1}{r}{297'000} & 13'175 & 5     & 2'390 & 124 \\
    \multicolumn{1}{l}{Netherlands} & 154   & 214   & \multicolumn{1}{r}{34'176} & 10'208 & 31    & 515   & 66 \\
    \multicolumn{1}{l}{Norway} & 61    & 5'284 & \multicolumn{1}{r}{36'357} & 6'500 & 2     & 343   & 120 \\
    \multicolumn{1}{l}{Spain} &   -    &   -    &  \multicolumn{1}{r}{-} & 5'027 & 1     & 3'563 & - \\
    \multicolumn{1}{l}{Hungary} & 45    & 6'285 & \multicolumn{1}{r}{1'019'666} & 4'500 & 1.6   & 10'197 & 100 \\
    \multicolumn{1}{l}{Denmark} & 27    & 1'412 & \multicolumn{1}{r}{81'000} & 3'500 & 19    & 625   & 130 \\
    \multicolumn{1}{l}{Sweden} & 35    & 12'878 & \multicolumn{1}{r}{144'750} & 2'200 & 0.5   & 2'303 & 63 \\
    \multicolumn{1}{l}{Luxembourg} & 19    & 136   & \multicolumn{1}{r}{11'526} & 1'328 & 51    & 165   & 70 \bigstrut[b]\\
    \hline
    \end{tabulary}%

\end{document}

EDIT:

enter image description here

I have edited the table reaching a width that suits me. However, the margin to the second hline is far too large when I use \bigstrut\ (cf. pciture 3). If I leave it out "Inhabitants" is too near to the hline. How can I approrpiately modify this?

documentclass[12pt]{report}
        \usepackage{multirow}
        \usepackage{bigstrut}
    \usepackage{booktabs}
    \usepackage{tabulary}
    \makeatletter
    \def\hlinewd#1{%
      \noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
       \reserved@a\@xhline}
    \makeatother

        \begin{document}

\begin{tabulary}{\textwidth}{LRRRRRRR}
    \hline
          & \multicolumn{3}{c}{\textbf{Associations}} & \multicolumn{4}{c}{\textbf{Gymnasts}} \bigstrut\\
    \hline
    \bigstrut\\
    \multicolumn{1}{l}{Nation} & Total & km2 per association & \shortstack{Inhabitants\\ per association} & Total & per 100 km2 & \shortstack{Inhabitants\\ per gymnast} & per association \bigstrut\\
    \hline
    \multicolumn{1}{l}{Germany} & 6'915 & 94    & \multicolumn{1}{r}{8'297} & 692'765 & 105   & 83    & 100 \bigstrut[t]\\
    \multicolumn{1}{l}{France} & 700   & 766   & \multicolumn{1}{r}{55'030} & 100'000 & 18    & 385   & 143 \\
    \multicolumn{1}{l}{Czech countries} & 573   & 138   & \multicolumn{1}{r}{15'227} & 47'500 & 61    & 1'884 & 83 \\
    \multicolumn{1}{l}{Switzerland} & 590   & 70    & \multicolumn{1}{r}{5'617} & 43'475 & 104   & 71    & 73 \\
    \multicolumn{1}{l}{Belgium} & 169   & 174   & \multicolumn{1}{r}{38'970} & 14'704 & 50    & 448   & 87 \\
    \multicolumn{1}{l}{Italy} & 106   & 2'704 & \multicolumn{1}{r}{297'000} & 13'175 & 5     & 2'390 & 124 \\
    \multicolumn{1}{l}{Netherlands} & 154   & 214   & \multicolumn{1}{r}{34'176} & 10'208 & 31    & 515   & 66 \\
    \multicolumn{1}{l}{Norway} & 61    & 5'284 & \multicolumn{1}{r}{36'357} & 6'500 & 2     & 343   & 120 \\
    \multicolumn{1}{l}{Spain} &   -    &   -    &  \multicolumn{1}{r}{-} & 5'027 & 1     & 3'563 & - \\
    \multicolumn{1}{l}{Hungary} & 45    & 6'285 & \multicolumn{1}{r}{1'019'666} & 4'500 & 1.6   & 10'197 & 100 \\
    \multicolumn{1}{l}{Denmark} & 27    & 1'412 & \multicolumn{1}{r}{81'000} & 3'500 & 19    & 625   & 130 \\
    \multicolumn{1}{l}{Sweden} & 35    & 12'878 & \multicolumn{1}{r}{144'750} & 2'200 & 0.5   & 2'303 & 63 \\
    \multicolumn{1}{l}{Luxembourg} & 19    & 136   & \multicolumn{1}{r}{11'526} & 1'328 & 51    & 165   & 70 \bigstrut[b]\\
    \hline
    \end{tabulary}%

\end{document}
  • The image you, post is not produced by the code you post (which generates an error due to missing package) and if the package is added the table is much narrower than the one you show – David Carlisle Jan 20 '15 at 20:47
  • Sorry, I forgot to add the tabulary and bookstab packages. It's edited now. However, I don't understand the point you are making. – MadJens Jan 20 '15 at 21:01
  • to increase the space after a line you can just use the standard \\[2cm] command no need for \bigstrut in that context – David Carlisle Jan 21 '15 at 10:44
  • what is the smallest entry? I have used 0.01cm but that is still a little too much margin for my liking. – MadJens Jan 21 '15 at 12:23
3

I think I'd try to think of shorter headings:

enter image description here

All the inner \multicolumn are not needed now but I left them in:

\documentclass[12pt]{report}
    \usepackage{array}
    \usepackage{bigstrut}
\makeatletter
\def\hlinewd#1{%
  \noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
   \reserved@a\@xhline}
\makeatother

\def\header#1{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}
    \begin{document}
\noindent X\dotfill X


\begin{center}
\setlength\tabcolsep{4.5pt}
      \begin{tabular}{l|rrr|rrrr}
    \hline
          & \multicolumn{3}{c|}{\textbf{Associations}} & \multicolumn{4}{c}{\textbf{Gymnasts}} \bigstrut\\
    \hline
    \multicolumn{1}{l|}{Nation} & Total &
\header{km$^2$\\ per\\ assoc-\\iation}
 & 
\header{Inhab-\\itants\\ per\\ assoc-\\iation}
& Total &
\header{per\\100\\ km$^2$} &
\header{Inhab-\\itants\\ per\\ gymn-\\ast} &
\header{per\\assoc-\\iation}\\
    \hline
    \multicolumn{1}{l}{Germany} & 6'915 & 94    & \multicolumn{1}{r}{8'297} & 692'765 & 105   & 83    & 100 \bigstrut[t]\\
    \multicolumn{1}{l}{France} & 700   & 766   & \multicolumn{1}{r}{55'030} & 100'000 & 18    & 385   & 143 \\
    \multicolumn{1}{l}{Czech countries} & 573   & 138   & \multicolumn{1}{r}{15'227} & 47'500 & 61    & 1'884 & 83 \\
    \multicolumn{1}{l}{Switzerland} & 590   & 70    & \multicolumn{1}{r}{5'617} & 43'475 & 104   & 71    & 73 \\
    \multicolumn{1}{l}{Belgium} & 169   & 174   & \multicolumn{1}{r}{38'970} & 14'704 & 50    & 448   & 87 \\
    \multicolumn{1}{l}{Italy} & 106   & 2'704 & \multicolumn{1}{r}{297'000} & 13'175 & 5     & 2'390 & 124 \\
    \multicolumn{1}{l}{Netherlands} & 154   & 214   & \multicolumn{1}{r}{34'176} & 10'208 & 31    & 515   & 66 \\
    \multicolumn{1}{l}{Norway} & 61    & 5'284 & \multicolumn{1}{r}{36'357} & 6'500 & 2     & 343   & 120 \\
    \multicolumn{1}{l}{Spain} &   -    &   -    &  \multicolumn{1}{r}{-} & 5'027 & 1     & 3'563 & - \\
    \multicolumn{1}{l}{Hungary} & 45    & 6'285 & \multicolumn{1}{r}{1'019'666} & 4'500 & 1.6   & 10'197 & 100 \\
    \multicolumn{1}{l}{Denmark} & 27    & 1'412 & \multicolumn{1}{r}{81'000} & 3'500 & 19    & 625   & 130 \\
    \multicolumn{1}{l}{Sweden} & 35    & 12'878 & \multicolumn{1}{r}{144'750} & 2'200 & 0.5   & 2'303 & 63 \\
    \multicolumn{1}{l}{Luxembourg} & 19    & 136   & \multicolumn{1}{r}{11'526} & 1'328 & 51    & 165   & 70 \bigstrut[b]\\
    \hline
    \end{tabular}%
\end{center}

\end{document}
  • That is a start, thank you! However, how do I get rid of the vertical lines? The longer I am using Latex the less I like them. – MadJens Jan 20 '15 at 21:41
  • 1
    @MadJens You have specified them with | in the tabular preamble, just take the | out – David Carlisle Jan 20 '15 at 21:42
  • Ah, I'd missed that. I'll delete my earlier comment (and this one too, in a minute). – Mico Jan 20 '15 at 22:19
  • This table is not quite solve yet for me. I have attained a good width, but there is still something amiss with the margin and I have edited my initial post. Thank you for your help. – MadJens Jan 21 '15 at 10:41

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.