public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* YAML block to carry LaTeX font details -- how do I preserve '{' and ‘}‘ ?
@ 2016-04-09 22:34 kurt.pfeifle via pandoc-discuss
       [not found] ` <6c4977e8-6dca-4d33-a44b-a72a31603e60-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: kurt.pfeifle via pandoc-discuss @ 2016-04-09 22:34 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3670 bytes --]



I am starting to experience with YAML blocks, so that I store as many as 
possible source-specific Pandoc command line options and variables within 
the Markdown source file for easier reproducability at a later stage.

Most things which I currently use work file, except one (which is: 
successfully passing *some* font features into the LaTeX output).

Here is my complete YAML block:

---
title: Some Document
subtitle:
    - This is a test for using YAML for metadata.
author:
    - name: Some Name
      affiliation: University of Somewhere
    - name: Some Other Name
      affiliation: University of Nowhere
date: 2016-04-10
toc: yes
numbersections: yes
toc-depth: 3
geometry:
    - paperwidth=595pt
    - paperheight=842pt
    - showframe=false
    - showcrop=false
    - hmargin=72pt
    - headsep=54pt
    - top=66pt
    - bottom=78pt
author-meta:  "Some Name, Some GmbH"
subject-meta:  "Knowledge-Based Information Extraction"
title-meta:  "Some Phantasy Title"
pdfstartpage: 2
keywords:  "Essay, Important, Difficult"
fontsize: 12pt
lang: de
mainfont: WeidemannBook*mainfontoptions:  BoldFont=WeidemannStd-Bold.otf, ItalicFont=WeidemannBookItalic.otf, BoldItalicFont=WeidemannStd-BoldItalic.otf, ItalicFeatures=Colour=AA0000, BoldFeatures={Colour=0000AA}, BoldItalicFeatures={Colour=AA00AA}
*monofont:  Letter Gothic Std
monofontoptions: [ Scale=0.8, Colour=AA0000, Numbers=Lining, Numbers=SlashedZero, ]
documentclass: scrartcl
header-includes:
...

My problem is with this line:

*mainfontoptions:  BoldFont=WeidemannStd-Bold.otf, ItalicFont=WeidemannBookItalic.otf, BoldItalicFont=WeidemannStd-BoldItalic.otf, ItalicFeatures=Colour=AA0000, BoldFeatures={Colour=0000AA}, BoldItalicFeatures={Colour=AA00AA}*

In LaTeX the output becomes:

\setmainfont[BoldFont=WeidemannStd-Bold.otf,
  ItalicFont=WeidemannBookItalic.otf, 
  BoldItalicFont=WeidemannStd-BoldItalic.otf,
  ItalicFeatures=*\{*Colour=AA0000*\}*,
  BoldFeatures=*\{*Colour=0000AA*\}*,
  BoldItalicFeatures=*\{*Colour=AA00AA*\}*]{WeidemannBook}

This does not compile to PDF and gives this error:

! LaTeX error: "kernel/misplaced-equals-sign"
....
LaTeX is attempting to parse some key-value input but found two equals signs not separated by a comma.

If I remove the backslashes which escape the curly braces, like so:

\setmainfont[BoldFont=WeidemannStd-Bold.otf,
  ItalicFont=WeidemannBookItalic.otf,
  BoldItalicFont=WeidemannStd-BoldItalic.otf,
  ItalicFeatures=*{*Colour=AA0000*}*,
  BoldFeatures=*{*Colour=0000AA*}*,
  BoldItalicFeatures=*{*Colour=AA00AA*}*]{WeidemannBook}

then the code compiles and works as expected — I get different colors for 
bold, italic and bold-italic text:

<https://lh3.googleusercontent.com/-rI8n718kiu8/VwmBiyHwHiI/AAAAAAAAAiY/FEjuI3w6YDwCfgEW65d-VRn_DkorZO6Xw/s1600/1.png>

How can I get the required curly braces into the LaTeX output un-escaped 
from setting it up in the YAML block?

Or is there an alternative way to get my wanted main font `*Features` to 
work?

Thanks, Kurt
​

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6c4977e8-6dca-4d33-a44b-a72a31603e60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 13803 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: YAML block to carry LaTeX font details -- how do I preserve '{' and ‘}‘ ?
       [not found] ` <6c4977e8-6dca-4d33-a44b-a72a31603e60-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2016-04-10  2:39   ` John MacFarlane
       [not found]     ` <20160410023930.GA96031-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2016-04-10  2:39 UTC (permalink / raw)
  To: kurt.pfeifle via pandoc-discuss

