1

I need to wrap the text in two table cells. However, when the text has been wrapped correctly in cell (1,1) and (1,3), the text on the first row in the table do not align.

\documentclass[b5paper, 10pt, twoside]{report}

\usepackage{booktabs}
\usepackage{array}
\newcommand*\rotbf[1]{\rotatebox{90}{\textbf{#1}}}
\newcommand{\specialcell}[2][b]{\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
\newcommand{\specialcellbold}[2][b]{%
  \bfseries
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}%
}
\newcommand*{\leftspecialcell}[2][b]{%
  \begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}

\newcommand*{\rightspecialcell}[2][t]{%
  \begin{tabular}[#1]{@{}r@{}}#2\end{tabular}%
}

\begin{document}
\begin{table}[hbr]
\begin{tabular}{lrrrr}
\toprule \textbf{} & \textbf{NIBE} & \textbf{Nilan}& \textbf{Enervent} &     \textbf{Viessman} \\
\midrule 
\leftspecialcell{Heat exchanger \\ \quad type} & None &     \rightspecialcell{Polystyrene\\plate exch.} & f & a \\
Heat source(s) & EA & EA & f & f \\
Heat sink(s) & Water & Water and air & f & f \\
Cooling option & No & Yes & & \\
\bottomrule
\end{tabular}\\
\end{table}
\end{document}
  • Sorry, this code looks awful. The \label will produce a wrong reference, since there is no \caption for the table – user31729 Mar 18 '15 at 15:34
  • @SoundsOfSilence: Forgot to remove \caption. It should not be there, seeing that this is a MWE only. – PhilN Mar 23 '15 at 18:18
1

This is uses a new columntype, (but can be switched to p - type) as well. for wrapping.

\documentclass[b5paper, 10pt, twoside]{report}

\usepackage{booktabs}
\usepackage{array}
\usepackage{ragged2e}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\newcommand*\rotbf[1]{\rotatebox{90}{\textbf{#1}}}
\newcommand{\specialcell}[2][b]{\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
\newcommand{\specialcellbold}[2][b]{%
  \bfseries
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}%
}
\newcommand*{\leftspecialcell}[2][b]{%
  \begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}

\newcommand*{\rightspecialcell}[2][t]{%
  \begin{tabular}[#1]{@{}r@{}}#2\end{tabular}%
}





\begin{document}
\begin{table}[hbr]
\caption{Some caption}\label{tbl:intflow}
\begin{tabular}{L{3cm}*{4}{r}}
\toprule \textbf{} & \textbf{NIBE} & \textbf{Nilan}& \textbf{Enervent} &     \textbf{Viessman} \\
\midrule 
Heat exchanger type & None &  \multicolumn{1}{L{2cm}}{Polystyrene plate exch.} & f & a \\
Heat source(s) & EA & EA & f & f \\
Heat sink(s) & Water & Water and air & f & f \\
Cooling option & No & Yes & & \\
\bottomrule
\end{tabular}\\
\end{table}


\begin{table}[hbr]
\label{tbl:intflowold}
\begin{tabular}{lrrrr}
\toprule \textbf{} & \textbf{NIBE} & \textbf{Nilan}& \textbf{Enervent} &     \textbf{Viessman} \\
\midrule 
\leftspecialcell{Heat exchanger \\ \quad type} & None &     \rightspecialcell{Polystyrene\\plate exch.} & f & a \\
Heat source(s) & EA & EA & f & f \\
Heat sink(s) & Water & Water and air & f & f \\
Cooling option & No & Yes & & \\
\bottomrule
\end{tabular}\\
\end{table}

\end{document}

enter image description here

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.