When using package colortbl
, the command \hdotsfor
fails (partially), leaving too much white space before and after the dotted part. The mwe
\documentclass{book}
\usepackage{colortbl}
\usepackage{amsmath}
\begin{document}
\[
\begin{pmatrix}
1&a_{11}&\dots&a_{1n}\\
\hdotsfor{4}\\
1&a_{r1}&\dots&a_{rn}
\end{pmatrix} = r.
\]
\end{document}
produces
Removing the package colortbl
makes everything right:
I understand this may be related to \leader
s and/or glue, which are explicitly mentioned in colortbl
's documentation, so maybe this is a feature and not a bug.
Question: is there an easy workaround, bar removing colortbl
?
Best Answer
Since
\hdotsfor
is only really designed for the AMS alignments, andcolortbl
colouring doesn't really work for them, I think the simplest is to addto your preamble after loading
amsmath
that makes these stretch withfilll
rather thanfill
glue which means that in the battle of elasticity with thecolortbl
the dots win.If you wanted a version of
\hdotfill
that worked even if there was a colortbl panel behind it then it would require a bit more work.