Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following latex code for a table, but would like to alter the output to match the image below it. Could anyone tell me how I could do this?

\begin{tabular}{|l||c|c|c|}
\hline
& Week 1 & week 2 & Week 3 \\\hline\hline
$\ell$ & 1 & 1 & 1 \\\hline
$h$ & 2 & 2 & 2 \\\hline
\end{tabular}

enter image description here

share|improve this question

4 Answers 4

up vote 4 down vote accepted

Assuming that short lines from a first-line rectangle are undesired, we can do the following:

\documentclass{article}

\begin{document}

\begin{tabular}{|l||c|c|c|}
%\hline
\cline{2-4}
%& Week 1 & week 2 & Week 3 \\\hline\hline
\multicolumn{1}{c|}{}& Week 1 & week 2 & Week 3 \\
\cline{2-4}\noalign{\vskip2pt}\cline{1-4}
$\ell$ & 1 & 1 & 1 \\\hline
$h$ & 2 & 2 & 2 \\\hline
\end{tabular}

\end{document}

enter image description here

share|improve this answer
    
Or \vskip\doublerulesep instead of a hardcoded 2pt. Also \hline works in place of \cline{1-4} –  Dan Nov 18 '13 at 21:04

enter image description here

\documentclass{article}

\usepackage{array,hhline}
\setlength\extrarowheight{2pt}
\begin{document}
\begin{tabular}{|l||c|c|c|}
\hhline{~---}
\multicolumn{1}{c|}{}& Week 1 & week 2 & Week 3 \\
\hhline{-===}
$\ell$ & 1 & 1 & 1 \\\hline
$h$ & 2 & 2 & 2 \\\hline
\end{tabular}

\end{document}
share|improve this answer

Here's another option, using booktabs

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{lccc}
    \toprule
           & Week 1 & Week 2 & Week 3 \\
    \midrule
    $\ell$ & 1      & 1      & 1      \\
    $h$    & 2      & 2      & 2      \\
    \bottomrule
\end{tabular}

\end{document}
share|improve this answer

I would look into the commands \cmidrule{a-b}to take care of the special case where the lines don't go into the first of the cells. http://en.wikibooks.org/wiki/LaTeX/Tables is a great place to start for advance tables.

share|improve this answer
1  
\cmidrule comes from booktabs, and wouldn't work to get exactly that output. Try \cline{2-4} instead. –  Torbjørn T. Nov 17 '13 at 22:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.