0

I need to use \uline (or something like it) from the ulem package for a custom command. Sometimes, when I use this custom command (in the mwe I just use \uline), I get a particularly dark, heavy (thick) underlining, compared with the standard.

For potentially relevant context: I'm using LaTeX, compiling with latexmk (via Vimtex), and viewing with Okular.

Why is this happening, and how can I stop it?

The effect is most noticeable with multiple paragraphs. Here it happens in the last line of the second paragraph:

\documentclass{article}

\usepackage{ulem}j

\begin{document}
\uline{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque laoreet lorem nec nulla sagittis, eu molestie lacus rutrum. Sed iaculis, est a faucibus rutrum, lacus lacus pellentesque magna, sed dignissim lorem arcu id est. Duis in convallis est. Duis gravida nisi quis turpis placerat, ut sagittis nunc tempus. Quisque pulvinar lectus nec orci scelerisque, id hendrerit metus tempor. Duis volutpat faucibus posuere. Ut semper turpis varius nibh ultrices luctus. Integer interdum urna vestibulum consectetur tempor. Nunc sed nibh tempus, aliquet erat non, ornare nibh.}

\uline{Donec viverra nec augue vitae commodo. Cras mollis ac sapien in pulvinar. Maecenas viverra ante a blandit tincidunt. Aliquam porta convallis lacus, sed mollis risus venenatis nec. Praesent eget tortor elit. Duis id ultrices lectus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas sapien tellus, posuere ut lacus at, feugiat lobortis purus. Quisque condimentum magna in rutrum iaculis. Duis at justo quis nulla faucibus blandit vitae eu arcu.}

\uline{Donec fringilla vitae nibh nec sagittis. Sed bibendum dictum dolor sed vehicula. Nulla metus massa, sodales ut consectetur id, rhoncus at elit. Donec orci libero, ornare at mi at, congue mattis orci. Aenean laoreet lectus eget risus ornare porttitor. Morbi sagittis in velit et sagittis. Praesent eu hendrerit orci, faucibus iaculis massa. Nam magna lacus, tincidunt vel justo eu, aliquam mollis risus. Fusce facilisis, mauris in porta pellentesque, nisl augue commodo mi, pellentesque rhoncus nibh leo id risus. Aliquam erat volutpat. Vivamus at velit lacinia, mattis massa sed, molestie odio. Phasellus feugiat in elit vitae consectetur. Nullam ullamcorper quam sed vestibulum tempor. Vestibulum vel tempor magna.}
\end{document}

My initial examples included a \renewcommand{\ULdepth}{1.6pt} command (as it was par of my custom command) and in that case I could get the same effect with a single word (though it was less noticable. With the MWE above I can't.

Any help appreciated, thanks!

1
  • 2
    Welcome! I tried and see no effect like you claim. It's probably just a viewer problem. Look at the output at big magnification and you'll see no difference.
    – egreg
    Apr 10 '20 at 21:41
1

I take it you find the thickness (darkness) of the underline varies randomly within a document. I couldn't see the effect for your mwe, but it appeared well using \setlength{\ULdepth}{1.6pt}... But that is just luck! It will be different at every zoom level viewing the document, and it applies to all the rules (drawn lines), including in tabular and above footnotes.

The problem is how the idealized document is rasterized to the output device, perhaps rounding the line thickness to an integer number of pixels. The result depends on the pixel density of the output device/view, and the priorities used by the program preparing the view. If the display tries to place the upper and lower edges of the underline as close to their nominal position as possible, the thickness will vary randomly by one pixel, You see this a lot viewing with xdvi, and probably others. Pdf(la)tex will try to prioritize the line thickness ahead of the precise location, and I can't see any problem viewing the pdf of your sample, even with \ULdepth set.

The hallmark of this problem is that the dark and light lines switch around at each different zoom level, and the problem disappears when you zoom in closely. If you are producing output for a particular printer, it can help to set \ULthickness to an exact multiple of the pixel size of the printer.

Note that you should use \setlength for changing \ULdepth, but \ULthickness is a command that needs redefining

\renewcommand\ULthickness{0.006666667in} % 2 pixels on a 300 dpi printer

It should become a length register in the future since more registers are available on modern TeX engines.

0

Welcome to TeX.SE. My short answer for the your solution could be to use \ULthickness decreasing the value of the thickness 1.3pt (for example) deleting the use of \ULdepth.

\documentclass{article}
\usepackage{ulem}
\renewcommand{\ULthickness}{1.3pt}
\begin{document}
\uline{foo}
\end{document}

enter image description here

...and ...you will have also....

\documentclass{article}

\usepackage{ulem}

\renewcommand{\ULthickness}{1.3pt}
\begin{document}
\uline{Donec fringilla vitae nibh nec sagittis. Sed bibendum dictum dolor sed vehicula. Nulla metus massa, sodales ut consectetur id, rhoncus at elit. Donec orci libero, ornare at mi at, congue mattis orci. Aenean laoreet lectus eget risus ornare porttitor. Morbi sagittis in velit et sagittis. Praesent eu hendrerit orci, faucibus iaculis massa. Nam magna lacus, tincidunt vel justo eu, aliquam mollis risus. Fusce facilisis, mauris in porta pellentesque, nisl augue commodo mi, pellentesque rhoncus nibh leo id risus. Aliquam erat volutpat. Vivamus at velit lacinia, mattis massa sed, molestie odio. Phasellus feugiat in elit vitae consectetur. Nullam ullamcorper quam sed vestibulum tempor. Vestibulum vel tempor magna.}
\end{document}

enter image description here

1
  • That's "increasing", not "decreasing". Changing the thickness makes one-pixel variation of thickness less noticeable, so it can work, but does not fully prevent the variation, which depends on just the final rendering to screen or paper, May 11 '20 at 2:14

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.