【问题标题】:How to make the vim Latex Suite recognize an "unknown package" error?如何让 vim Latex Suite 识别“未知包”错误?
【发布时间】:2011-05-04 05:59:52
【问题描述】:

我正在使用 Vim Latex 套件,我喜欢它。但是在某些方面它并没有达到我想要的效果。

来自.vim/compiler/tex.vim 文件:

"   Depending on the 'ignore-level', the following kinds of messages are
"   ignored. An ignore level of 3 for instance means that messages 1-3 will be
"   ignored. By default, the ignore level is set to 4. 
"
"   1. LaTeX Warning: Specifier 'h' changed to 't'. 
"      This errors occurs when TeX is not able to correctly place a floating
"      object at a specified location, because of which it defaulted to the
"      top of the page.
"   2. LaTeX Warning: Underfull box ...
"   3. LaTeX Warning: Overfull box ...
"      both these warnings (very common) are due to \hbox settings not being
"      satisfied nicely.
"   4. LaTeX Warning: You have requested ..., 
"      This warning occurs in slitex when using the xypic package.
"   5. Missing number error:
"      Usually, when the name of an included eps file is spelled incorrectly,
"      then the \bb-error message is accompanied by a bunch of "missing
"      number, treated as zero" error messages. This level ignores these
"      warnings.
"      NOTE: number 5 is actually a latex error, not a warning!

此列表未提及任何有关丢失包的信息。编译具有\usepackage 的 Tex 文件不在系统上时会注意到这一点。

通常会出现错误(添加 `\usepackage{notapackage} 时:

! LaTeX Error: File `notapackage.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

但在 vim 中,由于不支持这种类型的错误,我得到:

正如您所见,关于丢失的包裹没有任何说法,只是一个神秘的emergency stop

另一个问题是,当一个未知的选项被传递给一个包时,Vim 会打开那个包的.sty 文件,这可能会很烦人。

如何让 vim 识别这个错误?

【问题讨论】:

    标签: latex compiler-errors vim


    【解决方案1】:

    我认为您遇到的错误没有任何问题。请记住,vim 对乳胶一无所知。您看到的所有消息都是 latex 编译器吐出的内容(反过来,它不知道 vim)。 vim-latex-suite 所做的只是将输出整齐地显示在 vim 缓冲区/窗口中,以便于阅读/修复。

    其次,我认为您只是在 Quickfix/log 窗口中看到错误消息的最后一部分,如果您向上滚动,您应该会看到正确的消息。以下是您所看到的内容和不同编译模式的说明。

    不间断模式

    在这种模式下pdflatex(或latex)编译时不会因警告/错误而停止,这很有用,因为我真的不想在每一步都暂停并按回车键。从您收到的错误消息来看,这是您运行它的模式。设置此模式的位置在~/.vim/ftplugin/tex.vim 特别是以下行:

    let g:Tex_CompileRule_pdf = 'pdflatex -interaction nonstopmode $*'
    

    为了演示,这是我编译的一个测试示例

    \documentclass{article}
    \usepackage{notapackage}
    \begin{document}
    Hello world
    \end{document}
    

    我得到的信息是:

    起初,它看起来像你所拥有的,但请注意它们位于42-47 行。向上滚动几行,你会发现:

    在这种模式下无法停止它(这就是它被称为不间断模式的原因!),如果你从终端运行它,你会看到这种行为。

    交互模式

    在此模式下,它会为每个错误暂停并让您有机会更正它(如果可能)。这在编译时间较长且您宁愿暂停修复而不是从头重新编译的大型项目(即书籍运行到包含大量方程式 + 浮点数的页面)中很有用。

    如果通过设置关闭不间断模式

    let g:Tex_CompileRule_pdf = 'pdflatex $*'
    

    然后尝试编译,vim 会带你到终端,你可以在提示符下输入包的新名称。由于是一个简单的例子,为了直观地看到输入新包后的变化,我在提示符下输入了palatino。这应该编译 PDF 并以 Palatino 字体显示“Hello world”,确实如此! (Palatino 在左边,默认 CM 在右边)。

    但是,如果您像我一样只是将乳胶用于您的学校/数学/简历工作,我真的不推荐这种模式。很快就会令人沮丧。

    【讨论】:

    • 我知道这一切,我编辑了这个问题,让它更专注于我不知道的事情。
    • @romeovs:这很奇怪。 I get the notification.你能看看main.log的输出,看看有没有这行! LaTeX Error: File 'notapackage.sty' not found
    • 请注意:我的.log 中存在该错误...如果这不起作用,那还不错,无论如何我都使用预编译的序言,这意味着有机会添加坏包非常小。
    • @romeovs:好的.. 关键是它确实有效(请参阅评论中的屏幕截图),我还不能完全弄清楚为什么它不适合你。
    猜你喜欢
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多