不要让我在出现错误时手动中止 LaTeX 编译 [英] Don't make me manually abort a LaTeX compile when there's an error

查看:30
本文介绍了不要让我在出现错误时手动中止 LaTeX 编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如建议 这里latexmk 很方便每当源代码更改时不断编译文档的方法.但通常当您处理文档时,您会遇到错误,然后 latex 会恐慌并等待用户输入,然后再继续.这会变得非常烦人,尤其是最近我破解了一些东西来直接从 etherpad 编译 latex文档,在您键入时连续保存.

As suggested here, latexmk is a handy way to continually compile your document whenever the source changes. But often when you're working on a document you'll end up with errors and then latex will panic and wait for user input before continuing. That can get very annoying, especially recently when I hacked up something to compile latex directly from an etherpad document, which saves continuously as you type.

是否有设置 latexlatexmk 使其在无法编译时中止并显示错误消息?或者,如果有必要,我将如何设置某种 Expect 脚本来自动消除 LaTeX 的投诉?

Is there a setting for latex or latexmk to make it just abort with an error message if it can't compile? Or, if necessary, how would I set up some kind of Expect script to auto-dismiss LaTeX's complaints?

(我曾认为 pdflatex 的选项 -halt-on-error 可以解决问题,但显然不是.)

(I had thought pdflatex's option -halt-on-error would do the trick but apparently not.)

额外问题:Mac OSX 上的 Skim 是一个不错的 pdf 查看器,它会在 pdf 更改时自动刷新(与预览不同),除了,每当出现乳胶错误时,它都会让您重新确认您想要自动刷新.Texniscope 没有这个问题,但由于其他原因,我不得不放弃 Texniscope.有没有办法让 Skim 始终自动刷新,或者是否有其他查看器可以做到这一点?

Bonus question: Skim on Mac OSX is a nice pdf viewer that autorefreshes when the pdf changes (unlike Preview), except that whenever there's a latex error it makes you reconfirm that you want autorefreshing. Texniscope doesn't have this problem, but I had to ditch Texniscope for other reasons. Is there a way to make Skim always autorefresh, or is there another viewer that gets this right?

<小时>

  1. 在此处获取 latexmk:http://www.phys.psu.edu/~collins/software/latexmk-jcc/

将以下内容添加到您的 ~/.latexmkrc 文件中:

Add the following to your ~/.latexmkrc file:

$pdflatex = 'pdflatex -interaction=nonstopmode';

(对于带有 Skim 的 OS X)

(For OS X with Skim)

$pdf_previewer = "open -a /Applications/Skim.app";

  • 在编辑源文件 foo.tex 时,在终端中运行以下命令:

  • While editing your source file, foo.tex, run the following in a terminal:

    latexmk -pvc -pdf foo.tex
    

  • 使用 Skim 或其他实时 pdf 查看器查看 foo.pdf.对于 Skim,只需查看 Skim 首选项中的同步"选项卡并为您的编辑器进行设置.

  • Use Skim or another realtime pdf viewer to view foo.pdf. For Skim, just look at the "Sync" tab in Skim’s preferences and set it up for your editor.

    瞧!现在点击 foo.tex 上的保存将导致 foo.pdf 刷新而不接触任何东西.

    Voila! Hitting save on foo.tex will now cause foo.pdf to refresh without touching a thing.

    推荐答案

    使用 MikTeX,pdflatex 有这个命令行选项:

    With MikTeX, pdflatex has this command-line option:

      -interaction=MODE               Set the interaction mode; MODE must be one
                                      of: batchmode, nonstopmode, scrollmode,
                                      errorstopmode.
    

    <小时>

    @9999years 建议的


    Edit suggested by @9999years:

    这些值相当于一组提供相同功能的 LaTeX commands.

    Those values are equivalent to a set of LaTeX commands that provide the same functionality.

    来自TeX 使用技巧:

    这些模式使 TeX 的行为方式如下:

    The modes make TeX behave in the following way:

    • errorstopmode 停止所有错误,无论它们是关于源代码或不存在的文件.

    • errorstopmode stops on all errors, whether they are about errors in the source code or non-existent files.

    scrollmode 不会因源中的错误而停止,而是会在出现错误时请求输入发生更严重的错误,例如丢失文件.

    scrollmode doesn't stop on errors in the source but requests input when a more serious error like like a missing file occurs.

    在有点名不副实的 nonstopmode 中,TeX 在之后不请求输入严重错误但完全停止.

    In the somewhat misnamed nonstopmode, TeX does not request input after serious errors but stops altogether.

    batchmode 阻止除此之外的所有输出(用于自动化脚本).在所有情况下,所有错误都写入日志文件(yourtexfile.log).

    batchmode prevents all output in addition to that (intended for use in automated scripts). In all cases, all errors are written to the log file (yourtexfile.log).

    这篇关于不要让我在出现错误时手动中止 LaTeX 编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