Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variables not rendered in LaTex \input #5931

Closed
feffi opened this issue Nov 23, 2019 · 2 comments
Closed

variables not rendered in LaTex \input #5931

feffi opened this issue Nov 23, 2019 · 2 comments

Comments

@feffi
Copy link

feffi commented Nov 23, 2019

Hi, I'm trying to build a modular template for the pandoc/LaTex combination. For what I can see, variables entered in included LaTex files are not rendered. Instead just the name (latex math syntax, because of $...$) is rendered.

Is it possible to render subsequent variables included in subdocuments?

main.md

test: fooBar
main.tex

\documentclass[a4paper]{scrbook}
\begin{document}
A variable should be rendered here twice: $test$
\input{second}
\end{document}
second.tex

$test$
  • Expected output: A variable should be rendered here twice: fooBar fooBar

  • Output: A variable should be rendered here twice: fooBar test

  • Pandoc 2.7.3

  • Command: pandoc --pdf-engine=xelatex --from "markdown+yaml_metadata_block+raw_html" --template=main.tex main.md -o ./main.pdf --resource-path=.:includes:lib:content --verbose

@jgm
Copy link
Owner

jgm commented Nov 24, 2019

I think you're misunderstanding how templates work. Pandoc doesn't actually parse the latex in a latex template. A template is just considered a block of text with some holes in it for variables. Pandoc doesn't pay a bit of attention to what this text is, so when you write \input{second} pandoc simply passes that through verbatim.

What you're looking for is a template partial. This feature has been added to pandoc's template language in version 2.8. This would allow you to do something like:

$second()$

instead of

\input{second}

and it will work the way you want. Upgrade to 2.8 and read the manual section on Templates.

@jgm jgm closed this as completed Nov 24, 2019
@feffi
Copy link
Author

feffi commented Nov 24, 2019

Hello @jgm, thanks for your quick feedback! Really appreciated, I'll try your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants