1

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

4 Answers 4

4

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

1
  • Or \vskip\doublerulesep instead of a hardcoded 2pt. Also \hline works in place of \cline{1-4}
    – Dan
    Nov 18, 2013 at 21:04
4

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}
2

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}
0

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.

1
  • 1
    \cmidrule comes from booktabs, and wouldn't work to get exactly that output. Try \cline{2-4} instead. Nov 17, 2013 at 22:01

You must log in to answer this question.

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