New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra level of indentation in tikzpictures #1960
Comments
Thanks for the kind words!
Just to be sure: You are not complaining about the result if I take the example file and do \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0, 0) {
\includegraphics{logo.png}
};
\end{tikzpicture}
\end{document}
I can't properly reproduce the problem you are describing. Can you provide a full minimal example and a more detailed description? |
You can reproduce it with this minimal set nocompatible
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()
filetype plugin indent on
syntax on
set autoindent
set smarttab
set shiftwidth=4
set softtabstop=4
set tabstop=4 Create a new tex file (I used \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0, 0) {
\includegraphics{logo.png}
};
\end{tikzpicture} Save and exit Vim. Reopen the file, navigate to the ending of the I have tested this in Vim 8.2 and NeoVim 0.4.4 on Arch Linux. |
Ah, I see. I think this is because the behaviour is not what you expect. If you take the same file and do \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0, 0) {
\includegraphics{logo.png}
};
\end{tikzpicture} And this is actually what I expect. The point is that there is special indentation for TikZ statements, and \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node
at (0, 0) {
\includegraphics{logo.png}
};
\end{tikzpicture} |
Ah, now I understand, thanks for the explanation. For examples like \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node
at (0, 0) {
\includegraphics{logo.png}
};
\end{tikzpicture} or \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0, 0)
{
\includegraphics{logo.png}
};
\end{tikzpicture} this special indentation rule is clear to me. For someone who is used to C-like programming languages the style \documentclass{scrreprt}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0, 0) {
\includegraphics{logo.png}
};
\end{tikzpicture} is a bit unusual. Probably there is no way to avoid the extra indentation level if the opening brace is on the same line as the TikZ command? |
I agree, this is not how I personally like things either. However, I was never able to find a robust way to make this work exactly as I wanted. I also don't know a good way to avoid the extra indentation level. Sorry. :\ To be honest, indentation is quite hard, because we need to do some "house keeping". Some styles of indents depend on the "state" one or more lines above. The algorithm to calculate indents assumes that every previous line is correctly indented. Then it looks at the current lines and 1 or more lines above to determine the new indent. So: I'm not sure if there is a good way to solve this issue. As a minimum, we need a good example of "wrong indent" vs "right indent". This far, I don't see any clear "wrong indent" examples. :\ |
PR #1970 is only a partial fix since it deactivates TikZ indentation completely but users can decide which style fits better. |
Thanks, #1970 is merged now. |
Hey and thanks for this fantastic vim plugin! 馃槃 vimtex is great for working with LaTeX documents but I found a minor issue regarding the indentation rules in tikz pictures. Consider this minimal example:
Every time I enter
}
to close the\includegraphics
command, vimtex adds one extra level of indentation although the command is already indented. I tried to understand whats:indent_delims
does but I am not quite sure how it works or could be fixed.The text was updated successfully, but these errors were encountered: