Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.13k stars 959 forks source link

Cannot use `code-block-font-size` from the command line #356

Open nluetts opened 1 year ago

nluetts commented 1 year ago

Hi,

thanks for this great template!

I tried setting the font size in code listings using pandoc's metadata flag:

pandoc ... -o out.tex ... -M code-block-font-size:\\scriptsize

(or other variants using quotes) but this is parsed to the latex template as \textbackslash scriptsize:

% out.tex
...
\lstdefinestyle{eisvogel_listing_style}{
  language         = java,
  numbers          = left,
  xleftmargin      = 2.7em,
  framexleftmargin = 2.5em,
  backgroundcolor  = \color{listing-background},
  basicstyle       = \color{listing-text-color}\linespread{1.0}%
                      \lst@ifdisplaystyle%
                      \textbackslash scriptsize%
                      \fi\ttfamily{},
...

So in the final PDF, it will just say "\scriptsize" above each listing, instead of changing the font size.

It works with a yaml header, but it seems that currently it cannot work from the command line. I am not sure if I am just handling the backslash on the command line wrong, however. I would be grateful for help either way.

tinmarino commented 11 months ago

I had the same problem, I think this is related to pandoc and not pandoc-latex-template.

Quickfix

Use -V code-block-font-size='\tiny' and not -M

Bad (in YAML)

metadata:
  code-block-font-size: \tiny

Good (in command line)

-V code-block-font-size='\tiny'