# incompatibility between tikzposter class and microtype package

I've just started using the new tikzposter class (having previously used the fancytikzposter package from the same author) and immediately discovered that using the microtype package causes TeX to fail.

I'm wondering whether anybody else has come across this as I'm not sure what to do. My MWE is:

\documentclass{tikzposter}
\usepackage{microtype}
\begin{document}
%\block{\textls{title}}{text}
\end{document}


The commented out line in the middle is one of the reasons for using microtype, i.e. to get more control over letter spacing. I get the same in pdftex, xetex and lualatex and I'm using a freshly updated TeXlive installation.

The failing error is:

! Missing endcsname inserted.
protect
l.5 \end{document}

?

• This is most certainly a bug. – Henri Menke Mar 16 '14 at 13:02
• Yes, looks like a bug to me as well—any clues as to where to start looking? Having it fail at the \end{document} doesn't provide many clues. – Sam Mason Mar 17 '14 at 9:01

This was a rather tricky one ... I would contend it's a bug in tikzposter.
The problem is that tikzposter uses \AtBeginDocument for starting a tikzpicture environment, which is then closed \AtEndDocument. This means that any other code that a package (in this case microtype) inserts AtBeginDocument is executed inside a group, hence any local assignments will become undone AtEndDocument. Specifically, microtype disables some commands that are only allowed inside the preamble ABD, which triggers the error AED.
The clsguide advises:
The \AtBeginDocument hook should not be used for code that does any typesetting since the typeset result would be unpredictable.
Even though the actual typesetting that tikzposter does is not the real problem here but rather the group that it opens, I would still say that this qualifies as improper use of \AtBeginDocument. tikzposter could instead use the \AfterEndPreamble command from etoolbox (which it loads anyway).
• For reference, the necessary (one-line) patch to tikzposter.cls is described here, but not yet in CTAN. – Christian Clason Feb 8 '16 at 16:29