## LaTeX forum ⇒ General ⇒ [HELP] LaTeX Error: Two \documentclass or \documentstyle commands

LaTeX specific issues not fitting into one of the other forums of this category.
r2997790
Posts: 5
Joined: Sat Aug 24, 2019 12:10 pm

### [HELP] LaTeX Error: Two \documentclass or \documentstyle commands

Hi everyone,

I am getting an odd error and despite reinstalling pandoc and miktex is is still occuring.

LaTeX Error: Two \documentclass or \documentstyle commands.

I only have one \documentclass but this error continues.

Here's my code and I'm compiling it with:

pandoc sample_1.md -f gfm -H format.tex -o output.pdf

https://pastebin.com/BiB6EPKb (.md file)

This script works fine until I add in the \documentclass.

Does anyone know how to fix this error, it is driving me nuts. I've spent ages trying to find a way to fix it.

Thanks!

Ijon Tichy
Posts: 92
Joined: Mon Dec 24, 2018 10:12 am
This is a little bit off-topic, because it is not really a LaTeX question but a Pandoc question and I'm not really a Pandoc user. However, with option -H you add a file to the end of the header pandoc already uses. AFAIK pandoc already adds a \documentclass to the header before loading the given files. So you have two. BTW: \begin{document}…\end{document} also should not be part of the header file, because after this environment LaTeX finishs its work and therefore the text of the Github markdown file will not be processed any longer.

To change the document class or class options you should change variables like documentclass or classoption either of the used template or via option -V or via YAML. See Variables for LaTeX in the Pandoc Manual.