![! LaTeX 錯誤:無法確定 ../images/vi.gif 中圖形的大小(無 BoundingBox)](https://rvso.com/image/370291/%EF%BC%81%20LaTeX%20%E9%8C%AF%E8%AA%A4%EF%BC%9A%E7%84%A1%E6%B3%95%E7%A2%BA%E5%AE%9A%20..%2Fimages%2Fvi.gif%20%E4%B8%AD%E5%9C%96%E5%BD%A2%E7%9A%84%E5%A4%A7%E5%B0%8F%EF%BC%88%E7%84%A1%20BoundingBox%EF%BC%89.png)
我已經下載了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
僅支援pdflatex
pdf lualatex
-engine