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

Latex \graphicspath not honored consistently, if at all. #736

Closed
DavidGriffith opened this issue Feb 4, 2013 · 9 comments
Closed

Latex \graphicspath not honored consistently, if at all. #736

DavidGriffith opened this issue Feb 4, 2013 · 9 comments

Comments

@DavidGriffith
Copy link

If I add \graphicspath{{images/}{otherimages/}} to the preamble of a Latex document, this tells Latex to look in the specified directories for images when processing \includegraphics{foo.png}. I attempted to compile a document which contains five images to EPUB. Pandoc complained like this about the fifth file:

pandoc: ././pic5.png: openBinaryFile: does not exist (No such file or directory)

Pandoc complained similarly with this test file, but complained about the first image file instead. No EPUB file was generated in either case.

\documentclass{article}
\usepackage{graphicx}
\graphicspath{{images/}{otherimages/}}
\begin{document}
\includegraphics{pic1.png}
\includegraphics{pic2.png}
\includegraphics{pic3.png}
\includegraphics{pic4.png}
\includegraphics{pic5.png}
\end{document}
@mpickering
Copy link
Collaborator

This shouldn't be too difficult to implement.

@cpence
Copy link

cpence commented Dec 4, 2016

Is there any way to reproduce this functionality otherwise? I keep all of my images for lecture slides in a central location, and so really need to get something like this working.

For example, can I tell Pandoc to not even try to open up images itself? If it'd just spit the image path out into the TeX file without trying to check it first, it'd work when TeX built the PDF.

@jgm
Copy link
Owner

jgm commented Dec 4, 2016

@cpence In general pandoc does need to find the images, which might not even be coming from the file system (for example, if you're starting with a docx or epub, the images will be in the zip container).

Currently when an image is not found, we substitute a placeholder (the emphasized alt text). It would be possible just to leave the Image node in there, and in some cases this might work (e.g. if you have an appropriate \graphicspath in your latex template). Is that what you're proposing? I worry that it might break things for other users, though.

@jgm
Copy link
Owner

jgm commented Dec 4, 2016

@cpence You can always create a small Makefile or script that uses pandoc to create a tex file, then runs pdflatex or xelatex on that to get a PDF. If you do this, it will leave the paths.

@cpence
Copy link

cpence commented Dec 4, 2016

That does it, thanks! For anyone else with this issue who's converting from Markdown to TeX, a perfect workaround is:

pandoc -t beamer $IN_MARKDOWN --standalone -o $OUT_TEX
latexmk $OUT_TEX
latexmk -c $OUT_TEX
rm $OUT_TEX

(Obviously the \graphicspath support would be great for converting from TeX. And if it were implemented there, perhaps Pandoc could also scan the template files looking for \graphicspath options as well. But this workaround does great.)

@uetchy
Copy link

uetchy commented Dec 27, 2016

This issue breaks TeX to HTML convertion with flag --self-contained.
It would be great if pandoc can directly parse \graphicspath 👍

@jgm
Copy link
Owner

jgm commented Dec 27, 2016 via email

@gianarb
Copy link

gianarb commented Jan 16, 2017

Hello!
I am converting a Latex to Epub with pandoc but this problem is blocking me. \graphicspath is not working and I have back.

20:51 $ pandoc from-zero-to-ready.tex -o from-zero-to-ready.epub
pandoc: Could not find media `the-fundamentals', skipping...
pandoc: Could not find media `virtualization', skipping...
pandoc: Could not find media `engine', skipping...
pandoc: Could not find media `ifconfig', skipping...
pandoc: Could not find media `iptables', skipping...

I am using latexmk to create the pdf and it's working.
Do you have some advice?

@jgm jgm modified the milestone: pandoc 2.0 Jan 25, 2017
@jgm
Copy link
Owner

jgm commented Feb 7, 2017

Proposal for dealing with this issue:

  • add something to CommonState for "imagePaths"
  • have the latex reader update this when it sees a graphicspath command
  • have fetchItem use this for a search path (perhaps only for images?)

This would thread everything through the PandocMonad machinery, so graphicspath wouldn't leave a trace in the document metadata, or would we need to add it to WriterOptions.

@jgm jgm closed this as completed in 0448b7d Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants