Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following code works but comes with three errors. Undefined control sequence, missing number, illegal unit of measure. It seems that the redefined \hrulefill is expecting a number to be input but I don't know what or where. Any suggestions would be appreciated.

\documentclass{exam}
\def\hrulefill{\leavevmode\leaders\hrule height 0.1pt \hfill\kern\z}    
\begin{document}    
  Start with text before filling the rest of the line with a line. \hrulefill
\end{document}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

\kern expects a length, so you can use

\documentclass{exam}
\def\hrulefill{\leavevmode\leaders\hrule height 0.1pt \hfill\kern0pt\relax}    
\begin{document}    
  Start with text before filling the rest of the line with a line. \hrulefill
\end{document}

or, using the TeX \z@ (as your code suggests you were trying to do),

\documentclass{exam}
\makeatletter
\def\hrulefill{\leavevmode\leaders\hrule height 0.1pt \hfill\kern\z@}    
\makeatother
\begin{document}    
  Start with text before filling the rest of the line with a line. \hrulefill
\end{document}

Instead of redefining \hrulefull, I'd suggest you to define another command:

\documentclass{exam}
\makeatletter
\def\Hrulefill{\leavevmode\leaders\hrule height 0.1pt \hfill\kern\z@}    
\makeatother
\begin{document}    
  Start with text before filling the rest of the line with a line. \Hrulefill
\end{document}

so you can still use the default \hrulefill.

share|improve this answer
3  
\kern0pt will look for an optional space. Thus \kern0pt␣ or \kern0pt\relax will get a compatible \hrulefill. –  Heiko Oberdiek Sep 17 '13 at 4:40
    
@HeikoOberdiek right. I updated my answer. Thanks. –  Gonzalo Medina Sep 17 '13 at 4:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.