This code is used to draw these two horizontal rules.

{ \color{red}\hrule width \hsize \kern 1mm }{\color{green}\hrule width \hsize height 1pt}

I need just to color the space between the rules. Any suggestion?


1 Answer 1


\hrule is fairly unusual in that it is a vertical-mode macro. (Actually, it's a TeX "primitive" instruction rather than a macro built on one or more primitives.) As such, your code, viz.,

{\color{red}\hrule width \hsize \kern 1mm }{\color{green}\hrule width \hsize height 1pt}

is equivalent to

{\color{red}\hrule}\kern1mm{\color{green}\hrule height 1pt}

Because \kern1mm is sandwiched between two vertical-mode directives, it is also executed in vertical mode, i.e., it results in 1mm of vertical whitespace being inserted between the two rules (the upper one red, the lower one green). Aside: observe that width \hsize is redundant because the default width of the rule drawn \hrule is \hsize -- the width of the enclosing "vertical box".

To replace the vertical whitespace between the red and green rules with, say, a light-gray rule, it thus suffices to write

{\color{red}\hrule}%  % default height of \hrule is '0.4pt'
{\color{lightgray}\hrule height 1mm }% replacement for "\kern1mm"
{\color{green}\hrule height 1pt}

enter image description here

\setlength\textwidth{3cm} % just for this example
% original expression
{\color{red}\hrule width \hsize \kern 1mm}{\color{green}\hrule width \hsize height 1pt}

% modified, equivalent expression:
{\color{green}\hrule height 1pt}

% replace "\kern1mm" with "{\color{lightgray}\hrule height 1mm}"
{\color{lightgray}\hrule height 1mm}%
{\color{green}\hrule height 1pt}

You must log in to answer this question.

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