See BP Johnson's suggestions (recently in this list) about
using a dummy latex macro to protect text from being
interpreted as Markdown.

+++ kurt.pfeifle via pandoc-discuss [Apr 09 16 15:34 ]:
>   I am starting to experience with YAML blocks, so that I store as many
>   as possible source-specific Pandoc command line options and variables
>   within the Markdown source file for easier reproducability at a later
>   stage.
>
>   Most things which I currently use work file, except one (which is:
>   successfully passing some font features into the LaTeX output).
>
>   Here is my complete YAML block:
>---
>title: Some Document
>subtitle:
>    - This is a test for using YAML for metadata.
>author:
>    - name: Some Name
>      affiliation: University of Somewhere
>    - name: Some Other Name
>      affiliation: University of Nowhere
>date: 2016-04-10
>toc: yes
>numbersections: yes
>toc-depth: 3
>geometry:
>    - paperwidth=595pt
>    - paperheight=842pt
>    - showframe=false
>    - showcrop=false
>    - hmargin=72pt
>    - headsep=54pt
>    - top=66pt
>    - bottom=78pt
>author-meta:  "Some Name, Some GmbH"
>subject-meta:  "Knowledge-Based Information Extraction"
>title-meta:  "Some Phantasy Title"
>pdfstartpage: 2
>keywords:  "Essay, Important, Difficult"
>fontsize: 12pt
>lang: de
>mainfont: WeidemannBook
>mainfontoptions:  BoldFont=WeidemannStd-Bold.otf, ItalicFont=WeidemannBookItalic
>.otf, BoldItalicFont=WeidemannStd-BoldItalic.otf, ItalicFeatures=Colour=AA0000,
>BoldFeatures={Colour=0000AA}, BoldItalicFeatures={Colour=AA00AA}
>monofont:  Letter Gothic Std
>monofontoptions: [ Scale=0.8, Colour=AA0000, Numbers=Lining, Numbers=SlashedZero
>, ]
>documentclass: scrartcl
>header-includes:
>...
>
>   My problem is with this line:
>mainfontoptions:  BoldFont=WeidemannStd-Bold.otf, ItalicFont=WeidemannBookItalic
>.otf, BoldItalicFont=WeidemannStd-BoldItalic.otf, ItalicFeatures=Colour=AA0000,
>BoldFeatures={Colour=0000AA}, BoldItalicFeatures={Colour=AA00AA}
>
>   In LaTeX the output becomes:
>\setmainfont[BoldFont=WeidemannStd-Bold.otf,
>  ItalicFont=WeidemannBookItalic.otf,
>  BoldItalicFont=WeidemannStd-BoldItalic.otf,
>  ItalicFeatures=\{Colour=AA0000\},
>  BoldFeatures=\{Colour=0000AA\},
>  BoldItalicFeatures=\{Colour=AA00AA\}]{WeidemannBook}
>
>   This does not compile to PDF and gives this error:
>! LaTeX error: "kernel/misplaced-equals-sign"
>....
>LaTeX is attempting to parse some key-value input but found two equals signs not
> separated by a comma.
>
>   If I remove the backslashes which escape the curly braces, like so:
>\setmainfont[BoldFont=WeidemannStd-Bold.otf,
>  ItalicFont=WeidemannBookItalic.otf,
>  BoldItalicFont=WeidemannStd-BoldItalic.otf,
>  ItalicFeatures={Colour=AA0000},
>  BoldFeatures={Colour=0000AA},
>  BoldItalicFeatures={Colour=AA00AA}]{WeidemannBook}
>
>   then the code compiles and works as expected — I get different colors
>   for bold, italic and bold-italic text:
>
>   [1][1.png]
>
>   How can I get the required curly braces into the LaTeX output
>   un-escaped from setting it up in the YAML block?
>
>   Or is there an alternative way to get my wanted main font `*Features`
>   to work?
>
>   Thanks, Kurt
>   ​
>
>   --
>   You received this message because you are subscribed to the Google
>   Groups "pandoc-discuss" group.
>   To unsubscribe from this group and stop receiving emails from it, send
>   an email to [2]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [3]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [4]https://groups.google.com/d/msgid/pandoc-discuss/6c4977e8-6dca-4d33-
>   a44b-a72a31603e60%40googlegroups.com.
>   For more options, visit [5]https://groups.google.com/d/optout.
>
>References
>
>   1. https://lh3.googleusercontent.com/-rI8n718kiu8/VwmBiyHwHiI/AAAAAAAAAiY/FEjuI3w6YDwCfgEW65d-VRn_DkorZO6Xw/s1600/1.png
>   2. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   3. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   4. https://groups.google.com/d/msgid/pandoc-discuss/6c4977e8-6dca-4d33-a44b-a72a31603e60-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   5. https://groups.google.com/d/optout

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20160410023930.GA96031%40MacBook-Air-2.local.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: YAML block to carry LaTeX font details -- how do I preserve '{' and ‘}‘ ?
       [not found]     ` <20160410023930.GA96031-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
@ 2016-04-10  5:14       ` John MacFarlane
       [not found]         ` <20160410051448.GB2108-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2016-04-10  5:14 UTC (permalink / raw)
  To: kurt.pfeifle via pandoc-discuss

+++ John MacFarlane [Apr 09 16 19:39 ]:
>See BP Johnson's suggestions (recently in this list) about

BP Jonsson, I mean!
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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: YAML block to carry LaTeX font details -- how do I preserve '{' and ‘}‘ ?
       [not found]         ` <20160410051448.GB2108-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
@ 2016-04-10 10:42           ` kurt.pfeifle via pandoc-discuss
       [not found]             ` <2222a182-2c72-4c59-935a-feb01e091299-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: kurt.pfeifle via pandoc-discuss @ 2016-04-10 10:42 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3585 bytes --]



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.
What I did first (cul-de-sac, not working!) 

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...

...

What I did next (final solution) 

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.
Another question… 

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?
​

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/2222a182-2c72-4c59-935a-feb01e091299%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 17313 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: YAML block to carry LaTeX font details -- how do I preserve '{' and ‘}‘ ?
       [not found]             ` <2222a182-2c72-4c59-935a-feb01e091299-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2016-04-24  0:57               ` Rick Dooling
  0 siblings, 0 replies; 5+ messages in thread
From: Rick Dooling @ 2016-04-24  0:57 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3982 bytes --]

I don't know. Maybe I'm a simpleton but I would just edit the latex 
templates. I have lots of them. Then you keep your source file clean.

Rick

On Sunday, April 10, 2016 at 5:42:50 AM UTC-5, kurt.p...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org 
wrote:
>
> 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.
> What I did first (cul-de-sac, not working!) 
>
> 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...
>
> ...
>
> What I did next (final solution) 
>
> 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.
> Another question… 
>
> 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?
> ​
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b9af327d-6e18-4625-b3de-dbf8702e4d6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 16856 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-24  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-09 22:34 YAML block to carry LaTeX font details -- how do I preserve '{' and ‘}‘ ? kurt.pfeifle via pandoc-discuss
     [not found] ` <6c4977e8-6dca-4d33-a44b-a72a31603e60-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-04-10  2:39   ` John MacFarlane
     [not found]     ` <20160410023930.GA96031-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
2016-04-10  5:14       ` John MacFarlane
     [not found]         ` <20160410051448.GB2108-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
2016-04-10 10:42           ` kurt.pfeifle via pandoc-discuss
     [not found]             ` <2222a182-2c72-4c59-935a-feb01e091299-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-04-24  0:57               ` Rick Dooling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).