On Sunday, April 10, 2016 at 7:15:02 AM UTC+2, John MacFarlane wrote:
+++ John MacFarlane [Apr 09 16 19:39 ]:
>See BP Johnson's suggestions (recently in this list) about
BP Jonsson, I mean!
Well — and in my OP I meant to say I started to experiment (not to experience)… :-)
I'm referring to the technique of defining a macro like
\newcommand{\wrap}[1]{#1}
and using it to wrap things that you don't want pandoc
interpreting as Markdown.
At first I did not understand at all how I should apply this advice to my situation… However, thanks to this tipp and some more experimentation on my part, I found a solution. I’ll document it here in case someone else finds it useful too.
I created a file named wrapmarkdown.tex with this content:
\makeatletter
\newcommand{\wrapmarkdown}[1]{#1}-
\makeatother
and included it as a parameter into my Pandoc command: -H wrapmarkdown.tex
.
Into my YAML block I put this modification:
mainfontoptions: \wrapmarkdown{BoldFont=WeidemannStd-Bold.otf, ItalicFont=WeidemannBookItalic.otf, BoldItalicFont=WeidemannStd-BoldItalic.otf, ItalicFeatures={Colour=AA0001}, BoldFeatures={Colour=0000
This ended up with a LaTeX output containing this code around line 17:
\setmainfont[\wrapmarkdown{BoldFont=WeidemannStd-Bold.otf,
ItalicFont=WeidemannBookItalic.otf, BoldItalicFont=WeidemannStd-BoldItalic.otf,
ItalicFeatures={Colour=AA0001}, BoldFeatures={Colour=0000AA},
BoldItalicFeatures={Colour=AA00AA}}]{WeidemannBook}
and this code around line 107:
\makeatletter
\newcommand{\wrapmarkdown}[1]{#1}
\makeatother
When compiling this to PDF, an error occurred:
! Undefined control sequence.
<argument> ...st ,\l__fontspec_fontopts_clist ,\wrapmarkdown
{BoldFont=WeidemannStd-Bol...
...
The error message made me move the snippet from around line 107 to lines 2-4 of my generated LaTeX file. The output PDF was created successfully after this modification.
Therefore I ditched the inclusion of my wrapmarkdown.tex file via the -H
/--include-in-header
command line parameter.
Instead I hard-coded the respective lines into a custom LaTeX template, right after its initial lines, and added --template=my-custom-latex-template.latex
into the command line.
I assume there is no way to make -H
include a code snippet at a specific spot in the LaTeX header? The problem with my original approach seems to have been that on line 17 the call to the \wrapmarkdown
newcommand came before its definition on line 107… and that the only workaround was the one I used: to hard-code it into the LaTeX-template at an earlier line?
Would it be feasible to add a variable-based approach into the default Pandoc template, which could be utilized from the command line for cases like this?