I currently have an issue the cause of which I cannot find. On the first page of our document, a weird text which says "pgfcalendar" appears (see picture). pgfcalendar text

Usually I would guess, that this is somehow connected to the wrong usage of a package or something. But in this document pgfcalendar isn't even used. I searched through every .tex file and just can not find it anywhere. The error message is also pretty weird:

LaTeX Error: Can be used only in preamble.

‪/usr/local/texlive/2020/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex, 22‬ You have used a command in the main body of your document which should be used in the preamble. Make sure that \documentclass[…]{…} and all \usepackage{…} commands are written before \begin{document}. Learn more

l.22 \pgfutil@usemodule{pgfcalendar} Your command was ignored. Type I command to replace it with another command, or to continue without it.

Based on the name of the reference path, I would say that it's somehow connected to a local file or directory, which is weird, since no one in the Overleaf project is using separate software.

  • 7
    Without showing any code, you should perhaps provide a crystal ball so that we can guess. ;-) Jokes aside, please build a Minimal Working Example so that people can test your code and find out what's wrong.
    – Miyase
    Jun 22 at 9:33
  • Is that the very first error? Again, it's almost impossible to know what happens without the code, but this error is typical of trying to typeset something in the preamble, and so it should be preceded by a "missing \begin{document}" or something similar. But yeah, my cristall ball is low on batteries...
    – Rmano
    Jun 22 at 9:35
  • It probably has something to do with a command somewhere in the middle of your document related to pgfplots, maybe a package that uses pgfplots in the background, specifically something related to date/time plots. Try to see if you find anything suspicuous that may attempt to load the module in the error mid-document. But it can also be that there is an earlier completely unrelated error that cascades into this error, in that case you need to fix the earlier error first and then this error probably also goes away.
    – Marijn
    Jun 22 at 12:51
  • Do you happen to have a \usepgfplotslibrary{dateplot} after \begin{document}? Jun 22 at 18:20


Browse other questions tagged or ask your own question.