如何让vim Latex Suite识别“未知包”错误?
我正在使用 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!
此列表没有提及任何有关丢失软件包的信息。当编译具有系统上不存在的 \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 中,由于不支持这种类型的错误,我得到:
正如您所看到的,没有任何关于丢失包的信息,只是一个神秘的紧急停止
另一个问题是,当未知选项传递给包时,Vim打开该包.sty
文件,这可能非常令人恼火,
如何让 vim 识别这个错误?
I'm using the Vim Latex Suite, and I love it. But there are some points in which it doesn't do what I want.
From the .vim/compiler/tex.vim
file:
" 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!
This list doesn't mention anything about missing packages. This can be noticed when compiling a Tex file that has a \usepackage
which isn't on the system.
normally one would get the error (when adding `\usepackage{notapackage}:
! LaTeX Error: File `notapackage.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
But in vim, since this type of error isn't supported, I get:
As you can see nothing is said about a missing package, just an cryptic emergency stop
Another problem is that when an unknown option is passed to a package, Vim opens up that packages .sty
file, which can be mighty irritating.
How do I make vim recognize this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您收到的错误没有任何问题。请记住,vim 对乳胶一无所知。您看到的所有消息都是
latex
编译器吐出的内容(反过来,它不知道 vim)。 vim-latex-suite 所做的就是在 vim 缓冲区/窗口中整齐地显示输出,以便于阅读/修复。其次,我认为您只是在 Quickfix/log 窗口中看到错误消息的最后一部分,如果向上滚动,您应该会看到正确的消息。以下是对您所看到的内容以及不同编译模式的解释。
不间断模式
在此模式下,
pdflatex
(或latex
)编译时不会因警告/错误而停止,这很有用,因为我真的不想暂停并按 Enter 键每一步。根据您收到的错误消息判断,这就是您运行它的模式。设置此模式的位置位于~/.vim/ftplugin/tex.vim
尤其是以下行:为了演示,这是我编译的一个测试示例
我得到的消息是:
起初,它看起来像你有什么,但请注意它们位于
42-47
行。向上滚动几行,您会发现:在这种模式下无法停止它(这就是为什么它被称为不间断模式!),这就是您从终端运行它时看到的行为。
交互模式
在此模式下,它会在出现每个错误时暂停,并为您提供纠正错误的机会(如果可能)。这在大型项目中很有用(即书籍运行到包含大量方程+浮点数的页面),其中编译时间较长,您宁愿暂停修复而不是从头开始重新编译。
如果你通过设置关闭不间断模式
,然后尝试编译,vim 会将你带到终端,你可以在提示符处输入包的新名称。由于这是一个简单的示例,为了在输入新包后直观地看到变化,我在提示符下输入了
palatino
。这应该编译 PDF 并以 Palatino 字体显示“Hello world”,确实如此! (Palatino 位于左侧,默认 CM 位于右侧)。但是,如果您像我一样只是在学校/数学/简历工作中使用乳胶,我真的不会推荐这种模式。它很快就会变得令人沮丧。
I see nothing wrong with the error you are getting. Remember, that vim does not know anything about latex. All the messages that you see are what the
latex
compiler spits out (which in turn, does not know about vim). All that thevim-latex-suite
does is display the output neatly in a vim buffer/window for easy reading/fixes.Secondly, I think that you are just seeing the last part of the error message in the Quickfix/log window and if you scroll up, you should see the correct message. Here's an explanation of what you're seeing and the different modes of compilation.
Non-stop mode
In this mode
pdflatex
(orlatex
) compiles without stopping for warnings/errors, which is useful because I don't really want to pause and hit enter at each step. Judging by the error message you have, this is the mode you are running it in. The location where this mode is set is in~/.vim/ftplugin/tex.vim
especially, the following line:To demonstrate, here's a test example that I compiled
The message I get is:
At first, it looks like what you have, but note that they're at lines
42-47
. Scrolling up a few lines, you'll find:There is no way to halt it in this mode (that's why it's called nonstop mode!), and this is the behaviour you see if you ran it from the terminal.
Interactive mode
In this mode it pauses for each error and gives you a chance to correct it (if possible). This is useful in large projects (i.e. books running into pages with lots of equations + floats) where the compile time is longer and you'd rather pause to fix than recompile from the start.
If you turn off the nonstop mode by setting
and then try to compile, vim will take you to the terminal, where you can enter a new name for the package at the prompt. Since it is a simple example, to see the changes visually after entering a new package, I entered
palatino
at the prompt. This should compile the PDF and display "Hello world" in Palatino font, and indeed it does! (Palatino is on the left and the default CM is on the right).However, I really wouldn't recommend this mode if you, like me, are just using latex for your school/math/cv work. It'll quickly get frustrating.