I am trying to display a coloured \hrule
.
This discussion implies wrapping the \hrule
in a \textcolor
should do, but that adds an ugly extra vertical space above the \hrule
.
Other questions on TeX.SE, such as this, or this, deal with coloring \rule
rather than \hrule
, but \rule
already produces that extra vertical space even without \textcolor
.
MWE with the original \hrule
and two unsuccessful attempts to colour it:
\documentclass{article}
\setlength{\parindent}{0cm}
\usepackage{xcolor}
\begin{document}
abc%
\vskip 1mm%
\hrule
abc%
\vskip 1mm%
\textcolor{red}{\hrule}
abc%
\vskip 1mm%
\rule{\textwidth}{.1mm}
\end{document}
This produces:
I know I could probably use the hack of inserting a negative \vskip
to remove a \baselineskip
offset, but I am looking for a clean way of colouring a \hrule
that does not involve such a workaround.
Best Answer
Try
{\color{red}\hrule}
-- you need the{...}
around\color
etc. to prevent the color leaking into other parts of the document.Edit Here's some improvement