【发布时间】:2017-10-06 05:46:07
【问题描述】:
我正在尝试使用 LaTeX 的 graphicsx 包在模板中包含 JPEG 图像,但该包似乎没有呈现该图像。当然,我可能会省略一些内容,但我在下面包含了我的代码以供考虑。
我在 Cloud 9 中使用容器化的 Ubuntu 14.04 实例,texlive-full 包和节点 v6.10.2。
var fs = require('fs');
var input = process.argv[2];
var output = process.argv[3];
var temp = [];
fs.readFile(input, 'utf8', function (err, data) {
if (err) throw err;
console.log('>>> Tex file imported.');
temp.push(data);
var options = { 'command': 'pdflatex' };
require('latex')(temp, options).pipe(fs.createWriteStream(output));
console.log('>>> Tex file built.');
});
我的tex文件如下:
\documentclass{article} \usepackage{graphicx} \begin{document}
\begin{center} \includegraphics[scale=1]{logo.jpg}
\newline \Large NOTICE
\end{center}
\sffamily Account Number: \textit{12345678} \newline
\newline MR A TEST
\newline 2 THE STREET
\newline FARNBERRY
\newline CLOUD TOWN
\newline GU15 3AA \newline
\newline Amount: 1078.52
\newline Financial Year: \textbf{2017}
\newline
\newline \small{Footer text}
\end{document}
如果我使用命令>pdflatex filename.tex 从终端编译此 tex 文件,则图像在 PDF 中呈现良好。您能帮我渲染包含的图像吗?
谢谢。
【问题讨论】:
-
我没有发现你的错误。当您将 pdf 输出为 .tex 文件时,您的图像不显示?
-
嗨@mtkilic 是的,当我运行节点应用程序时,包括输入文件和输出文件作为像这样
>node app.js texfile.tex output.pdf这样的参数,会创建 PDF,但不包括 logo.jpg。 -
更有可能,您的
texfile.tex和jpg不在同一个文件夹中。 -
我可以确认它们在同一个文件夹中,因为当我在同一个 tex 文件上运行终端命令
>pdflatex filename.tex时,jpg 呈现正常。