! LaTeX 錯誤:無法確定 ../images/vi.gif 中圖形的大小(無 BoundingBox)

! LaTeX 錯誤:無法確定 ../images/vi.gif 中圖形的大小(無 BoundingBox)

我已經下載了https://hea-www.harvard.edu/~fine/Tech/vi.html文件使用wget -p -k https://hea-www.harvard.edu/~fine/Tech/vi.html然後運行pandoc --latex-engine=xelatex -o vi.pdf vi.html這個產品 -

pandoc: Error producing PDF from TeX source.
! LaTeX Error: Cannot determine size of graphic in ../images/vi.gif (no Boundin
gBox).

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.884 ...html}{\includegraphics{../images/vi.gif}}

當我使用這個產品時pdflatex(pandoc中的預設乳膠引擎) -pandoc -o vi.pdf vi.html

pandoc: Error producing PDF from TeX source.
! LaTeX Error: Unknown graphics extension: .gif.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.884 ...html}{\includegraphics{../images/vi.gif}}

我還用來wkhtmltopdf https://hea-www.harvard.edu/~fine/Tech/vi.html從網頁連結製作pdf。但是,在wkhtmltopdf解決方案中我無法控制背景顏色。我想製作一個黑白pdf。

答案1

赫伯特密碼並將其放入文件中:

% file: gif2png.tex
% Herbert's code:
% https://tex.stackexchange.com/questions/7602/how-to-add-a-gif-file-to-my-latex-file/7608#7608

\usepackage{epstopdf}

\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{convert gif:#1 png:\OutputFile}
\AppendGraphicsExtensions{.gif}

現在您可以使用以下選項呼叫 pandoc:--pdf-engine-opt=-shell-escape --include-in-header=gif2png.tex

例子:

以這個簡單的 html 檔案為例:

<!-- file: test.html -->
<p>Here is a gif:</p>
<img src="test.gif" title="A dummy picture" alt="The gif" />

還有一個 gif 叫做test.gif

在此輸入影像描述

並運行 pandoc:

pandoc test.html --pdf-engine-opt=-shell-escape --include-in-header=gif2png.tex -o test.pdf

您將得到這個 pdf 結果:

在此輸入影像描述


警告:

epstopdf僅支援pdflatexpdf lualatex-engine

相關內容