4

It seems that latex-suite do the auto indent wrong when there are no closed bracks, for example, in the following $[0,1)$ is the cause of problem:

\begin{equation}
    f(x),\quad x\in[0,1)
\end{equation}

will indent to

\begin{equation}
    f(x),\quad x\in[0,1)
    \end{equation}

is there a way to solve it? (if I replace $[0,1)$ with $[0,1]$ then the indent work again).

UPDATE I just install one plugin, i.e., vim-latex or latex-suite (is this the old name?). And after a while, I found the problem is caused by these lines in vim-latex\indent\tex.vim

    if g:tex_indent_brace
  " Add a 'shiftwidth' after a "{" or "[" while there are not "}" and "]"
  " after them. \m for magic
    if line =~ '\m\(\(\[[^\]]*\)\|\({[^}]*\)\)$'
        "let ind = ind + &sw
    endif
  " Remove a 'shiftwidth' after a "}" or "]" while there are not "{" and "["
  " before them. \m for magic
    if cline =~ '\m^\(\([^[]*\]\)\|\([^{]*}\)\)'
        "let ind = ind - &sw
    endif
endif

as you can see, I comment out two lines of if...endif, and which will stop indent for { and [. And my example will output (do gg = G):

\begin{equation}
    f(x),\quad x\in[0,1)
\end{equation}

BUT, it also mess up something, such as

\newcommand{set}[1]{%
\left\{#1\right\}%
}

rather than

\newcommand{set}[1]{%
  \left\{#1\right\}%
}

so, there still need some solution to fix this.

cmhughes
  • 100,947
user19832
  • 1,585
  • Try on vim.stackexchange.com if folks don't answer here. What if you add ℅} to the end of the offending line? – cxw Aug 20 '15 at 09:48
  • can you clarify: are you using latexindent to do the indentation? or are you using another tool? I can confirm the behaviour you describe using latexindent – cmhughes Aug 20 '15 at 13:47
  • 1
    if you're using latexindent, then I can provide a number of fixes; you might also have a look at Section 4.5: An important example in the documentation :) It's very similar to your question – cmhughes Aug 20 '15 at 16:12
  • @cxw If I add %} at the end of that line, then no indent of that line. – user19832 Aug 21 '15 at 07:56
  • @cmhughes I don't know latexindent, is it a plugin independent to vim-latex or latex-suite? I only use latex-suite and do the recommand setting as said in the official site. – user19832 Aug 21 '15 at 07:57
  • @cmhughes I didn't find your section, it seems that :help latex-suite.txt has no section 4.5. – user19832 Aug 21 '15 at 07:58
  • I was referencing latexindent documentation; it sounds like you're not using it, so it would be best to remove the latexindent tag from your question – cmhughes Aug 21 '15 at 11:16
  • I can't reproduce this with Vim 7.4 and Latex Suite at commit e6972ac from 2017-12-09. – rkta Aug 23 '18 at 17:39

0 Answers0