lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.53k stars 391 forks source link

`IEEEeqnarray` not recognized as math environment #2675

Closed ThomasChaffey closed 1 year ago

ThomasChaffey commented 1 year ago

IEEEeqnarray is not being recongnized as a math environment by vimtex.

Previously, I manually added IEEEeqnarray as a math environment. Originally, this was done by placing the command call TexNewMathZone("M", "IEEEeqnarray", 1) in a file in ~/.vim/after/syntax/tex/. After some updates, the method changed to call vimtex#syntax#core#new_region_math('IEEEeqnarray') in .vimrc. This is no longer working.

I see that support for IEEEtrantools should now be standard, as per this feature request: https://github.com/lervag/vimtex/issues/1796. I've updated to the latest versions of vim and vimtex for OS X, but still have the problem.

lervag commented 1 year ago

IEEEeqnarray is defined by the package ieeetrantools and should be recognized by default without any additional customizations. Can you provide a minimal example where this does not work as expected for you?

ThomasChaffey commented 1 year ago

Hi Lervag,

Thanks for the quick response, and apologies for the vagueness of my issue yesterday. I've made it more precise now. A minimum non-working example is:

\documentclass{ieeeconf}
\begin{document}
\begin{IEEEeqnarray*}{rCl}
\int_{-\infty}^\infty u(t)^2 dt < \infty.
\end{IEEEeqnarray*}
\end{document}

A minimum fix is:

\documentclass{article}
\usepackage{IEEEtrantools}
\begin{document}
\begin{IEEEeqnarray*}{rCl}
\int_{-\infty}^\infty u(t)^2 u(t) dt < \infty.
\end{IEEEeqnarray*}
\end{document}

Adding usepackage{IEEEtrantools} only fixes the issue if the document is reloaded.

IEEEtrantools is already provided by the class ieeeconf, and I get an error if I load the package. Unfortunately I have to use that class for the conference I'm submitting to.

lervag commented 1 year ago

Thanks for the quick response, and apologies for the vagueness of my issue yesterday.

No problem!

I've made it more precise now. A minimum non-working example is:

\documentclass{ieeeconf}
\begin{document}
\begin{IEEEeqnarray*}{rCl}
\int_{-\infty}^\infty u(t)^2 dt < \infty.
\end{IEEEeqnarray*}
\end{document}

I think it should work as expected after you've compiled this document. Can you check that?

The problem here is that the syntax rules are applied only when VimTeX recognizes the package. If there is no \usepackage that explicitly loads a package, then VimTeX does not immediately know it is there. When you compile the document, the compiler creates a .fls file that VimTeX uses to figure out which packages are used, thus things (should) work after you compile.

If I'm right: I may consider to make an update where ieeeconf automatically loads the package.

ThomasChaffey commented 1 year ago

I think it should work as expected after you've compiled this document. Can you check that?

I'm afraid it doesn't work: I tried compiling both from vimtex and using pdflatex in the terminal, no luck...

If I'm right: I may consider to make an update where ieeeconf automatically loads the package.

Which source file(s) would I have to patch to get something like this to work?

Edit: in the meantime, is there a method to manually add IEEEeqnarray as a math environment, similar to my old solution?

lervag commented 1 year ago

Edit: in the meantime, is there a method to manually add IEEEeqnarray as a math environment, similar to my old solution?

Yes: You can do this:

let g:vimtex_syntax_packages = {
      \ 'ieeetrantools': {'load': 2},
      \}
lervag commented 1 year ago

I'm trying to reproduce. Is this the source of the template you are using?

https://www.ieee.org/conferences/publishing/templates.html

lervag commented 1 year ago

Or this? https://www.ctan.org/tex-archive/macros/latex/contrib/IEEEconf

ThomasChaffey commented 1 year ago

I'm using the template provided here by the IEEE Control Systems Society: https://css.paperplaza.net/conferences/support/files/ieeeconf.cls

lervag commented 1 year ago

It's interesting to note that this template is not part of common texlive distributions, whereas IEEEtran is. Not sure why.

I believe I've pushed a fix for this now. Please update and test.

ThomasChaffey commented 1 year ago

Wonderful! It's working well now.

This is surely some ancient template that should be abandoned, but I expect it would involve some committee approval or something, so much less work to just keep using the old template!

lervag commented 1 year ago

Great, glad to hear it. And yes, I would also not be surprised if this is "old cruft", but adding the support was trivial and doesn't really hurt anything, so I think it was OK to add it.