When using the doi package with tikzposter, I get the following error when compiling with pdflatex:

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

l.4 \HyperFirstAtBeginDocument

However, if I kill the failed compilation and run pdflatex a second time without deleting the *.aux file then it compiles successfully.

Is this a known conflict, and is there any way to fix this so that it compiles the first time? Thanks in advance for your help.


  • 2
    doi is not involved other than it loads hyperref you get the same error if you change doi to hyperref in the above – David Carlisle May 16 '16 at 15:18

Looks like a hyperref or tikz bug (not fully tracked it down) but you can do this:




The additional line should be the last thing in the preamble, just before \begin{document}

|improve this answer|||||
  • 1
    tikzposter adds \begin{tikzpicture} to \AtBeginDocument and \end{tikzpicture} to \AtEndDocument and so introduce a group. Not quite sure if this is a good idea ... – Ulrike Fischer May 16 '16 at 15:48
  • 2
    @UlrikeFischer oh excellent, thanks! that means it's a tikz bug not a hyperref one, so I don't have to fix it:-) – David Carlisle May 16 '16 at 15:55
  • ; -). Imho there is somewhere here a discussion regarding environments in begin/end document but can't look now, I'm off to dinner... – Ulrike Fischer May 16 '16 at 16:08

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.