1

I am working on a table that @David Carlisle fixed for me in this topic: Formatting pbox in table for neat distribution of text The tex for the table is below:

\documentclass[a4paper]{article}
\usepackage{array}
\setlength\extrarowheight{2pt}
\begin{document}
\newcommand\pb[1]{%
\begin{tabular}{@{}l@{}}#1\end{tabular}}
\begin{table}[htp]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE}           & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT}                           & number    & number    & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number         \\ \hline
some title here          & value       &\pb{12341 538768 \\ 23423 22}& \pb{12341 538768 \\ 23423 22}   &    \pb{12341 538768 \\ 23423 22}      \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number    \\ \hline
some title here         & value                     &  \pb{12341 538768 \\ 23423 228}& \pb{12341 538768 \\ 23423 22}   &  \pb{12341 538768 \\ 23423 22}       \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number     \\ \hline
some title here         & value l                     &   \pb{12341 538768 \\ 23423 22}& \pb{12341 538768 \\ 23423 22}  & \pb{12341 538768 \\ 23423 22}      \\ \hline
\end{tabular}
\caption{There should be proper caption.}
\end{table}

\end{document}

What I am trying to do now is to make it more readable. In order to do so I wanted to make some of the lines thicker that the other. The problem is that I want the thickness to be changeable within table, which is a bit harder to achieve. Here is an exemplary look of the table:

enter image description here

Is there any easy way to achieve this?

6
  • 1
    One key to readability of tables is avoiding vertical lines. The documentation of booktabs has some nice explanations. Right now, this table looks a bit like sieve on an LSD trip.
    – Johannes_B
    Commented Jan 27, 2015 at 22:29
  • 1
    A bit less drastic, chat.stackexchange.com/transcript/41?m=14647777#14647777
    – Johannes_B
    Commented Jan 27, 2015 at 22:31
  • :-) Well this table is ineed unreadable and looks ugly, but the table i presented is one third of the actual table and i want to use bold lines to separate each part, so the data is exposed better, so the screen is just an example so that I can modify the code to my own needs, because doing it from scratch is a bit too hard for me.
    – Max
    Commented Jan 27, 2015 at 22:46
  • 1
    removing the lines is probably an improvement but if you want thick and thin an easy way is to use || for thick vertical and \hline\hline for thick horizontal, setting \setlength\doublerulesep{0pt} so they make a thick rule rather than a double rule Commented Jan 27, 2015 at 22:46
  • 1
    The tabu package, about which I know next to nothing, can do mixed line thickness. See tex.stackexchange.com/questions/223329/… Commented Jan 28, 2015 at 0:22

2 Answers 2

3

Here is a solution, using the \Xhline and \Xcline commands from makecell:

\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{makecell}
\renewcommand\cellalign{lc}
\setcellgapes{3pt}
\makegapedcells
\newcommand\thickvrule[1][2pt]{\vrule width #1}

\begin{document}

\begin{table}[htp]
\begin{tabular}{!{\thickvrule}l|l!{\thickvrule}*{2}{l|}l!{\thickvrule}}\Xhline{2pt}
\multicolumn{2}{!{\thickvrule}l!{\thickvrule}}{SOME TEXT HERE} & \multicolumn{3}{l!{\thickvrule}}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{!{\thickvrule}l!{\thickvrule}}{MORE TEXT} & number & number & number \\ \hline
\multicolumn{2}{!{\thickvrule}l!{\thickvrule}}{ANOTHER TEXT} & number & number & number \\ \Xcline{1-2}{1.2pt}\Xcline{3-5}{2pt}
some title here & value &\makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\
\Xcline{1-2}{1.2pt}\Xcline{3-5}{2pt}
\multicolumn{2}{!{\thickvrule}l!{\thickvrule}}{ANOTHER TEXT} & number & number & number \\ \Xcline{1-2}{1.2pt}\Xcline{3-5}{2pt}
some title here & value & \makecell{12341 538768 \\ 23423 228}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \Xcline{1-2}{1.2pt}\Xcline{3-5}{2pt}
\multicolumn{2}{!{\thickvrule}l!{\thickvrule}}{ANOTHER TEXT} & number & number & number \\ \Xcline{1-2}{1.2pt}\Xcline{3-5}{2pt}
some title here & value l & \makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \Xhline{2pt}
\end{tabular}
\caption{There should be proper caption.}
\end{table}

\end{document} 

enter image description here

1

You can do that with {NiceTabular} of nicematrix. In that environment, the key hvlines draws all the rules excepted in the \multicolumn. Morever, nicematrix creates PGF/Tikz nodes under the cells, row and columns of the array. So, it's possible to add whatever rule you want with Tikz. In the following code, I have drawn the thick rules with Tikz after the construction of the tabular.

\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{makecell}
\renewcommand\cellalign{lc}

\usepackage{nicematrix}
\NiceMatrixOptions{cell-space-limits=2pt}

\usepackage{tikz}

\begin{document}

\begin{table}[htp]
\begin{NiceTabular}{lllll}[hvlines]
\multicolumn{2}{l}{SOME TEXT HERE} & \multicolumn{3}{l}{Big title that takes the whole page} \\ 
\multicolumn{2}{l}{MORE TEXT} & number & number & number \\ 
\multicolumn{2}{l}{ANOTHER TEXT} & number & number & number \\ 
some title here & value &\makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\
\multicolumn{2}{l}{ANOTHER TEXT} & number & number & number \\ 
some title here & value & \makecell{12341 538768 \\ 23423 228}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ 
\multicolumn{2}{l}{ANOTHER TEXT} & number & number & number \\ 
some title here & value l & \makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} &
\makecell{12341 538768 \\ 23423 22} \\ 
\CodeAfter
\tikz \draw [very thick] 
            (1-|1) rectangle (9-|6) 
            (1-|3) -- (9-|3) 
            (4-|3) -- (4-|6) 
            (5-|3) -- (5-|6) 
            (6-|3) -- (6-|6) 
            (7-|3) -- (7-|6) 
            (8-|3) -- (8-|6) ;
\end{NiceTabular}
\caption{There should be proper caption.}
\end{table}

Ouput of the above code

You must log in to answer this question.

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