19

We know that by adding \setlength\arrayrulewidth{xpt} changes the thickness of all the table lines.

If I wanted to change specific table lines, how to do it?


\documentclass[11pt]{article}

\setlength\arrayrulewidth{0.7pt}

\begin{document}

\begin{tabular}{|l|l|l|l|}
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
\end{tabular}

\vspace{1ex}

\begin{tabular}{|l|l|l|l|}
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
\end{tabular}

\end{document}

First table remains with its thickness of the lines intact. I want to change the thickness of all lines in second table. (Vertical and horizontal ones need to be equal.)

2 Answers 2

31

Update

Use \arrayrulewidth from the preamble and place it before the desired table using a group to keep the change to \arrayrulewidth local:

\documentclass[11pt]{article}
\usepackage{array}


\begin{document}

\begin{tabular}{|l|l|l|l|}
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
\end{tabular}

\vspace{1ex}

{
\setlength\arrayrulewidth{2pt}
\begin{tabular}{|l|l|l|l|}
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
\end{tabular}
}

\begin{tabular}{|l|l|l|l|}
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
 &  &  &  \\ 
\hline
\end{tabular}

\end{document}

enter image description here

You can have individual rule control too:

For horizontal rules:

\noalign{\hrule height <length>}

instead of \hline (you can define a command for this). For vertical rules:

!{\vrule width <length>}

instead of | in the format specification. An example:

enter image description here

The code for the example:

\documentclass{article}
\usepackage{array}

\newcommand\ChangeRT[1]{\noalign{\hrule height #1}}

\begin{document}

\noindent
\begin{tabular}{
  |c!{\vrule width 1pt}
  c!{\vrule width 1.6pt}
  c!{\vrule width 2.2pt}
  c!{\vrule width 2.8pt}
  c!{\vrule width 3.4pt}
  c!{\vrule width 4pt}
  c!{\vrule width 4.6pt}
  }
\hline
& & & & & & \\
\ChangeRT{1pt}
& & & & & & \\
\ChangeRT{1.6pt}
& & & & & & \\
\ChangeRT{2.2pt}
& & & & & & \\
\ChangeRT{2.8pt}
& & & & & & \\
\ChangeRT{3.4pt}
& & & & & & \\
\ChangeRT{4pt}
& & & & & & \\
\ChangeRT{4.6pt}
\end{tabular}\par\bigskip

\noindent
\begin{tabular}{|c!{\vrule width 4pt}c|c!{\vrule width 8pt}}
\hline
column1a & column2a & column 3a \\
\ChangeRT{4pt}
column1b & column2b & column 3b \\
\hline
column1c & column2c & column 3c \\
\ChangeRT{2pt}
column1d & column2d & column 3d \\
\hline
\end{tabular}
\end{document}

The booktabs package offers an optioanl argument to its rule commands control their thickness (vertical rules, of course, are not a good companion here):

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{*{7}{c}}
\toprule[2pt]
a & b & c & d & e & f & g \\
\midrule[1pt]
a & b & c & d & e & f & g \\
\midrule
a & b & c & d & e & f & g \\
\cmidrule[2pt]{3-5}
a & b & c & d & e & f & g \\
\midrule
a & b & c & d & e & f & g \\
\bottomrule[5pt]
\end{tabular}

\end{document}

enter image description here

2
  • I've expressed myself wrong. Can you take a look again? I've edited.
    – Schwale
    Jul 23, 2015 at 19:11
  • @Oshnaj Please see my updated answer. Jul 23, 2015 at 19:17
5

For horizontal rules, you can use the boldline package (from the shipunov bundle). It defines \hlineB and a \clineB commands, which use a num \arrayrulewidth argument.

An alternative is the makecell package, which defines its own \Xhline and \Xcline commands; they have a dimension argument.

For vertical rules, you can use !{\vrule width x pt} in the table preamble. Boldline defines a V{num} qualifier.

\documentclass{article}

\usepackage{array, makecell}
\usepackage{boldline}
\usepackage[x11names, table]{xcolor}
\usepackage{colortbl}

\begin{document}

\begin{center}
  \renewcommand\arraystretch{1.5}
  \begin{tabular}{V{5}c|c|cV{5}}
    \hlineB{7.5}
    Fiddle & Dee & Dee \\
\clineB{1-2}{3}
Tweedledee &Tweedledum & \\
    \hlineB{5}
  \end{tabular}
  \vskip 3ex
  \begin{tabular}{!{\vrule width2pt}c|c|c!{\vrule width2pt}}
\Xhline{3pt}
    Fiddle & Dee & Dee \\
\Xcline{1-2}{1.2pt}
Tweedledee &Tweedledum & \\
    \Xhline{2pt}
  \end{tabular}
\end{center}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .