4

I'm trying to add a vertical double line to the horizontal one using \hhline. I want to add this double vertical line after column Year, before (a,b) in my table (the second line from the left). I want this new vertical double line to go from the top, down to the bottom of the table.

My code is:

  \begin{table}[h!]
  \begin{center}
  \begin{tabular}{|c|c|c|c|c|c|}
  \hline
  Year & a & c &e & g\\ 
  &b & d &   f &h \\ \hhline{|=|=|=|=|=|} 
  1995 & 423 & 1049.5 & 3.4 & 31.1 \\ \hline  
  1996 & 224 & 1009.9 & 3.2 & 31.0\\ \hline
  1997 & 209 & 1069.1* & 3.5 & 30.8\\ \hline
  1998 & 298 & 1270.9 & 4.0 & 31.9\\ \hline
  1999 & 322  & 1386.1 &4.2 & 32.9\\ \hline
  2000 & 507 & 1633.9 & 5.0&32.7 \\ \hline
  2001 & 472 & 1515.5 & 4.5&34.0\\ \hline
\end{tabular}
\end{center}

\end{table}

What do I do to improve it? I tried searching other threads but I couldn't get the solutions to work for me.

2
  • Welcome to TeX.SX! Please complete your code with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand, it's easier for us just copy-paste and run it.
    – CarLaTeX
    Feb 20, 2017 at 17:21
  • don't use just h it usually generates a warning, better to use [htp] otherwise it is more likely the table goes to the end of the document. Also only use ! in exceptional cases where you want to ignore the current settings. Feb 20, 2017 at 17:30

2 Answers 2

5

You don't need \hhline for this:

\begin{center}
 \begin{tabular}{|c||c|c|c|c|c|}
  \hline
  Year & a & c &e & g\\ 
  &b & d &   f &h \\ \hline\hline  % \hhline{|=|=|=|=|=|} 
  1995 & 423 & 1049.5 & 3.4 & 31.1\\ \hline  
  1996 & 224 & 1009.9 & 3.2 & 31.0\\ \hline
  1997 & 209 & \phantom{*}1069.1*& 3.5 & 30.8\\ \hline
  1998 & 298 & 1270.9 & 4.0 & 31.9\\ \hline
  1999 & 322 & 1386.1 & 4.2 & 32.9\\ \hline
  2000 & 507 & 1633.9 & 5.0 & 32.7\\ \hline
  2001 & 472 & 1515.5 & 4.5 & 34.0\\ \hline
 \end{tabular}
\end{center}

enter image description here

1
  • Unrelated to the main question, but what does the use of \phantom do here?
    – Adam_G
    Nov 4, 2022 at 17:25
4

Vertical double-lines that cross double horizontal lines (=) require #. However, I'd go with a more open, booktabs presentation:

enter image description here

\documentclass{article}

\usepackage{hhline,booktabs}

\begin{document}

\begin{tabular}{|c||c|c|c|c|c|}
  \hline
  Year & a & c &e & g\\ 
  &b & d &   f &h \\
  \hhline{|=#=|=|=|=|} 
  1995 & 423 & 1049.5 & 3.4 & 31.1\\ \hline  
  1996 & 224 & 1009.9 & 3.2 & 31.0\\ \hline
  1997 & 209 & 1069.1\rlap{*} & 3.5 & 30.8\\ \hline
  1998 & 298 & 1270.9 & 4.0 & 31.9\\ \hline
  1999 & 322 & 1386.1 & 4.2 & 32.9\\ \hline
  2000 & 507 & 1633.9 & 5.0 & 32.7\\ \hline
  2001 & 472 & 1515.5 & 4.5 & 34.0\\ \hline
\end{tabular}

\bigskip

\begin{tabular}{ *{6}{c} }
  \toprule
       & a & c & e & g \\
  Year & b & d & f & h \\
  \midrule
  1995 & 423 & 1049.5 & 3.4 & 31.1 \\
  1996 & 224 & 1009.9 & 3.2 & 31.0 \\
  1997 & 209 & 1069.1\rlap{*} & 3.5 & 30.8 \\
  1998 & 298 & 1270.9 & 4.0 & 31.9 \\
  1999 & 322 & 1386.1 & 4.2 & 32.9 \\
  2000 & 507 & 1633.9 & 5.0 & 32.7 \\
  2001 & 472 & 1515.5 & 4.5 & 34.0 \\
  \bottomrule
\end{tabular}

\end{document}

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.