3

I use pandoc to render .pdf files from markdown. Example input:

#Fudamental matrix
##Epipolar constraint in pixels

(@) $$(K_{0}^{-1}x)^{T}E(K_{1}^{-1}x')=0$$

(@) $$x^{T}((K_{0}^{-1})^{T}EK_{1}^{-1})x'=0$$

(@fundam) $$x^{T}F x'=0$$

Which renders my equations with the following numbers: (1), (2), (3). I would like to have: (1.1), (1.2), (1.3), where the first number is the chapter nr, or even (1.1.1), (1.1.2), etc. with subchapters numbers as well.

I have a file templateAdd.tex with:

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

I have tried adding the following to the file:

\usepackage{amsmath}
\renewcommand{\theequation}{\thechapter--\arabic{equation}}

as described here, but this does not change the number rendering at all- it's still (1), (2), etc.

My pandoc call:

pandoc -s --mathjax --highlight-style pygments --number-sections --include-in-header   templateAdd.tex -o output\output.pdf -c style_print.css background.md 
4gn3s
  • 133
  • 4

2 Answers2

4

This is happening because pandoc is interpreting (@) signs as list markers, specifically an ordered list enclosed in parentheses. As can be seen if you inspect the latex output of pandoc:

Input:

(@) $$(K_{0}^{-1}x)^{T}E(K_{1}^{-1}x')=0$$

Output:

\begin{enumerate}
\def\labelenumi{(\arabic{enumi})}
\item
  \[(K_{0}^{-1}x)^{T}E(K_{1}^{-1}x')=0\]
\end{enumerate}

To get your desired numbering you will have to turn your formulas into latex equations. You can achieve this by using some inline latex in your markdown like this:

\begin{equation}
(K_{0}^{-1}x)^{T}E(K_{1}^{-1}x')=0
\end{equation}

and in your templateAdd.tex add the line:

\numberwithin{equation}{section}

you can change section to subsection or subsubsection to get (1.1) (1.1.1) or (1.1.1.1) numbering style.

2

An alternative is to use the pandoc-eqnos filter, which processes attributed formulas. e.g.,

$$ (K_{0}^{-1}x)^{T}E(K_{1}^{-1}x')=0 $$ {#eq:foo}

When pandoc's output format is set to LaTeX or pdf, attributed formulas are converted by pandoc-eqnos to numbered LaTeX equations. The equation may be referenced as Eq. @eq:foo.

To get the numbering style you want, you still need to put

\numberwithin{equation}{section}

in your LaTeX template and change section to subsection or subsubsection to get (1.1) (1.1.1) or (1.1.1.1) numbering style.

tjd
  • 21