Rmarkdown: how to get yaml scalar untransformed in latex template

Dear community,

I am customizing my latex template to have more optional inputs accessible in the yaml header. I added something like :

myvar: "myvar_value"

When using $myvar$ in my template the content is myvar\_value. Hence when using my_var to store the name of a file, it is not found by tikzpicture.

Is there a way to get the content without any transformation?
Should I reverse the transformation using a latex command and how?

Regards,

jm

For a discussion of a similar problem see this earlier post.

I wrestled with this problem four years ago, and you can find my results here.

It is possible to pass YAML variables to pandoc to be filtered by an external program before begin passed back to pandoc for further processing. This was necessary because while pandocā€™s API exposes a serialization of the abstract syntax tree (AST) that it uses to internally represent the source document or transformation into the target document and allows free access to anything in the yaml fore matter for use in a document template, the functionality to directly access the yaml fields for anything else is suppressed.

At least that was the case then.

You can add a style sheet to be read in with the other YAML fore matter and park the variables there.

Thank you for the feedback.

This is a bit tricky solution and I do not feel knowledgeable enough to use the AST. I am concerned I will hit a wall pretty fast on that path.

I will stick with the yaml part but without any special character that could break my code.

1 Like

I think that's a good plan; I wrestled with it a long time.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.