12

I can successfully produce the images when output is HTML, but errors out when attempting pdf output.

input file text for image,

  ![](images\icon.png "test")

Error produced,

pandoc: Error producing PDF from TeX source. ! Undefined control sequence. images\icon

l.535 \includegraphics{images\icon.png}

4

2 回答 2

28

Note that pandoc produces the PDF via LaTeX, as the error message reveals. Your input

![](images\icon.png "test")

is converted into LaTeX

\includegraphics{images\icon.png}

\ in LaTeX has a special meaning: it begins a control sequence. So LaTeX is looking for an \icon command here and not finding it. The fix is to use a forward slash / instead of a backslash \ as path separator. LaTeX allows you to use / for paths even in Windows.

Of course, this may cause problems in some other output formats. I suppose I should change pandoc to convert backslashes in paths to forward slashes when writing LaTeX.

于 2013-07-26T03:18:17.577 回答
1

I've had a similar problem on Windows. My images are stored in a subdirectory named "figures". No matter what I tried the path wasn't followed. I have solved it by including --resource-path=.;figures in the call to pandoc.

于 2018-09-06T10:45:58.887 回答