I am writing a pair of Pandoc template and LaTeX package(s) for my authoring workflow (write in Markdown, produce PDF through Pandoc->LaTeX). In the Markdown document the type of document can be selected, and consequently different document classes can be loaded (book, report, article, presentation, or letter classes).
Unfortunately I can't make Pandoc dynamically adjust the mapping of heading levels to LaTeX commands. So the intermediate LaTeX file will always have \section{}
as first-level headings, \subsection{}
as second level etc., as it is appropriate for an article class.
What I can do in a Pandoc template is conditionally execute LaTeX commands, so the suggestion was to remap the LaTeX sectioning commands appropriately. My question is: is it possible to "remap" all sectioning commands or do I have to "recreate" them by copying their original definition?
If I do
\renewcommand{\chapter}[1]{\part{#1}}
it seems to correctly shift chapters to become parts. However, if I do
\renewcommand{\chapter}[1]{\part{#1}}
\renewcommand{\section}[1]{\chapter{#1}}
both sections and chapters end up being parts. I can see why this happens, as \section
is mapped to \chapter
which is already a \part
(the order of the two commands doesn't seem to make a difference, which is what I hoped for).
What is the best (only?) way of shifting all heading levels by a fixed number of levels?
\let\originalchapter\chapter \renewcommand\chapter{\part} \let\originalsection\section \renewcommand\section{\originalchapter}
But that's not the way of doing this, probably. – Manuel Jan 12 '18 at 9:21