Tabular border style

comparison of 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}
       &
        \begin{tabular}{@{}lll@{}}
        \toprule
        Column 1 & Column 2 & Column 3 \\
        \cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
        second row & & \\
        third row & & \\
        \bottomrule
        \end{tabular}
   \end{tabular}
\end{document}

\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


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.

Tags:

Border

Tables