2

I'm trying to make a table that's a little complex. I'll try to explain what I want with a picture of a table from word: Table from word

I'm new to latex, so I have two questions. How can I make such table look good? And secondly - how do I make it in LaTex? I've tried the following:

\begin{table}[hbr]
\caption{Description}
\label{tbl:hexhcomp}
\centering
\noindent
\def\arraystretch{1.2} 
\begin{tabular}[c]{|l || c| c| c| c| c| c| c| c|}
  \cline{2-7}
  \multicolumn{1}{c|}{} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Thermal\\wheel}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Energy\\wheel}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Fixed\\matrix}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Plate}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Tube}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Run-around}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Heat- pipe}}} &
    \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Membrane}}} \\[15pt]
  \hline
  \hline

  \parbox[t]{3cm}{\raggedright{Sensible efficiency}} & N & N & N & Y & Y & Y & Y & Y \\[15pt]
  \hline
  \parbox[t]{3cm}{\raggedright{Latent efficiency}} & N & N & N & N & Y & Y & Y & Y \\[15pt]
  \hline
\end{tabular}
\end{table}

Is there a simpler or more elegant way of achieving this?

  • change the first column from c to >{\raggedright}p{3cm} (you need array package) then you can get rid of the \parbox similarly you don't need the \parbox around the rotated boxes in the first row at all. Apart from that it looks about right – David Carlisle Nov 13 '14 at 14:43
2
% arara: pdflatex

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\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}
\caption{Description}
\label{tbl:hexhcomp}
\centering
\begin{tabular}{l *{8}c}
\toprule
     & \rotbf{\specialcell{Thermal\\wheel}} 
     & \rotbf{\specialcell{Energy\\wheel}} 
     & \rotbf{\specialcell{Fixed\\matrix}} 
     & \rotbf{Plate} 
     & \rotbf{Tube} 
     & \rotbf{\specialcell{Run-\\around}} 
     & \rotbf{Heat-pipe} 
     & \rotbf{Membrane} \\
\midrule
\specialcell{Sensible\\efficiency} & N & N & N & Y & Y & Y & Y & Y \\
\specialcell{Latent\\efficiency} & N & N & N & N & Y & Y & Y & Y \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

You may always include \midrule or \addlinespace[...] if you think the readability is suffering. You should do this at the very end in order to see the complete picture.

enter image description here

| improve this answer | |
  • Nice! However, the table will contain at least 9 rows of data (like "Sensible efficiency"). Do you still not think there's a need for \hline-s between the lines? Is it possible to get the N and Y on the middle of the two lines? Or does that hamper the reading quality? – ROLF Nov 13 '14 at 15:04
  • @ROLF I made it a bit simpler now. Everything is centered like this and no hard coding is required for the sizes. – LaRiFaRi Nov 13 '14 at 15:23
  • Is there a way to insert vertical lines easily in this code? I just want to see what it looks like. EDIT: Never mind, I found the {l*{8}c} :) – ROLF Nov 13 '14 at 16:00
  • How to I remove the gaps that appears when inserting vertical lines? – ROLF Nov 13 '14 at 16:08
  • @ROLF booktabs is not meant to be used with vertical lines. You will have to switch back to your hlines – LaRiFaRi Nov 13 '14 at 17:48
1

Closer to your original layout than the booktabs answer, but using simpler markup.

enter image description here

\documentclass{article}
\usepackage{graphicx,array}
\begin{document}
\begin{table}[hbtp]% there is no r, always best to include p
\caption{Description}
\label{tbl:hexhcomp}
\centering
\noindent
\def\arraystretch{3} 
\newcommand\rothd[1]{\makebox[20pt]{%
\rotatebox{90}{\def\arraystretch{1}\bfseries\begin{tabular}{@{}l@{}}#1\end{tabular} }}}
\begin{tabular}%[c] no need for [c] it's the default anyway
{|
>{\raggedright}p{3cm}% instead of l 
|| c| c| c| c| c| c| c| c|}
\hline
  % not needed  \multicolumn{1}{c|}{}
 &
% \parbox[t]{0.8cm}{\rotatebox[origin=c]{90}{\textbf{Thermal\\wheel}}} &
 \rothd{Thermal\\wheel}&
 \rothd{Energy\\wheel} &
 \rothd{Fixed\\matrix}& 
\rothd{Plate} &
 \rothd{Tube} &
\rothd{Run-\\around} &
\rothd{Heat-pipe} & 
\rothd{Membrane}
 \\
\hline
\hline

Sensible efficiency & N & N & N & Y & Y & Y & Y & Y \\
\hline
Latent efficiency & N & N & N & N & Y & Y & Y & Y \\
\hline

\end{tabular}
\end{table}
\end{document}
| improve this answer | |

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.