# Indentation in Latex within a list after an equation

Here is a minimal .tex file:

\begin{document}
\begin{itemize}
\item Here is an equation:
\begin{align*}
x = y
\end{align*}
\item Here is another item
\end{itemize}
\end{document}


I would like to make the second item bold. If I put my cursor before the H and put

\textbf{


while in insert mode, the line de-indents as soon as the bracket is put in place.

My question is how can I prevent this behavior? I would like no indentation.

The problem seems to be the equation environment. If that is removed then I get the desired behavior.

Here is my .vimrc:

set nocompatible
filetype plugin indent on
syntax enable


The behavior goes away if I remove

filetype plugin indent on


but then I also lose some other desired functionality.

Ultimately, I will be using this with https://github.com/lervag/vimtex. So solutions involving that plugin would be welcome as well.

The reason this is happening is because the indentexpr [1] prefers text to be indented inside \items. You can see this by pressing gg=G. This is what it considers correct indenting:

\begin{document}
\begin{itemize}
\item Here is an equation:
\begin{align*}
x = y
\end{align*}
\item Here is another item
\end{itemize}
\end{document}


When you type \textbf{ (specifically the {), it realizes that the \item should be un-indented compared to the text above it (\end{align*}. To disable this, you can put

let g:tex_indent_items=0 into your vimrc (only works with vim's default tex indent)

If you simply don't like the jumping (i.e., re-indenting) when pressing { behavior, consider:

set indentkeys-={ indentkeys-=}

[1] By default, vim uses GetTeXIndent() as its indentexpr; vimtex uses a different indentexpr.

• Perfect -- as a third option, I think I will just get used to indenting things the way Vim expects it, since I have no strong preference for the way I was doing it. – evencoil Oct 1 '17 at 22:28
• If you eventually want to use vimtex, you should know that (as @Mass states) vimtex uses its own indentexpression. Thus any settings you apply now for the built-in LaTeX indentation will not have any effect. Indentation is actually quite hard, and it is clearly subjective. Vimtex indentation does differ slightly from the built-in indentation, and it is not perfect. However, it is possible to customize it, at least slightly. It also offers more advanced indentation for various commands, and it tries to be more consistent throughout. – Karl Yngve Lervåg Oct 2 '17 at 6:49
• @KarlYngveLervåg I actually had this behavior with my full setup with vimtex, and then as I created a minimal vimrc found that it persisted even without vimtex. In any case, changing my indenting behavior seems to have "solved" this problem in vimtex as well. – evencoil Oct 2 '17 at 11:47