11

I'm using longtable to typeset a glossary.

When microtype is enabled, it starts looking wrong as the first line of wrapped text in a cell gets shifted to the right. MWE:

\documentclass{article}
\usepackage{array}
\usepackage{microtype}

\begin{document}

\begin{tabular}{@{}
    >{\raggedleft\arraybackslash}p{3cm}
    >{\raggedright\arraybackslash}p{6cm}
    @{}}
    MWE: & \emph{Why} does microtype break this table? \emph{Why} does microtype break this table? \emph{Why} does microtype break this table? \\
\end{tabular}

\end{document}

Results in this:

result of above code. bad.

If I comment out \usepackage{microtype} above, it looks good:

enter image description here

it also happens without the \emph, I've just been testing various texts and this example makes the issue particularly noticeable.

This is pdflatex from texlive 2024.2

Why is this happening and how can I fix it?

Edit: I'm now working around this by disabling microtype for the table as per this Answer

2
  • 2
    Interesting. This is unrelated to longtable: the issue occurs also with a simple tabular. It's an interaction between array and microtype.
    – campa
    Apr 18 at 11:46
  • Thanks for finding out, I updated the MWE and removed the longtable tag. Apr 19 at 13:04

1 Answer 1

10

microtype can not apply the left protrusion in the first line. But you could add it manually:

\documentclass{article}
\usepackage{array}
\usepackage{microtype}

\begin{document}

\begin{tabular}{@{}
    >{\raggedleft\arraybackslash}p{3cm}
    >{\raggedright\arraybackslash}p{6cm}
    @{}}
    MWE: & \leftprotrusion\emph{Why} does microtype break this table? \emph{Why} does microtype break this table? \emph{Why} does microtype break this table? \\
\end{tabular}

\end{document}

enter image description here

2
  • 1
    Do you know some more details on why it cannot do this automatically? Is there a way to fix it without add \leftprotrusion to every cell? Apr 18 at 13:56
  • 1
    @Gamification The problem is that in tables, tex expands macros at the beginning of cells, so microtype doesn't recognise the original \emph. I'll see what can be done. (For now, {\em Why} would also work, with less keystrokes.)
    – Robert
    Apr 20 at 22:32

You must log in to answer this question.

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