I am using VIM with with syntastic, which is just a syntax checking plugin. When I am using commands like \raggedright or \raggedleft following a space and then some text, it gives me an annoying warning saying that

Command terminated with space.

In order to remove that warning, I escape the space with a \ e.g \raggedright\ Some text. But when it ends when something like . or ? I don't get any warning.

So my question is why I am getting this behavior? Is it LaTeX or just a syntastic thing?

  • 2
    This is a syntastic thing. LaTeX would indeed swallow the space after \raggedright, but because \raggedright does not produce output that is actually a good thing. Compare the output of \raggedright\ Lorem and \raggedright Lorem. In the first case you explicitly start your line with a space, which is probably not a good idea. On the other hand you usually want to add an explicit escaped space if the macro produces output, for example \LaTeX is nice and \LaTeX\ is nice (or \LaTeX{} is nice). – moewe Feb 22 at 7:39
  • 1
    So there are macros where you want to add an explicit space and some where you don't. You can only really know into which category a macro falls if you are TeX and have traced back all macro assignments and expansions, this is unreasonable for an external syntax checker. So they had to decide whether to warn (and potentially produce false positives) or not to warn (and have true positives go unnoticed). – moewe Feb 22 at 7:44
  • 3
    According to github.com/vim-syntastic/syntastic/issues/2247 syntastic runs lacheck and chktex, both have their issues (look around on this site), because serious syntax linting in LaTeX is tricky, see also tex.stackexchange.com/q/155424/35864, tex.stackexchange.com/q/473890/35864. For your actual question, have a look at tex.stackexchange.com/q/31091/35864 – moewe Feb 22 at 7:47
  • Thank you for all the details @moewe , It seems like a syntastic thing. I just installed texstudio and there were no warnings in the same code. – Nomi Shaw Feb 22 at 8:06
  • 3
    Yes syntastic runs additional LaTeX syntax checkers/linters on your file. The warnings produced by these tools have nothing to do with warnings or errors produced by TeX itself when it compiles your file. They can be useful in catching some issues LaTeX may not warn you about, but as you discovered they can also produce quite a few false positives. My advice would be to acquaint yourself with LaTeX and its pitfalls a bit so that you don't need these additional syntax checkers. – moewe Feb 22 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.