Skip to content
New issue

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

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

Already on GitHub? # to your account

Error if there is an underscore in logo file name #100

Closed
wiesener opened this issue Jun 26, 2019 · 3 comments
Closed

Error if there is an underscore in logo file name #100

wiesener opened this issue Jun 26, 2019 · 3 comments
Labels

Comments

@wiesener
Copy link

If I add a logo file name with underscore it gives error:

File not found:

\T1\textunderscore

@Wandmalfarbe
Copy link
Owner

Pandoc interprets every metadata value as Markdown and converts it to the output format before inserting it in the document. Unfortunately the underscore gets converted to \_. In the template the following LaTeX is produced

\includegraphics[width=120pt, left]{logo\_underscore.pdf}

with the following error message:

Error producing PDF.
! Package pdftex.def Error: File `logo\T1\textunderscoreunderscore.pdf' not fou
nd: using draft setting.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.333 ...[width=120pt, left]{logo\_underscore.pdf}

This is a known and documented behaviour (see jgm/pandoc#3504 or jgm/pandoc#1685).

Raw content to include in the document’s header may be specified using header-includes; however, it is important to mark up this content as raw code for a particular output format, using the raw_attribute extension), or it will be interpreted as markdown. For example:

header-includes:
- |
```{=latex}
\let\oldsection\section
\renewcommand{\section}[1]{\clearpage\oldsection{#1}}
```

You can tell pandoc that you want to pass the metadata value to LaTeX unparsed (as raw LaTeX) so the following code should work:

logo: "`logo_underscore.pdf`{=latex}"

@fohrloop
Copy link

I am having similar issue, but in my case I am trying to add the logo in the command line using

--metadata logo="__assets__/my_logo.png"

The .tex file produced will have

    \includegraphics[width=100pt, left]{\_\_assets\_\_/my\_logo.png}

which does not work. However, if I edit the lines into

    \includegraphics[width=100pt, left]{__assets__/my_logo.png}

the .pdf is produced without errors. I saw there is a workaround when using the YAML metadata in the .md files, but how would one make it work using the command line arguments?

@Wandmalfarbe
Copy link
Owner

I am having similar issue, but in my case I am trying to add the logo in the command line using

--metadata logo="__assets__/my_logo.png"

I don't know how to pass raw latex via the --metadata option. The manual mentions the following:

But unlike --variable, --metadata affects the metadata of the underlying document (which is accessible from filters and may be printed in some output formats) and metadata values will be escaped when inserted into the template.

I think it is worth a question on pandoc-discuss or in the pandoc issue tracker.

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

No branches or pull requests

3 participants