在命名管道 (fifo) 上调用 LaTeX?

发布于 2024-08-05 13:06:22 字数 1190 浏览 11 评论 0原文

我在 Unix 上的命名管道 fifo 上运行 LaTeX。我像这样创建 fifo:

$ mkfifo fifo

然后像这样运行 LaTeX:

$ latex fifo

这个过程会阻塞并且没有输出,直到我从另一个 shell 写入 fifo:

$ echo "\\end" > fifo

然后 $ Latex fifo 输出变为:

This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7)
%&-line parsing enabled.
entering extended mode

然而,LaTeX 进程永远不会结束。怎么才能让LaTeX结束呢?我尝试发送 chr(0) 和 chr(4) (即 ctrl-d),但都不起作用。是否有一些命令可以告诉 LaTeX 退出(即类似 \exit 的命令)?

感谢您的阅读。

编辑

值得注意的是,当您运行 tex 而不是 latex 的变体时,以下内容将按预期工作:(

$ echo "story\\end" > fifo

同时,在 tex然而

$ tex fifo
This is TeX, Version 3.1415926 (Web2C 7.5.7)
(./fifo [1] )
Output written on fifo.dvi (1 page, 212 bytes).
Transcript written on fifo.log.

,尽管 Leslie Lamport 在第 233 页的文档准备系统 LaTeX 中指出 \end 已被 \end{document} 取代,但以下任一情况都不会结束 LaTeX 会话:

$ echo "\begin{document}story\end{document}"
$ echo "\\begin{document}story\\end{document}"

I'm running LaTeX on a named pipe fifo on Unix. I create the fifo like-so:

$ mkfifo fifo

I then run LaTeX like-so:

$ latex fifo

This process blocks and has no output until I write to the fifo from another shell:

$ echo "\\end" > fifo

Then the $ latex fifo output becomes:

This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7)
%&-line parsing enabled.
entering extended mode

However, the LaTeX process never ends. How can you get LaTeX to end? I've tried sending it chr(0) and chr(4) (i.e. ctrl-d), but neither works. Is there some command that will tell LaTeX to exit (i.e. something like \exit)?

Thanks for reading.

EDIT:

It is noteworthy that when you run tex instead of a variant of latex then the following works as expected:

$ echo "story\\end" > fifo

(meanwhile, in the tex console)

$ tex fifo
This is TeX, Version 3.1415926 (Web2C 7.5.7)
(./fifo [1] )
Output written on fifo.dvi (1 page, 212 bytes).
Transcript written on fifo.log.

However, although Leslie Lamport notes in A Document Preparation System LaTeX on page 233 that \end has been replaced by \end{document}, neither of the following ends a LaTeX session:

$ echo "\begin{document}story\end{document}"
$ echo "\\begin{document}story\\end{document}"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゞ记忆︶ㄣ 2024-08-12 13:06:22

我建议允许你的 shell 将 fifo 管道定向到标准输入。

latex < fifo

当我这样做时,我首先得到这个输出:

This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2009.3.25)  18 SEP 2009 14:25
entering extended mode
 file:line:error style messages enabled.
 %&-line parsing enabled.

然后在 echo 命令之后得到:

**\end

*
! Emergency stop.
<*> \end

End of file on the terminal!

I would suggest allow your shell to direct the fifo pipe to the standard in.

latex < fifo

When I do that, I get this output first:

This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2009.3.25)  18 SEP 2009 14:25
entering extended mode
 file:line:error style messages enabled.
 %&-line parsing enabled.

and then after the echo command:

**\end

*
! Emergency stop.
<*> \end

End of file on the terminal!
未央 2024-08-12 13:06:22

如果我先将空行回显到 fifo,然后再回显文档的其余部分,则它可以正常工作。

mkfifo test
latex test

其他控制台:

echo "" > test
echo "\documentclass{report}\begin{document}asdf\end{document}" > test

第一个控制台:

xdvi test

我的猜测是 LaTeX 对文件进行了两次传递,而 TeX 则没有。在第一遍中,LaTeX 尝试确定某些内容,然后关闭文件,并在第二遍中重新打开它。

If I echo a blank line into the fifo first and then echo the rest of the document, it works fine.

mkfifo test
latex test

Other console:

echo "" > test
echo "\documentclass{report}\begin{document}asdf\end{document}" > test

First console:

xdvi test

My guess is that LaTeX makes two passes of the file whereas TeX does not. On the first pass, LaTeX tries to determine something, then it closes the file, and reopens it for the second pass.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文