It seems, by using the command \setul{}{ pt} in the soul package, we can change the underline width. But I don't want to use this package. Is there any other command for changing the underline width to an arbitrary size, without using any specific package?

  • Are you wishing to use the native \underline macro, or are you open to other solutions that don't use packages? Does it need to line break? If yes, does it need to hyphenate? – Steven B. Segletes Jul 27 '18 at 14:46
  • 1
    @StevenB.Segletes: Although I prefer to use '\underline' macro, but other suggestions are welcomed. No it dose not need any line break. – Astrolabe Jul 27 '18 at 14:54


Here is \dunderline[<offset of line top>]{<thickness>}{<content>}.

EDIT: I took Harald's suggestion to place the macro inside of a group, since \ooalign changes \lineskiplimit. Without the extra group, the underline can run into the content below on the next line. With the extra group, as shown in the MWE, extra vertical space is inserted to prevent overlap.

\dunderline{1pt}{This is a test}

\dunderline{2pt}{This is a test}

\dunderline[-.5pt]{2pt}{This is a test}

\dunderline[-6pt]{2pt}{This is a test} \lipsum[1]

enter image description here


The magnification is arbitrary, but only between 1x and 2x the original thickness. It performs the result with a double underline. Since an underline is .4pt thick, the 1st parameter offset can only vary between 0pt (1x mag) to .4pt (2x mag).

\underline{This is a normal thickness}

\dunderline[.2pt]{This is 1.5x thickness}

\dunderline{This is 2x thickness}


enter image description here

  • 1
    Should you wrap the \ooalign in a group, perhaps? It sets \lineskiplimit=-\maxdimen, after all. – Harald Hanche-Olsen Jul 27 '18 at 16:52
  • @HaraldHanche-Olsen I didn't know that, so thank you, I will edit. Without it, the dunderline can interfere with what is below. – Steven B. Segletes Jul 27 '18 at 17:02

Of course, soul allows line breaks in underlined material. If you want it, then use soul. But you should avoid underlining altogether.

Otherwise, here's a version that is customizable like for \setul.


  \addtolength{\myuldp}{0.9pt}% clearance
    height -\myuldp
    depth \dimexpr\myuldp+\myulthickness
% initialize



\myul{Abcdefghi} \myul{abcyj}


\myul{Abcdefghi} \myul{abcyj}


\myul{Abcdefghi} \myul{abcyj}


An empty argument in \setmyuldepth uses the whole lowercase alphabet to decide the depth; an empty first argument to \setmyul means “don't change the current value”.

enter image description here

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.