LaTeX forum ⇒ Graphics, Figures & TablesThick 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

Postby pooley343 » Thu Nov 20, 2008 11:38 am

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...

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


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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Thick vertical lines in tabular

Postby gmedina » Thu Nov 20, 2008 3:20 pm

Hi,

the following example illustrates one possibility:
\documentclass{article}
\usepackage{array}

\begin{document}

\begin{center}
  \renewcommand{\arraystretch}{1.3}
  \begin{tabular}{!{\vrule width 2pt}c|c|c!{\vrule width 2pt}c|c|c%
  !{\vrule width 2pt}c|c|c!{\vrule width 2pt}}
    \noalign{\hrule height 2pt}
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \noalign{\hrule height 2pt}
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \noalign{\hrule height 2pt}
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline
    1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \noalign{\hrule height 2pt}
  \end{tabular}
\end{center}

\end{document}

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

curiouslearn
Posts: 105
Joined: Fri Nov 30, 2007 11:32 pm

Re: Thick vertical lines in tabular

Postby curiouslearn » Sun Dec 14, 2008 10:16 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.

User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Thick vertical lines in tabular

Postby localghost » Sun Dec 14, 2008 10:49 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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Thick vertical lines in tabular

Postby curiouslearn » Mon Dec 15, 2008 1:33 am

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.

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Thick vertical lines in tabular  Topic is solved

Postby Juanjo » Sun Dec 21, 2008 1:24 am

Add this to the preamble:
\newlength{\arrayrulewidthOriginal}
\newcommand{\Cline}[2]{%
  \noalign{\global\setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
  \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
  \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

Re: Thick vertical lines in tabular

Postby Da Masda » Thu Nov 22, 2012 2:01 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

Thick vertical lines in tabular

Postby jimratliff » Mon Aug 13, 2018 6:05 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:
\newlength{\arrayrulewidthOriginal}
\newcommand{\Cline}[2]{%
  \noalign{\global\setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
  \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
  \noalign{\global\setlength{\arrayrulewidth}{\arrayrulewidthOriginal}}}

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

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Thick vertical lines in tabular

Postby Juanjo » Tue Aug 14, 2018 2:11 pm

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:
\documentclass[12pt]{article}

\let\Setlength\setlength % <--- Important: place this line before loading calc
\usepackage{calc}
\newlength{\arrayrulewidthOriginal}
\newcommand{\Cline}[2]{%
  \noalign{\global\Setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
  \noalign{\global\Setlength{\arrayrulewidth}{#1}}\cline{#2}%
  \noalign{\global\Setlength{\arrayrulewidth}{\arrayrulewidthOriginal}}}

\begin{document}
  
\begin{tabular}{lccr}
   \hline
   aaa & bbb & ccc & ddd \\ \Cline{1pt}{1-2}
   aaa & bbb & ccc & ddd \\ \Cline{2pt}{3-4}
   aaa & bbb & ccc & ddd \\ 
   \hline
\end{tabular}

\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 12 guests