15

I want to draw a table with two \hline and two vertical line. But as shown in the figure, the first vertical line do not cross the two hline. How to solve this problem?

\documentclass{article}
\usepackage{hhline}
\begin{document}

\begin{tabular}{c||c||c}
\hline 
1 & 2 & 3 \\ \hhline{=|=|=}
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\ \hline
\end{tabular}

\end{document}

output

  • 2
    Minimize the use of vertical lines in tables. They disturb more than they help. – Svend Tveskæg Jan 2 '14 at 10:00
  • 5
    +Svend I couldn't disagree more. SOME tables look nice without vertical lines, but there are MANY tables that demand them, and the notion that they should be avoided at all cost is a horrific one that is way too prevalent in the LaTeX community. – Travis Bemrose Feb 1 '16 at 13:02
17

As stated in the hhline package documentation, | gives you a vertical line which cuts through a double (or single) hline, whereas # gives a double hline segment between two vlines.

So, to correct your situation (leaving aside the aesthetic issues) simply use, # in place of the | in the argument for \hhline.


\documentclass{article}
\usepackage{hhline}
\begin{document}

\begin{tabular}{c||c||c}
\hline 
1 & 2 & 3 \\ \hhline{=#=#=}
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\ \hline
\end{tabular}

\end{document}

You get the following output.

enter image description here


For further reading, please see the hhline package documentation mentioned above. Also, you may like to see this question as well.

2

Don't use vertical lines in tables; they disturb more than they help.

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{ccc}
\toprule
1 & 2 & 3 \\
\midrule
4 & 5 & 6 \\
\midrule
7 & 8 & 9 \\
\bottomrule
\end{tabular}

\end{document}

output

  • 14
    It is not the answer to OP's question. – Przemysław Scherwentke Jan 2 '14 at 10:43
  • 1
    @PrzemysławScherwentke I don't agree with you. We've hand a "don't do this" answers with alternative provided before. Since TeX is about typography, it's not wrong to provide typographical alternatives to what OP asks for. See e.g. What's the quickest way to write “2nd” “3rd” etc in LaTeX – yo' Jan 2 '14 at 13:53
  • Thanks so much! It is beautiful but MMA gives the answer 'to' the question. – Eden Harder Jan 2 '14 at 14:21
-2
\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{c| |c| |c}
\toprule
1 & 2 & 3 \\ \hline
\hline
4 & 5 & 6 \\ \hline \hline
7 & 8 & 9 \\
\bottomrule
\end{tabular}

\end{document}

It looks pretty! This looks nicer

  • This doesn't answer the question. – Werner Jul 13 '17 at 20:08

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.