I have a document which has a right aligned two line header. Said header is created using scrlayer-scrpage. When I also try to enable the microtype package the two lines do not line up at the right and the second line is shifted a bit to the left. A minimal working example is provided below:

% !TeX TS-program = lualatex


\setkomafont{pagehead}{\normalfont} % reset \slshape

| Test ()\\
| Test ()%

    | Test ()\\
    | Test ()%

This occurs in PDFLaTeX, XeLaTeX and LuaLaTeX as far as I can tell. Removing the line which changes the font for the head does not remove the issue though it is far less noticeable. The lua-visual-debug packages helps visualize the boxes a bit better.

Strangely the error does not occur in the body. For now I could revert to getting along without the microtype package though if it is an error on my side I would like to get it fixed and if it is a bug inside the microtype or scrlayer-scrpage I would like to report a bug to help them fix it.

misaligned lines in header

1 Answer 1


There's no error on your part, but it's not a bug either. The misalignment is due to the fact that scrlayer-scrpage inserts a \strut at the end of the header (to ensure uniform line spacing), which prevents microtype (or rather the respective engine) from seeing the end-of-line. There are two possible workarounds:

  • Either disable protrusion in the first line, too, by inserting a strut:

    | Test ()\strut\\
    | Test ()%
  • Or reconstruct the protrusion by means of the primitive \rightmarginkern (which is available in all three engines):

        \unvbox\@tempboxa \setbox\@tempboxa=\lastbox
    | Test ()\\
    | Test (\protruderight{)}%

[luatex offers the primitive \protrusionboundary, which is supposed to simplify this, but I actually couldn't get it to work -- even the example in the doc doesn't seem to work as advertised.]

You must log in to answer this question.

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