26
\begin{tabular}{|c|c|c|}
Column 1 & Column 2 & column3 \\
\hline
second row & & \\
\hline
\end{tabular}

How do I change the border style? Using | I can draw thin solid vertical lines and \hline draws thin solid horizontal lines. I would like a thick outer border and thin dotted lines of various sizes and colors in the table. In short I would like to achieve similar functionality of attached screenshot of MS word table options in LaTeX. Also the reason for asking this is to put all table borders related answers in one place.

Thanks for your help. Screenshot of MS Word "Borders and Shading" dialog box

  • I wouldn´t like the look of dashed lines, even in illustrations, if you can use gray lines instead. – Benjamin McKay Feb 17 '15 at 16:46
17
\documentclass{article}
\usepackage{array,booktabs,arydshln,xcolor}
\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}

\begin{document}

\begin{tabular}{!{\VRule[2pt]}c!{\VRule}c!{\color{red}\VRule[3pt]}c!{\VRule}}
Column 1 & Column 2 & column3 \\\specialrule{3pt}{0pt}{0pt}
second row & & \\\hdashline
third row  & & \\\specialrule{4pt}{0pt}{0pt}
\end{tabular}

\end{document}

enter image description here

  • I want to add a one bold horizontal line only between the two row... this method didn't work. – Misaki Oct 9 '13 at 10:18
  • 2
    Please explain how this works. – Duncan Whyte Mar 26 '18 at 17:53
15

comparison of different table layouts

Here are a few table layouts, with my favourite one last.

\documentclass{article}
\usepackage{xcolor}
\usepackage{booktabs}
\begin{document}
    \begin{tabular}{p{6cm}p{6cm}}
        \begin{tabular}{|c|c|c|}
        \hline
        Column 1 & Column 2 & Column 3 \\
        \hline
        second row & & \\
        \hline
        third row & & \\
        \hline
        \end{tabular}
        &
        \begin{tabular}{ccc}
        Column 1 & Column 2 & Column 3 \\
        \hline
        second row & & \\
        \hline
        third row & & \\
        \hline
        \end{tabular}
        \\[5em]
        \begin{tabular}{|ccc|}
        \hline
        Column 1 & Column 2 & Column 3 \\
        \hline
        second row & & \\
        third row & & \\
        \hline
        \end{tabular}
        &
        \begin{tabular}{|c|c|c|}
        \hline
        Column 1 & Column 2 & Column 3 \\
        \hline
        second row & & \\
        third row & & \\
        \hline
        \end{tabular}
        \\[5em]
        \begin{tabular}{ccc}
        Column 1 & Column 2 & Column 3 \\
        second row & & \\
        third row & & 
        \end{tabular}
        &
        \begin{tabular}{lll}
        \toprule
        Column 1 & Column 2 & Column 3 \\
        \midrule
        second row & & \\
        third row & & \\
        \bottomrule
        \end{tabular}
        \\[5em]
        % Colour for the rulings in tables:
        \makeatletter
           \def\rulecolor#1#{\CT@arc{#1}}
           \def\CT@arc#1#2{%
           \ifdim\baselineskip=\z@\noalign\fi
           {\gdef\CT@arc@{\color#1{#2}}}}
           \let\CT@arc@\relax
          \rulecolor{gray!50}
        \makeatother
        \begin{tabular}{@{}lll@{}}
        \toprule
        Column 1 & Column 2 & Column 3 \\
        \midrule
        second row & & \\
        third row & & \\
        \bottomrule
        \end{tabular}
   \end{tabular}
\end{document}
5

There is the hhline package and the arydshln package. You can get colour in the table with the xcolor package.

You might have your reasons to typeset your tables with many different line styles... I'd usually recommend to avoid vertical lines at all and to draw horizontal lines with commands provided by the booktabs package.

In case you are writing something related to science, more or less all textbooks seem to roughly follow similar guidelines. Rarely you will find a vertical line.

0

You can use all the flexibility permitted by LaTeX:

\usepackage{arydshln}
...

\begin{table}[h]
\begin{tabular}{lll}
\multicolumn{1}{c}{\textbf{Title 1}} &  & \multicolumn{1}{c}{\textbf{Title 2}} \\
\cline{1-1} \cline{3-3}
\multicolumn{1}{|l|}{Cell 1} & & \multicolumn{1}{|l|}{Cell 2} \\
\cdashline{3-3}
\multicolumn{1}{|l|}{Cell 3} & & \multicolumn{1}{|l|}{Cell 4} \\
\cline{3-3}
\multicolumn{1}{|l|}{Cell 5} & & \\
\cline{1-1}
\end{tabular}
\end{table}

The result is:

enter image description here

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Paul Gessler Feb 17 '15 at 12:11

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.