1

I have a command:

  \newcommand{\lineunderscore}{\uline{\hspace*{\fill}}}

But when i try to use this command, i keep getting errors

\documentclass{article}

\usepackage{ulem}

\begin{document}
  \newcommand{\lineunderscore}{\uline{\hspace*{\fill}}}


test\lineunderscore\\test

\end{document}

Like ! Extra }, or forgotten \endgroup., what is my problem ?

1 Answer 1

2

You can't put complicated macros inside \uline I think you wanted

\documentclass{article}

\usepackage{ulem}

\begin{document}
  \newcommand{\lineunderscore}{\uline{\hfill}}


test\lineunderscore\\test

\end{document}

although I would probably use

\documentclass{article}


\begin{document}


test\hrulefill\\test

\end{document}

3
  • Beat me to it! +1. Out of curiosity, why do complicated macros like \hspace not work? (And what makes a macro complicated?)
    – chsk
    May 15, 2021 at 9:37
  • 1
    @chsk a macro is "complicated" in this context if it fails. Actually the real complication is \ulem which is a massively complicated macro trying to do underlining while still allowing normal line breaking and inter-word space stretching, it needs to be able to deconstruct its argument, and rebuild something equivalent but underlined. so putting in anything more than simple letters might work, but generally wit will fail. May 15, 2021 at 9:57
  • Thanks for the explanation! (And that's a rather philosophical definition. I like it.)
    – chsk
    May 15, 2021 at 11:01

You must log in to answer this question.

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