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

Error when using header-includes in front matter #20

Closed
lgarcin opened this issue Apr 20, 2020 · 3 comments
Closed

Error when using header-includes in front matter #20

lgarcin opened this issue Apr 20, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@lgarcin
Copy link

lgarcin commented Apr 20, 2020

I get an error when I try to convert from markdown to pdf with latex commands defined in header-includes in font matter.

File test.md

---
header-includes: |
    \newcommand{\Ker}{\mathrm{Ker}}
---

# Title

$\Ker$

Command run

codebraid pandoc --from markdown --to pdf test.md -o test.pdf

Error

! LaTeX Error: Command \Ker already defined.

I don't get any error if I try to convert from markdown to markdown with codebraid or when I convert from markdown to pdf directly with pandoc :

pandoc --from markdown --to pdf test.md -o test.pdf
@gpoore
Copy link
Owner

gpoore commented Apr 20, 2020

I believe that direct-to-PDF conversion will internally use --standalone. It looks like any header-includes get duplicated when the output uses --standalone (even for markdown to markdown or markdown to latex). This can also happen under some conditions just using pandoc:

pandoc --from markdown --to markdown test.md --standalone

gives

---
header-includes: |
  ```{=tex}
  \newcommand{\Ker}{\mathrm{Ker}}
  ```
---

```{=tex}
\newcommand{\Ker}{\mathrm{Ker}}
```

Title
=====

$\mathrm{Ker}$

That might be a pandoc bug. If not, I will figure out some way to work around it on the codebraid side.

Using codebraid to convert to an intermediate format like latex or markdown instead of directly to PDF is probably the best workaround for now.

@gpoore
Copy link
Owner

gpoore commented Apr 21, 2020

According to jgm/pandoc#4311, pandoc is performing as expected (even if it seems counterintuitive at times), so this will have to be handled within codebraid.

@gpoore gpoore added the enhancement New feature or request label Apr 21, 2020
gpoore added a commit that referenced this issue Jun 22, 2020
…or Pandoc Markdown to Pandoc Markdown conversions--this prevents includes from being included prematurely and makes roundtrip conversions behave as expected (#20)
@gpoore
Copy link
Owner

gpoore commented Jun 22, 2020

This is fixed now in the dev version on GitHub, and I will release a new version on PyPI soon.

@gpoore gpoore closed this as completed Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants