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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
2  
Minimize the use of vertical lines in tables. They disturb more than they help. – Svend Tveskæg Jan 2 '14 at 10:00
    
+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 at 13:02
up vote 10 down vote accepted

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.

share|improve this answer

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

share|improve this answer
7  
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
    
@tohecz Yeah! I agree with you! +1 – Eden Harder Jan 2 '14 at 14:21

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.