1

I've created a longtable which is too wide. Reducing the fontsize is not an option because of my university's guidelines. I already tried to solve the problem by using resizebox, tabularx etc. but none of this really worked. Since I am really a beginner I might just did a easy mistake.

However, that's the code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{longtable}
\begin{document}
\begin{longtable}{@{}llrrr@{}} 
\caption{Industry-specific drivers of final energy demand and emissions}\\
\label{tab:IndDrivers}

\textbf{Product} & \textbf{Period} & \textbf{Production growth}  & \textbf{Energy efficiency} & \textbf{Emission share}               \\
& \textbf{} & \textbf{[\% p.a.]}  & \textbf{[\% p.a.]} & \textbf{outside EU ETS} \\
\hline
\endhead
\hline
\endfoot
Aluminium        & until 2020     & 0.7  &  &  \\
                 & 2021 to 2030   & 0.6  &  &  \\
                 & 2031 to 2040   & 0.5  &  &  \\
                 & after 2040     & 0.3  &  &  \\
Ammonia          & until 2020     & 1.2  &  &  \\
                 & 2021 to 2030   & 1.1  &  &  \\
                 & 2031 to 2040   & 1.1  &  &  \\
                 & after 2040     & 1.0  &  &  \\
Cement           & until 2020     & 0.6  &  &  \\
                 & 2021 to 2030   & 1.2  &  &  \\
                 & 2031 to 2040   & 1.0  &  &  \\
                 & after 2040     & 0.8  &  &  \\
\end{longtable}
\end{document}

Does someone have a solution? I'd be very very thankful!

Best,

Fabian

3 Answers 3

1

With makecellyou can add breaks in the tablehead.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{longtable}

\usepackage{makecell} % ADDED
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{longtable}{@{}llrrr@{}} 
\caption{Industry-specific drivers of final energy demand and emissions}\\
\label{tab:IndDrivers}

\thead{Product} & \thead{Period} & \thead{Production\\growth}  & \thead{Energy\\efficiency} & \thead{Emission share\\outside EU ETS}               \\
& \thead{} & \thead{[\% p.a.]}  & \thead{[\% p.a.]}  \\
\hline
\endhead
\hline
\endfoot
Aluminium        & until 2020     & 0.7  &  &  \\
                 & 2021 to 2030   & 0.6  &  &  \\
                 & 2031 to 2040   & 0.5  &  &  \\
                 & after 2040     & 0.3  &  &  \\
Ammonia          & until 2020     & 1.2  &  &  \\
                 & 2021 to 2030   & 1.1  &  &  \\
                 & 2031 to 2040   & 1.1  &  &  \\
                 & after 2040     & 1.0  &  &  \\
Cement           & until 2020     & 0.6  &  &  \\
                 & 2021 to 2030   & 1.2  &  &  \\
                 & 2031 to 2040   & 1.0  &  &  \\
                 & after 2040     & 0.8  &  &  \\
\end{longtable}
\end{document}

enter image description here

2
  • Thank you very much!
    – Fabian
    Feb 6, 2020 at 11:14
  • If this is the solution you wanted, please accept it as well. Thank you
    – Sango
    Feb 6, 2020 at 12:05
0

Whit this simple change in headers:

\textbf{Product} & \textbf{Period} & \textbf{Production}  & \textbf{Energy} & \textbf{Emission}   \\
& \textbf{} & \textbf{growth}  & \textbf{efficiency} & \textbf{share outside} \\    
& \textbf{} & \textbf{[\% p.a.]}  & \textbf{[\% p.a.]} & \textbf{EU ETS} \\

You obtain:

New table

And instead of until and after, you can write < 2020 or > 2040, and so on...

0

Here is another variant using nested table instead of makecell, headings aligned at the bottom baseline and using better spaces rules from booktabs. The nested tables are put inside the new command \thead. I have used more spacing between rows (\extrarowheight) and reduced the dominance of headers by setting them a grade smaller and not using bold.

I have used longtable’s built in \caption-command. In the updated answer, I have introduce some reading guidance by using \addlinespace to increasing the space between each group of rows.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable, booktabs, array}

% Multi-line left-aligned text with manual line breaks.
% The base line of the whole is at the top row.
\newcommand*{\thead}[1]{%
  \begingroup
    \renewcommand*{\arraystretch}{1}%
    \small\begin{tabular}[b]{@{}r@{}}#1\end{tabular}%
  \endgroup
}

\setlength{\extrarowheight}{1pt}

\begin{document}
\begin{longtable}{@{}llrrr@{}} 
\caption{Industry-specific drivers of final energy demand and emissions\label{tab:IndDrivers}}\\

\thead{Product} &
\thead{Period}   &
\thead{Production\\growth\\{}\footnotesize{[\% p.a.]}}&
\thead{Energy\\efficiency\\{}\footnotesize{[\% p.a.]}}   &
\thead{Emission\\ share outside\\ EU ETS}\\
\midrule
\endhead
\bottomrule
\endfoot

Aluminium        & until 2020     & 0.7  &  &  \\
                 & 2021 to 2030   & 0.6  &  &  \\
                 & 2031 to 2040   & 0.5  &  &  \\
                 & after 2040     & 0.3  &  &  \\ \addlinespace[0.75ex]
Ammonia          & until 2020     & 1.2  &  &  \\
                 & 2021 to 2030   & 1.1  &  &  \\
                 & 2031 to 2040   & 1.1  &  &  \\
                 & after 2040     & 1.0  &  &  \\ \addlinespace[0.75ex]
Cement           & until 2020     & 0.6  &  &  \\
                 & 2021 to 2030   & 1.2  &  &  \\
                 & 2031 to 2040   & 1.0  &  &  \\
                 & after 2040     & 0.8  &  &  \\
\end{longtable}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .