## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Thick vertical lines in tabular Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
pooley343
Posts: 17
Joined: Mon Oct 20, 2008 2:53 pm

### Thick vertical lines in tabular

I am trying to make a table but with thicker lines for all the outer lines. All of the packages suggest that you should never, ever use vertical lines and don't support thicker vertical lines...well what if I need to?!

I've found and example of what I want but it is written in TeX...

1. {
2. \offinterlineskip
3. \tabskip=0pt
4. \halign{
5. \vrule height2.75ex depth1.25ex width 1pt #\tabskip=1em &
6. \hfil 0.#\hfil &\vrule # & \qquad$0.#\,\pi$\hfil &\vrule # &
7. \hfil 0.#\hfil &#\vrule width 1pt \tabskip=0pt\cr
8. \noalign{\hrule height 1pt}
9. & \omit$\alpha_s$ &&\omit star angle && \omit diquark size [fm] & \cr
10. \noalign{\hrule}
11. & 3 && 22 && 34 &\cr
12. & 4 && 14 && 22 &\cr
13. & 5 && 095 && 15 &\cr
14. \noalign{\hrule height 1pt}
15. }}

Any Help?
Last edited by cgnieder on Thu Nov 22, 2012 2:30 pm, edited 1 time in total.
Reason: code marked

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Hi,

the following example illustrates one possibility:
1. \documentclass{article}
2. \usepackage{array}
3.
4. \begin{document}
5.
6. \begin{center}
7. \renewcommand{\arraystretch}{1.3}
8. \begin{tabular}{!{\vrule width 2pt}c|c|c!{\vrule width 2pt}c|c|c%
9. !{\vrule width 2pt}c|c|c!{\vrule width 2pt}}
10. \noalign{\hrule height 2pt}
11. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
12. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
13. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \noalign{\hrule height 2pt}
14. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
15. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
16. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \noalign{\hrule height 2pt}
17. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
18. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
19. 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \noalign{\hrule height 2pt}
20. \end{tabular}
21. \end{center}
22.
23. \end{document}

To change a vertical line's width, use
1. !{\vrule width <unit>}
To change a horizontal line's width, use
1. \noalign{\hrule height <unit>}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

curiouslearn
Posts: 105
Joined: Fri Nov 30, 2007 11:32 pm
Gmedina, thanks very much for this old post of yours. This morning I was looking for how to increase the line width of vertical lines in tables. I spent a lot of time searching and only found people giving advice about why there should be no vertical lines in tables, which was useless to me since normal form representations of games in Game theory often have vertical lines. Then I came across this helpful post of yours, on this ever helpful forum.

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
curiouslearn wrote:[...] I spent a lot of time searching and only found people giving advice about why there should be no vertical lines in tables, which was useless to me since normal form representations of games in Game theory often have vertical lines. [...]

Avoiding vertical lines is still true for tables containing normal text to improve readability. If the special purpose of a table is made clear right at the beginning, nobody will refuse to help in creating a table with vertical lines.

Best regards
Thorsten¹
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

curiouslearn
Posts: 105
Joined: Fri Nov 30, 2007 11:32 pm
Thanks, Thorsten. I understand. Can someone please tell me how I can use the thickness of \cline lines, that is lines which only span a few columns. Alternatively, how can the thicker horizontal lines drawn using the method suggested by gmedina can be restricted to only a few columns.

Thanks for any help.

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am
1. \newlength{\arrayrulewidthOriginal}
2. \newcommand{\Cline}[2]{%
3. \noalign{\global\setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
4. \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
5. \noalign{\global\setlength{\arrayrulewidth}{\arrayrulewidthOriginal}}}

Then write, for example, \Cline{2pt}{4-7} where you would use \cline{4-7}.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

Da Masda
Posts: 2
Joined: Thu Nov 22, 2012 1:56 pm
THANKS, Juanjo, this is exactly what I have been looking for
This definitely is the easiest way to handle table line thickness. GREAT!

jimratliff
Posts: 1
Joined: Sat Jul 21, 2018 5:52 am
FYI, the below quoted solution conflicts with the calc package in the following sense: If you add \usepackage{calc}, (a) it still compiles, (b) it still draws the horizontal segment, but (c) the thickness of the horizontal line is just the standard thickness and it doesn't change for different values of the length argument. If you then comment out the \usepackage{calc}, the desirable behavior is restored.

Juanjo wrote:Add this to the preamble:
1. \newlength{\arrayrulewidthOriginal}
2. \newcommand{\Cline}[2]{%
3. \noalign{\global\setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
4. \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
5. \noalign{\global\setlength{\arrayrulewidth}{\arrayrulewidthOriginal}}}

Then write, for example, \Cline{2pt}{4-7} where you would use \cline{4-7}.

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am
The problem is that the calc package redefines \setlenght. A simple way to fix it consists in capturing the original definition of \setlenght in a new command, say\Setlenght, before loading calc and use \Setlenght instead of\setlenght in the definition of \Cline.

Check the following minimal working example:
1. \documentclass[12pt]{article}
2.
4. \usepackage{calc}
5. \newlength{\arrayrulewidthOriginal}
6. \newcommand{\Cline}[2]{%
7. \noalign{\global\Setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
8. \noalign{\global\Setlength{\arrayrulewidth}{#1}}\cline{#2}%
9. \noalign{\global\Setlength{\arrayrulewidth}{\arrayrulewidthOriginal}}}
10.
11. \begin{document}
12.
13. \begin{tabular}{lccr}
14. \hline
15. aaa & bbb & ccc & ddd \\ \Cline{1pt}{1-2}
16. aaa & bbb & ccc & ddd \\ \Cline{2pt}{3-4}
17. aaa & bbb & ccc & ddd \\
18. \hline
19. \end{tabular}
20.
21. \end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.