\documentclass{report}
\setcounter{secnumdepth}{5}
\begin{document}
\part{Part}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph}
\subparagraph{Subparagraph}
\end{document}
You can change the formatting of these using the titlesec
package.
I finally need to create a latex custom template. I have other customization needs that can be filled easily with the a custom template.
So, in order to create a latex custom template:
pandoc -D latex > default-template.tex # to store the default template
cp default-template.tex custom-template.tex # to create your own template
Then, edit custom-template.tex
file.
To add headers with a condition, you can do this:
diff --git a/default-template.tex b/custom-template.tex
index 33277c0..629c7a2 100644
--- a/default-template.tex
+++ b/custom-template.tex
@@ -175,9 +175,13 @@ $if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
\date{$date$}
-$for(header-includes)$
-$header-includes$
-$endfor$
+$if(header-includes)$
+\usepackage{fancyhdr}
+\pagestyle{fancy}
+\fancyhead{}
+\fancyhead[RO,RE]{Your header content here}
+\fancyfoot[LO,LE]{Your footer content here}
+$endif$
$if(subparagraph)$
$else$
On the header of your Markdown file:
---
header-includes: yes
---
# Some title
Some content.
Then, generate your PDF using your latex custom template:
pandoc -f markdown -t latex --standalone --template custom-template.tex -o outputfile.pdf inputfile.md
You can go further and report the content of the headers using the latex parameters and YAML meta-data.
$if(header-includes)$
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[$head-options$]{$head-content$}
\fancyfoot[$foot-options$]{$foot-content$}
$endif$
In your Markdown file:
---
header-includes: yes
head-options: RO,RE
foot-options: LO,LE
head-content: Your header content here
foot-content: Your footer content here
---
# Some title
Some content.
I have not tested this last possibility, though. May be you have to protect the string passed from the Markdown's YAML header to LaTeX. To be tested.
Best Answer
With pandoc 1.12.x and it’s new YAML metadata capabilities you could add all the information and all LaTeX-code you need in your markdown document like this:
That way you don't have to modify the template, simply calling
pandoc doc.md -o doc.pdf
will suffice.If you want more control, you can add new metadata like this:
To make this work, you have to modify the template (
pandoc -D latex > template.latex
) accordingly:This is also the place to create a title page. As you can see, the template is nothing but a LaTeX document with some
$variables$
, so it should be easy to customize to your liking.Now just call pandoc with the template option:
pandoc -s -N --template=template.latex doc.md -o doc.pdf
You can find the documentation for templates here: https://pandoc.org/MANUAL.html#templates