3

I'm trying to make a table that should be pretty straight forward. But somehow, the text in the two first cells seems to "forget" that it's using the X-alignment command in tabularx:

\documentclass[a4paper,11pt]{article}

\usepackage{tabularx,multirow,booktabs,parskip,setspace,amsmath,amssymb} 
%This is a colaborate document, there are a shitload of packages, but I believe these
%are the packages relevant for the problem.

\newcommand{\cubes}{m\textsuperscript{3}}   
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X} 

\begin{document}

\begin{table}
\begin{minipage}[]{1\textwidth}
\centering
\caption{Expected energy consumption from desalination capacity \label{tab:energy-consumption}}
\begin{tabularx}{1\textwidth}{*{5}{C}}
\toprule
\multirow{2}{*}{Desalination method}&\multirow{2}{*}{Energy consumption [kW/\cubes]}    & \multicolumn{3}{c}{Energy consumption from plant capacity}        \\
                    &           & 50,000 \cubes/d   & 100,000 \cubes/d  & 200,000 \cubes/d      \\
\midrule
RO                  & 18        & $900\cdot 10^3$   & $1800\cdot  10^3$         & $3600 \cdot 10^3$     \\
MSF                 & 18        & $900\cdot 10^3$   & $1800\cdot 10^3$      & $3600 \cdot 10^3$     \\
MED                 & 12.5  & $625\cdot 10^3$   & $1250\cdot 10^3$      & $2500 \cdot 10^3$     \\
\bottomrule
\end{tabularx}
\end{minipage}
\end{table}

\end{document}

As the picture clearly shows, the result is not very esthetic (or readable). I would love the table to split "Desalination \\ method" and "Energy \\ consumption ...". Why does not this happen?

EDIT: The problem can be avoided by just skipping the \multirow-calls and adjusting some tekst in the first row and some in the second (check out a screen dump of the table: http://grab.by/d2KC). But I still find the initial problem intriguing.

Screendump of produced table

0

1 Answer 1

3

Although your complete code is not compiling, the following looks like working. The problem is that you are providing {*} parameter and that means that the cell width is the natural length of the content without linebreaking it. So either you give explicit lengths as below or you can put a tabular environment similar to what is given in the manual of multirow package. Edit: You can adjust your column widths to reach to the desired output.

\documentclass[a4paper,11pt]{article}

\usepackage{tabularx,graphicx,booktabs,parskip,setspace,amsmath,amssymb,multirow}

\newcommand{\cubes}{m\textsuperscript{3}}   
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X} 

\begin{document}
\begin{table}
\caption{Expected energy consumption from desalination capacity \label{tab:energy-consumption}}
\begin{tabularx}{1\textwidth}{*{5}{C}}
\toprule
\multirow{2}{2cm}{Desalination method} &\multirow{2}{2.5cm}{Energy consumption [kW/\cubes]}    & \multicolumn{3}{c}{Energy consumption from plant capacity}        \\
                    &           & 50,000 \cubes/d   & 100,000 \cubes/d  & 200,000 \cubes/d      \\
\midrule
RO                  & 18        & $900\cdot 10^3$   & $1800\cdot  10^3$         & $3600 \cdot 10^3$     \\
MSF                 & 18        & $900\cdot 10^3$   & $1800\cdot 10^3$      & $3600 \cdot 10^3$     \\
MED                 & 12.5  & $625\cdot 10^3$   & $1250\cdot 10^3$      & $2500 \cdot 10^3$     \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

enter image description here

I strongly recommend the siunitx package for unit handling.

1
  • Mine compiled... Anyhow; thank you very much for both solution and siunitx-tip =)
    – Holene
    Apr 12, 2012 at 9:26

You must log in to answer this question.

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