如何让vim Latex Suite识别出"未知软件包"错误?

rom*_*ovs 7 vim latex compiler-errors

我正在使用Vim Latex Suite,我喜欢它.但有些观点认为它没有做我想做的事情.

.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!
Run Code Online (Sandbox Code Playgroud)

此列表未提及有关缺少包的任何信息.在编译具有\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)
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

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

另一个问题是当一个未知的选项传递给一个包时,Vim会打开那个包.sty文件,这可能会让人非常恼火.

如何让vim识别出这个错误?

abc*_*bcd 5

我发现你得到的错误并没有错.请记住,vim对乳胶一无所知.您看到的所有消息都是latex编译器吐出的消息(反过来,它不知道vim).所有该vim-latex-suite所做的是在为方便阅读/修复一个vim缓冲器/窗口整齐地显示输出.

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

不间断模式

在这种模式下pdflatex(或latex)编译而不停止警告/错误,这很有用,因为我不想在每一步都暂停并按Enter键.根据您的错误消息判断,这是您运行它的模式.~/.vim/ftplugin/tex.vim特别是,设置此模式的位置,如下所示:

let g:Tex_CompileRule_pdf = 'pdflatex -interaction nonstopmode $*'
Run Code Online (Sandbox Code Playgroud)

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

\documentclass{article}
\usepackage{notapackage}
\begin{document}
Hello world
\end{document}
Run Code Online (Sandbox Code Playgroud)

我收到的消息是:

在此输入图像描述

起初,它看起来像你拥有的,但请注意它们是在线42-47.向上滚动几行,你会发现:

在此输入图像描述

在这种模式下无法停止它(这就是为什么它被称为不间断模式!),这就是你从终端运行它时看到的行为.

互动模式

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

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

let g:Tex_CompileRule_pdf = 'pdflatex $*'
Run Code Online (Sandbox Code Playgroud)

然后尝试编译,vim将带您到终端,在那里您可以在提示符下输入包的新名称.由于这是一个简单的例子,为了在输入新包后可视地看到更改,我palatino在提示符下输入.这应该编译PDF并在Palatino字体中显示"Hello world",的确如此!(Palatino位于左侧,默认CM位于右侧).

在此输入图像描述 在此输入图像描述

但是,如果你像我一样只是在学校/数学/简历中使用乳胶,我真的不会推荐这种模式.它会很快变得令人沮丧.