Here's my code:

\ul{\Huge\textbf{Some text}}
\underline{\Huge\textbf{Some text \hspace{1in}}}
\ul{\Huge\textbf{Some text \hspace{1in}}} % This line causes error

The command \underline{\Huge\textbf{Some text \hspace{1in}}} produces the result

enter image description here

I want the underline to be thicker though, so I tried using the soul package, setting the thickness, and then \ul{Some text}

This gives me the desired underline thickness

enter image description here

The problem occurs when I try to combine the two to get a thick line extending beyond the text. The command \ul{\Huge\textbf{Some text \hspace{1in}}} produces an error, "Missing number, treated as zero."

Any ideas why or how to fix it? Or better ways of underlining text with a bold line that extends an arbitrary distance beyond the text?

| improve this question | | | | |
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Apr 12 '15 at 0:03
  • Try \protect\hspace*{1in} – user31729 Apr 12 '15 at 0:08
  • Doing \ul{\Huge\textbf{Some text \protect\hspace{1in}}} fixes the error but cuts the underline off at the end of the text... produces same result as second image above – Philip Apr 12 '15 at 0:14
  • \ul{\Huge\textbf{\mbox{Some text \hspace{1in}}}} – user31729 Apr 12 '15 at 0:18
  • @ChristianHupfer I'm jealous. You knew the answer, I had to look it up in the package manual. :( – R. Schumacher Apr 12 '15 at 0:20

You have to read the fine print in the soul manual http://texdoc.net/texmf-dist/doc/latex/soul/soul.pdf You have to protect with \mbox{}.

\ul{\Huge\textbf{Some text\mbox{\hspace{1in}}}}
| improve this answer | | | | |
  • Great, that worked for me, thanks. I read that doc but didn't realize that line of the table applied. – Philip Apr 12 '15 at 0:22

Without loading any other packages, here's a command that will accomplish this using a rule.




  \aeunderline[2in]{Hello World} and this is what follows.


enter image description here

| improve this answer | | | | |

plain TeX based

A solution with underline based on plain TeX means only:

    \hbox{\textbf{Some text \hspace{1in}}}
    \kern.5ex % space between text and line
    \hrule height 2.5pt % rule thickness


TikZ based

The following example uses TikZ, which offers more options regarding the line style. For example, this version shows round line caps:

    node font=\bfseries,
    inner sep=0pt,
    line width=2.5pt,
    line cap=round, % also decorations, ...
    node (text) {Some text}
    (text.south east) ++(1in, -.5ex) coordinate (tmp)
    -- (text.south west |- tmp)

Result TikZ

| improve this answer | | | | |

Just for completeness of the answers to this question, if you are using luatex, there is an unfinished package that underlines: luauline. (It is usable, it just isn't ready enough for CTAN since it has no documentation and needs a few performance improvements.)

If you download this package and place it in your local TeX tree, you can load it and produce the desired result with the following:

\setluaunderlineheight{2pt}  % set thickness of the underline
\uline{\Huge\textbf{Some text\hspace*{1in}}}
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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