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

Add folding of enumerate items #1765

Closed
PKU-lzk opened this issue Aug 5, 2020 · 7 comments
Closed

Add folding of enumerate items #1765

PKU-lzk opened this issue Aug 5, 2020 · 7 comments

Comments

@PKU-lzk
Copy link

PKU-lzk commented Aug 5, 2020

The feature request is for providing a folding for enumerate items.

Here is a minimum example using enumerate env.

\documentclass[a4paper]{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[fullwidth, itemindent=0pt, label=\textbf{\arabic*.}]
	\item First.
	\item Second.
	
	  second.
		\begin{enumerate}[label=(\arabic*)]
			\item 1.
			\item
				2.
		\end{enumerate}
	\item
	
		Third.
\end{enumerate}
\end{document}

Would it be possible to fold it like this:

\documentclass[a4paper]{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[fullwidth, itemindent=0pt, label=\textbf{\arabic*.}]
	\item First.
	\item Second.-----------------------------------------------------------------------------------------
		\begin{enumerate}[label=(\arabic*)]
			\item 1.
			\item---------------------------------------------------------------------------------
		\end{enumerate}
	\item-------------------------------------------------------------------------------------------------
\end{enumerate}
\end{document}

Thanks!

@lervag
Copy link
Owner

lervag commented Aug 5, 2020

Anything is possible, but I'm not sure I agree that the first fold should stop at the \begin{enumerate} part. So, I think this is a better picture of what could be added:

All folds open                Fold level 2 closed           Fold level 1 closed
----------------------------------------------------------------------------------------
0 \begin{enumerate}[...]      0 \begin{enumerate}[...]      0 \begin{enumerate}[...]
0   \item First.              0   \item First.              0   \item First.
1   \item Second.             1   \item Second.             1   \item Second. ----------
1                             1                             1   \item ------------------
1     second.                 1     second.                 0 \end{enumerate}
1     \begin{enumerate}[...]  1     \begin{enumerate}[...]
1             \item 1.        1             \item 1.
2             \item           2             \item --------
2                     2.      1     \end{enumerate}
1     \end{enumerate}         1   \item
1   \item                     1
1                             1     Third.
1     Third.                  0 \end{enumerate}
0 \end{enumerate}

Here we ignore the folds from the environments. The point is that each \item starts a fold the continues to the next \item or until \end{enumerate|itemize}. The numbers indicate the fold levels.

What do you think?

@PKU-lzk
Copy link
Author

PKU-lzk commented Aug 6, 2020

You are right! This one is better.

@lervag
Copy link
Owner

lervag commented Aug 10, 2020

Ok, this was harder than I thought. But I've pushed a branch with the feature now. I think it might be ready for merge, but it would be nice if you could test it. Something like this:

cd path/to/vimtex
git pull
git checkout feat/fold-items

@PKU-lzk
Copy link
Author

PKU-lzk commented Aug 11, 2020

It works in most cases, but it doesn't fold as I expected in this case:

All folds open                                        All Folds closed
------------------------------------------------------------------------------------
\begin{enumerate}[...]                                \begin{enumerate}[...]--------
  \item A                                               \item D
    \begin{enumerate}[...]                            \end{enumerate}
      \item B
    \end{enumerate}
    C
  \item D
\end{enumerate}

@lervag
Copy link
Owner

lervag commented Aug 11, 2020

I think it's fixed now. Can you test again?

lervag added a commit that referenced this issue Aug 11, 2020
@lervag
Copy link
Owner

lervag commented Aug 11, 2020

By the way, I rebased and cleaned up, so you have to force pull the branch. Or delete the branch and fetch a fresh version of it. Let me know if you need help with it!

lervag added a commit that referenced this issue Aug 11, 2020
@lervag
Copy link
Owner

lervag commented Aug 11, 2020

I think this works as expected, so I've merged it with master. If you find any more bugs, let me know, I'll fix them asap.

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

No branches or pull requests

2 participants