2

I'm having some problems with tables:

1) Right now cells are centrally aligned (horizontal & vertical). I would like to centre the cells horizontally only so that the text remains at the top of the cell.

2) The line spacing between different cells is perfect. However inside the cell i want the line spacing to be less so i can differentiate between different cells and multi-line cells. (See 3rd row)

Thanks for the help

Here's my code:

    \documentclass[12pt]{report}
    \usepackage{array}
    \begin{document}

    \begin{table}[h]
        \renewcommand{\arraystretch}{1.75}
        \begin{tabular}{lcccc}
        \hline
        Parameter                                                                   
        & MSF                                                                                   
        & MED                                                                          
        & RO                                                                                
        & ED         \\ \hline

        Application
        & SW/BW 1
        & SW/BW
        & SW/BW     
        & BW        \\                                                                                                                                                                                                                    

        \begin{tabular}[c]{@{}l@{}}Market share2 (\%)\end{tabular}
        & 27 
        & 8
        & 4
        & 60         \\

        \begin{tabular}[c]{@{}l@{}}Water production\\cost  (\$/m\textsuperscript{3})\end{tabular}    
        & 0.56--1.75
        & 0.52--1.5  
        & \begin{tabular}[c]{@{}c@{}}0.45--1.72 (SW)\\   0.26--1.33 (BW)\end{tabular}  
        & 0.6--1.05 \\                                                                                                                                               

        \end{tabular}
        \end{table}

     \end{document}

table

4
  • tabular are vertically centred by default you can top-align them using the optional argument but you used \begin{tabular}[c] that should be [t] Jan 14, 2015 at 17:34
  • 1
    Please always post a complete document so people can test answers Jan 14, 2015 at 17:35
  • @DavidCarlisle Thanks that solved the first problem. And i completed the code
    – Moody
    Jan 14, 2015 at 18:02
  • presumably you want \renewcommand{\arraystretch}{1} before your inner tables Jan 14, 2015 at 18:03

2 Answers 2

4

I'm not sure if this is what you want

enter image description here

Code:

\documentclass[12pt]{report}
\usepackage{array}
\begin{document}

\begin{table}[h]
   \renewcommand{\arraystretch}{1.75}
   \begin{tabular}{lcccc}
   \hline
   Parameter
   & MSF
   & MED
   & RO
   & ED         \\ \hline

   Application
   & SW/BW 1
   & SW/BW
   & SW/BW
   & BW        \\

   Market share2 (\%)
   & 27
   & 8
   & 4
   & 60         \\

   \begin{tabular}[t]{@{}l@{}}Water production\\[-10pt] cost (\$/m\textsuperscript{3})\end{tabular}
   & 0.56--1.75
   & 0.52--1.5
   & \begin{tabular}[t]{@{}c@{}}0.45--1.72 (SW)\\[-10pt] 0.26--1.33 (BW)\end{tabular}
   & 0.6--1.05 \\  \hline

   \end{tabular}
   \end{table}

\end{document}

or (easier)

\documentclass[12pt]{report}
\usepackage{array}
\begin{document}

\begin{table}[h]
   \renewcommand{\arraystretch}{1.75}
   \begin{tabular}{lcccc}
   \hline
   Parameter
   & MSF
   & MED
   & RO
   & ED         \\ \hline

   Application
   & SW/BW 1
   & SW/BW
   & SW/BW
   & BW        \\

   Market share2 (\%)
   & 27
   & 8
   & 4
   & 60         \\

   Water production
   & 0.56--1.75
   & 0.52--1.5
   & 0.45--1.72 (SW)
   & 0.6--1.05 \\[-10pt]

   cost (\$/m\textsuperscript{3})
   &
   &
   & 0.26--1.33 (BW)
   &          \\

   \hline

   \end{tabular}
   \end{table}

\end{document}
0
1

Another way, without changing \arraystretch. It uses makecell and booktabs:

\documentclass[12pt]{report}
\usepackage{array, booktabs, makecell}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadalign{tc}
\renewcommand\cellalign{tl}
\setcellgapes{5pt}\makegapedcells

\begin{document}

\begin{table}[h]
   \begin{tabular}{lcccc}
   \toprule
   Parameter
   & MSF
   & MED
   & RO
   & ED \\
   \midrule
   Application
   & SW/BW 1
   & SW/BW
   & SW/BW
   & BW \\
%
   Market share2 (\%)
   & 27
   & 8
   & 4
   & 60 \\
%
  \makecell{Water production\\cost (\$/m\textsuperscript{3})}
   & 0.56--1.75
   & 0.52--1.5
   & \thead{0.45--1.72 (SW)\\0.26--1.33 (BW)}
   & 0.6--1.05 \\
   \bottomrule
   \end{tabular}
   \end{table}

\end{document} 

enter image description here

You must log in to answer this question.

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