I am having a bit of a trouble with a table. The code for the table looks like this:
\documentclass{report}
\usepackage{booktabs}
\usepackage{array}
\newcommand*\rotbf[1]{\rotatebox{90}{\textbf{#1}}}
\newcommand{\specialcell}[2][c]{\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}}
\begin{document}
\begin{table}[hbr]
\centering
\label{tbl:heatwheel_res}
\begin{tabular}{llll}
\toprule
\textbf{Parameter} & \specialcell{Exhaust\\air} & \specialcell{Exhaust and \\ outdoor air} & \specialcell{Heat wheel\\(80~\%)} \\
\midrule
Heat recovery [\%] & 89,6 \% & 89,6 \% & 77,4 \% \\
Real heat recovery [\%] & 50,5 \% & 52,1 \% & - \\
Net energy need for VH and SH & 27,7 & 27,0 & 15,8 \\
\specialcell{Delivered energy for\\DHW, VH and SH} & 31,1 & 27,6 & 45,6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
I'm using \specialcell
in order to break the line of elements that are too long. However, I want the text in the first row to be bold. When I add \textbf{}
inside \specialcell
, the document will not compile. Error message is: "Missing } inserted
".
Do you have any suggestions? Can I make a new specialcell (\specialcell2
) that is automatically bold?
Another question: How can I force the table to be a bit wider, in order to increase the space between the first column and the second column? I think column 1 and 2 are a bit too close at row 4.
Best Answer
Since the whole outer cell, which contains
\specialcell
should be bold,\bfseries
can be specified in the outer cell, right before\specialcell
:This can also be put into a macro
\specialcellbold
, see the following example:The table formatted a little different:
Remarks:
siunitx
for aligning at the decimal marker and for setting the percent signs.\siunit{text-rm=\bfseries}
. Optiondetect-weight
did not work inside anS
-column.Update
I, Svend Tveskæg, found the code not very easy to read to I cleaned it up a bit (I hope it's okay):