[Tex/LaTex] place \includegraphics command before \begin{document}


Can I place \includegraphics command before \begin{document}? I see in sharelatex they are doing like that but in texstudio I am writing the same code but I get the error.

Best Answer

Display of graphics or Text/tables, showing page numbers/headers etc. i.e. anything which is really connected with text etc. is typesetting.

Typesetting is not possible with LaTeX before \begin{document}.

If text/content is to be stored, either in boxes or a wrapper macro, this can be done of course, see the \blindtext command from blindtext package, which is definitely stored before \begin{document} (since it's in a package), but you can't use \blindtext before \begin{document} directly.

The example videos provided in the link show basically


The \title{#1} macro is effectively doing this\gdef\@title{#1}, i.e. using another macro to store the content, designed to be used by \maketitle later on.