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

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

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

Post by r2997790 »

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/MTcADABg (.tex file)
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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

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

Post by Ijon Tichy »

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.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply