Graphics, Figures & TablesSmall defects in a table, using the hhline package

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small defects in a table, using the hhline package

Post by Cham »

I'm having difficulties in removing a tiny defect in a table output. I'm using the hhline package to built an "Excel-like" table, and here's a part of the code which is the culprit (not a MWE) :

Code: Select all

	\multicolumn{1}{|c|}{Corde 4} & 140 & 20 & 27 & 1 & 1,4 & 0,2 & 1,2 & 0,2 & 0,6 & 0,1 \\ \hline
	\hhline{~~~~~~~b----}
	\multicolumn{7}{r|}{Somme :} & 0,2 & 0,4 & 0,1 & 0,3 \\
	\cline{8-11}
	\end{tabular}
Preview of a part of the table, with a magnification of the problem :
table-defect.jpg
table-defect.jpg (46.17 KiB) Viewed 5536 times
How should I remove these two "holes" ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small defects in a table, using the hhline package

Post by Cham »

Here's a MWE showing my problem :

Code: Select all

\documentclass[10pt,oneside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{hhline}
\usepackage{siunitx}

\begin{document}

\begin{center}
\begin{minipage}{0.975\linewidth}
	\renewcommand{\arraystretch}{1.5}
	\begin{tabular}{l|c|c|c|c|c|c|c|c|c|c|}
	\cline{2-11}
		& \multicolumn{10}{c|}{A title}
		\\ \cline{2-11}
		& \multicolumn{1}{>{\centering}p{3em}|}{$x$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$\Delta x$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$y$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$\Delta y$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$A$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$\Delta A$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$\Delta B$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$\Delta B$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$C$}
		& \multicolumn{1}{>{\centering}p{3em}|}{$\Delta C$}
		\\ \cline{2-11}
		& \multicolumn{2}{c|}{unit}
		& \multicolumn{2}{c|}{unit}
		& \multicolumn{2}{c|}{unit}
		& \multicolumn{2}{c|}{unit}
		& \multicolumn{2}{c|}{unit}
		\\ \hhline{b-|==|==|==|==|==|}
	\multicolumn{1}{|c|}{word 1} & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ \hline
	\hhline{~~~~~~~b----}  % <--- problem here
	\multicolumn{7}{r|}{Sum :} & 11 & 12 & 13 & 14
	\\ \cline{8-11}  % And here
	\end{tabular} \\[10pt]
\end{minipage}
\end{center}

\end{document}
A question by the way : why do I need to load the siunitx package just for this MWE ? Without it, the code doesn't compile, and yet I'm not using any SI units here.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small defects in a table, using the hhline package

Post by Cham »

Also, what is the difference between using \cline{1-11} and \hline ?

I don't see much differences from the output.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Small defects in a table, using the hhline package

Post by Cham »

So, no ideas about my query ? How to fix these small defects ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Small defects in a table, using the hhline package

Post by Stefan Kottwitz »

A quick fix of the corners would be moving the vertical line to the cell where the line is on top and bottom:

Code: Select all

\multicolumn{7}{r}{Sum :} & \multicolumn{1}{|c|}{11} & 12 & 13 & 14
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small defects in a table, using the hhline package

Post by Cham »

Nice one ! Thanks Stefan.

Would it be better to include all the other numbers too ? The code below doesn't work :

Code: Select all

\multicolumn{7}{r}{Sum :} & \multicolumn{4}{|c|c|c|c|}{11 & 12 & 13 & 14}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Small defects in a table, using the hhline package

Post by Stefan Kottwitz »

The numbers should stay in separate cells. If you would use a multi column for all numbers, it would be a single cell, so you would lose the column alignment of the numbers.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Small defects in a table, using the hhline package

Post by Cham »

Thanks.

Now just to be a bit picky : the fixed vertical line has now a very slight offset to the right, relative to the column above it. How to fix this ?
Post Reply