Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary reverse indent of \item in nested enumerate environment #2670

Closed
lutalli opened this issue Mar 17, 2023 · 5 comments
Closed

Unnecessary reverse indent of \item in nested enumerate environment #2670

lutalli opened this issue Mar 17, 2023 · 5 comments
Labels

Comments

@lutalli
Copy link

lutalli commented Mar 17, 2023

Description

The indentation of \item seems to work improperly in a nested enumerate environment (enumerate in another enumerate). When I enter an \item in a nested enumerate and type a space, the \item gets indented backwards unnecessarily.

Steps to reproduce

  1. Begin with the following minimal TeX file:
\begin{document}

\begin{enumerate}
\end{enumerate}

\end{document}
  1. Type \item in the enumerate environment, after that start another enumerate (where | stands for the cursor position):
\begin{document}

\begin{enumerate}
    \item \begin{enumerate}|
\end{enumerate}

\end{document}
  1. Start a newline, type another \item (which belongs to the inner enumerate):
\begin{document}

\begin{enumerate}
    \item \begin{enumerate}
            \item|
\end{enumerate}

\end{document}
  1. Type a space:
\begin{document}

\begin{enumerate}
    \item \begin{enumerate}
        \item |
\end{enumerate}

\end{document}

Expected behavior

The inner \item should stay in place after the space is typed, like this:

image

Actual behavior

The following recording shows the problematic actual behavior - \item gets falsely indented back:

nested_enumerate.mov

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: macOS 12.4 (21F79)
  Vim version: NVIM v0.8.2
  Has clientserver: true
  Servername: /var/folders/zx/08zvm7jx3k70j_1_nyt1lc_80000gn/T/nvim.lutalli/2amYJE/nvim.66614.0

VimTeX project: tmp
  base: tmp.tex
  root: /
  tex: /tmp.tex
  main parser: fallback current file
  document class: 
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 0
    executable: latexmk
  viewer: Skim
  qf method: LaTeX logfile
@lutalli lutalli added the bug label Mar 17, 2023
@lervag
Copy link
Owner

lervag commented Mar 25, 2023

Indentation is hard. So, before I agree this is a bug, let's first consider the example. Let's assume we use spaces and indent width of 2. Then the following should represent the example you provide:

\begin{enumerate}
  \item \begin{enumerate}
      \item hello
        world
      \item hello
        again
    \end{enumerate}
  \item hello
    moon
\end{enumerate}

I think my listing here also represents the correct indentation. And it seems that this does not work as expected now and so it may be a bug. But before I look closer, do you agree that this looks correctly indented to you?

Notice, just to be clear: I am not trying to align \begin and \end here. I am saying that \begin should add an indent, and similarly \item should add indent to succeeding lines before the next \item. Or, that's the idea, at least.

@lutalli
Copy link
Author

lutalli commented Mar 25, 2023

Yes, I agree that the provided example represents the expected behaviour. There should be 3x indents before the inner \item, which consist of 1x given by the outer \begin, 1x by the outer \item, and 1x by the inner \begin.

lervag added a commit that referenced this issue Mar 26, 2023
@lervag
Copy link
Owner

lervag commented Mar 26, 2023

I think this should be fixed now.

@lervag lervag closed this as completed Mar 26, 2023
@lutalli
Copy link
Author

lutalli commented Mar 27, 2023

I can confirm that the indentation works properly now. Thanks for fixing it!

@lervag
Copy link
Owner

lervag commented Mar 27, 2023

Great, glad to hear it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants