Microtype, csquotes active quotes and itemize interaction

csquotesitemizemicrotype

I've met today a bad interaction between microtype, csquotes autoquotes, and the itemize environment, essentially leading to a "forgotten \endgroup" error.

A MWE:

\documentclass{article}

\usepackage{microtype}

\usepackage{csquotes}
\MakeAutoQuote{“}{”}

\begin{document}

\begin{itemize}
\item “foo”
\end{itemize}

\end{document}

Which leads to error:

./document.tex:11: Extra }, or forgotten \endgroup.
<recently read> }
                 
l.11 \item “
              foo”
./document.tex:12: Missing } inserted.
<inserted text> 
                }
l.12 \end{itemize}

I can only reproduce when both packages are loaded and the active quote immediately follows \item (passing an empty optional argument to it does not change things).

Am I missing something, or is this really a bad interaction between the packages? (I'm pretty sure this used to work, but my memory is known to have failed in similar instances…). If it is indeed, I suppose a report is due. I'd gladly do it, but I'm not sure whom to with this. Pointers in that regard are welcome. As is some temporary workaround.

Best Answer

EDIT: This has been fixed in microtype version 3.0a.


Beginning with version 3.0, microtype applies some patches to improve protrusion at "inner margins", e.g. at the beginning of \items (see chapter 9 of the microtype doc). This requires some gymnastics, and here the active character from csquotes interferes. A quick fix would be to prevent the patching with \microtypesetup{nopatch=item}, either for the whole document or only the problematic case. A better fix (which will be included in the next version) would be to patch the pertinent microtype command:

\documentclass{article}

\usepackage{microtype}

\usepackage{csquotes}
\MakeAutoQuote{“}{”}
\usepackage{etoolbox}

\begin{document}

\begin{itemize}
\microtypesetup{nopatch=item} 
  \item “foo” some more text\\ “another quote”
\end{itemize}

\makeatletter 
\patchcmd\MT@get@prot{\noindent}{\noindent\@disablequotes}{}{}
\makeatother
\begin{itemize}
  \item “foo” some more text\\ “another quote”
\end{itemize}

\end{document}

(In a real document, you'd move the \MT@get@prot patch to the preamble, of course.)

output

Related Question