Inline math font size and equations spacing in markdown to pdf conversion using pandoc

733 Views Asked by At

I'm using vim and markdown as an alternative to obsidian. I'm doing the conversion from markdown to pdf using pandoc and I would like to resemble as much as possible the pdf output of obsidian since I like how it looks.

In general I could make both pdf looks almost the same, but, I got two problems, the first is that the inline math font is too big, the second that the spacing before and after an equation is different.

Here are two screenshots, the first one being the pandoc output, the second the obsidian output.

Pandoc pdf output

Obsidian pdf output

To style the pdf I'm using a custom latex snippet which I include with pandoc -H style.tex ... during the pdf compilation, with this I was able to change the spacing between the text and the sections title as well as other things like page margins, etc. But I didn't find anything related to the math nor the equation for a template

I've also tried writing the equation as $\small \vec{E}$ but didn't work.

I think it has to be a way of changing the spacing from the latex template, I know that pandoc is using the unicode-math package to convert the latex equations but didn't find nothing related on how to change the spacing for the equations nor the font size.

EDIT: the style.tex file

% page setup
\usepackage[a4paper,
            top=2cm,
            bottom=1.75cm,
            left=1.75cm,
            right=1.75cm]{geometry}

\usepackage{titlesec}
\usepackage{fontspec}

% inline code (backticks in md)
% taken from https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
\linespread{1.15}
\definecolor{bgcolor}{HTML}{e0e0e0}
\let\oldtexttt\texttt

\renewcommand{\texttt}[1]{
    \colorbox{bgcolor}{\oldtexttt{#1}}
}

% change boldfont bold to extrabold
% \setmainfont[
%  BoldFont={Inter-ExtraBold}
% ]{Inter}

% change regular font to light font
% \setmainfont{Inter light}

\newfontfamily\titlefont{Inter}[
UprightFont     =   *-Regular,
BoldFont        =   *-ExtraBold,
]

\newfontfamily\sectionsfont{Inter}[
UprightFont     =   *-Regular,
BoldFont        =   *-SemiBold,
]

\titleformat{\section}
{\titlefont\huge\bfseries}
{}
{0em}
{}

\titleformat{\subsection}
{\sectionsfont\LARGE\bfseries}
{}
{0em}
{}

\titleformat{\subsubsection}
{\sectionsfont\Large\bfseries}
{}
{0em}
{}

\titleformat{\paragraph}
{\sectionsfont\large\bfseries}{\theparagraph}{1em}{}

\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\titlespacing*{\subsubsection}
{0pt}{2.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\titleformat{\subparagraph}
{\normalfont\large\bfseries}{\theparagraph}{1em}{}

\titlespacing*{\subparagraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

EDIT2: this is the .tex output part showed in the screenshot taken from:

pandoc --pdf-engine=xelatex file.md -o file.tex

eléctrica que efectúa el campo sobre la partícula. se puede calcular entonces como:

\[\frac{w_{a \rightarrow b}}{q_{0}} = - \int_{a}^{b} \vec{e} \cdot d\vec{l} = v_{b} - v_{a} = v_{ab}\]

donde \({q_{0}}\) es una pequeña carga puntual, \(v_{a}\) y \(v_{b}\) el potencial por unidad de carga de los puntos \(a\) y \(b\) respectivamente, \(\vec{e}\) el valor del campo eléctrico 
0

There are 0 best solutions below