6

I am writing an outline and have a lot of nested enumitem lists. Is there a way to automatically suppress output for higher list levels? e.g. In the following:

\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{enumerate}[label=\alph*.]
  \item First point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...

How do I print a concise version of my outline by printing only the first-level \items ?

6

More general method doing all of enumerate, itemize, and description and allowing to specify a level N.

[there was temporarily a problem which impacted vertical spacing, this is now fixed. Final version.]

\documentclass{article}
\usepackage{enumitem}

\makeatletter
% GENERAL PURPOSE ENVIRONMENT SWALLOWING
% #1 is the name of the surrounding environment
% we swallow everything until finding the correct \end
% then we reinject \end{#1}
\def\@scoop{\@scoop}

\long\def\scoop  #1#2\end #3{\def\scoop@env{#1}\scoop@i #2\begin\@scoop }

\long\def\scoop@i #1\begin #2{\def\scoop@tmp{#2}%
                        \ifx\scoop@tmp\@scoop
                             \expandafter\scoop@end
                        \else\expandafter\scoop@ii
                        \fi }

\long\def\scoop@ii #1\begin\@scoop #2\end #3{\scoop@i #2\begin\@scoop }

\def\scoop@end {\expandafter\end\expandafter{\scoop@env}}

\makeatother

%% PATCHING THE enumerate, itemize and description ENVIRONMENTS
%%   *** FROM ENUMITEM ***
%% (starred environments enumerate*, etc.. NOT DONE)

\makeatletter
\def\end@concise {\def\endenumerate   {\enit@endenumerate}%
                  \def\enditemize     {\enit@enditemize}%
                  \def\enddescription {\enit@enddescription}}


\newcount\cnt@concise
\cnt@concise\@M

% à cause des \relax dans \renewenvironment? non.
% \def\@MAKECONCISE {%
%        \renewenvironment{enumerate}[1][]
%           {\scoop {enumerate}}{\aftergroup\end@concise\ignorespacesafterend}%
%        \renewenvironment{itemize}[1][]
%           {\scoop {itemize}}{\aftergroup\end@concise\ignorespacesafterend}%
%        \renewenvironment{description}[1][]
%           {\scoop {description}}{\aftergroup\end@concise\ignorespacesafterend}%
% }%

% OK I have solved it. Must be something done by enumitem.sty which didn't
% like the modification to \endenumerate etc..., so we delay. It works.
\def\@MAKECONCISE@i {%
    \def\enumerate   {\@MAKECONCISE@ii \scoop {enumerate}}%
    \def\itemize     {\@MAKECONCISE@ii \scoop {itemize}}%
    \def\description {\@MAKECONCISE@ii \scoop {description}}%
}%

\def\@MAKECONCISE@ii {%
    \def\endenumerate {\aftergroup\end@concise\ignorespacesafterend}%
    \let\enditemize     \endenumerate
    \let\enddescription \endenumerate
}% 

\renewenvironment{enumerate}[1][]
  {\advance\cnt@concise-\@ne\ifnum\cnt@concise<\@ne\@MAKECONCISE@i\fi
   \enit@enumerate\enitdp@enumerate{enum}\thr@@{#1}}
  {\enit@endenumerate}

\renewenvironment{itemize}[1][]
  {\advance\cnt@concise-\@ne\ifnum\cnt@concise<\@ne\@MAKECONCISE@i\fi
   \enit@itemize\enitdp@itemize{item}\thr@@{#1}}
  {\enit@enditemize}

\renewenvironment{description}[1][]
  {\advance\cnt@concise-\@ne\ifnum\cnt@concise<\@ne\@MAKECONCISE@i\fi
   \enit@description\enitdp@description{description}\@M{#1}}
  {\enit@enddescription}

\newcommand{\SetConciseLevelTo}[1]{\cnt@concise #1\relax }

\makeatother

\begin{document}

\hrule
\medskip

\texttt{CONCISE LEVEL = 1}
\SetConciseLevelTo {1}


\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{itemize}
  \item First point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
  \begin{description}
  \item[More elaboration of the First point:] here we explain more things.
    \begin{itemize}
    \item specific details ...
    \item ... and again specific details
    \end{itemize}
  \end{description}
\item Second point concisely.
  \begin{itemize}
  \item Second point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
   \end{itemize}
\item Third point concisely.
  \begin{itemize}
  \item Third point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Fourth point concisely.
  \begin{itemize}
  \item Fourth point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\end{enumerate}

Again:
\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{itemize}
  \item First point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
  \begin{description}
  \item[More elaboration of the First point:] here we explain more things.
    \begin{itemize}
    \item specific details ...
    \item ... and again specific details
    \end{itemize}
  \end{description}
\item Second point concisely.
  \begin{itemize}
  \item Second point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
   \end{itemize}
\item Third point concisely.
  \begin{itemize}
  \item Third point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Fourth point concisely.
  \begin{itemize}
  \item Fourth point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\end{enumerate}

\hrule
\medskip
\texttt{CONCISE LEVEL = 2}

\SetConciseLevelTo {2}

\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{itemize}
  \item First point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
  \begin{description}
  \item[More elaboration of the First point:] here we explain more things.
    \begin{itemize}
    \item specific details ...
    \item ... and again specific details
    \end{itemize}
  \end{description}
\item Second point concisely.
  \begin{itemize}
  \item Second point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Third point concisely.
  \begin{itemize}
  \item Third point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Fourth point concisely.
  \begin{itemize}
  \item Fourth point in elaboration.
    \begin{description}
    \item[Specific details]...
    \end{description}
  \end{itemize}
\end{enumerate}

\hrule
\medskip
\texttt{CONCISE LEVEL = 3}

\SetConciseLevelTo {3}

\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{itemize}
  \item First point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
  \begin{description}
  \item[More elaboration of the First point:] here we explain more things.
    \begin{itemize}
    \item specific details ...
    \item ... and again specific details
    \end{itemize}
  \end{description}
\item Second point concisely.
  \begin{itemize}
  \item Second point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
   \end{itemize}
\item Third point concisely.
  \begin{itemize}
  \item Third point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Fourth point concisely.
  \begin{itemize}
  \item Fourth point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\end{enumerate}

\hrule
\medskip
\texttt{CONCISE LEVEL = 1}

\SetConciseLevelTo {1}

\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{itemize}
  \item First point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
  \begin{description}
  \item[More elaboration of the First point:] here we explain more things.
    \begin{itemize}
    \item specific details ...
    \item ... and again specific details
    \end{itemize}
  \end{description}
\item Second point concisely.
  \begin{itemize}
  \item Second point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Third point concisely.
  \begin{itemize}
  \item Third point in elaboration.
    \begin{description}
    \item[Specific details] ...
    \end{description}
  \end{itemize}
\item Fourth point concisely.
  \begin{itemize}
  \item Fourth point in elaboration.
    \begin{description}
    \item[Specific details]...
    \end{description}
  \end{itemize}
\end{enumerate}

\hrule

\end{document}

concise lists


first version

(I think there was a bug, but it doesn't matter now)

Try this

\documentclass{article}
\usepackage{enumitem}

\makeatletter
% GENERAL PURPOSE ENVIRONMENT SWALLOWING
% #1 is the name of the surrounding environment
% we swallow everything until finding the correct \end
% then we reinject \end{#1}
\def\@scoop{\@scoop}

\long\def\scoop  #1#2\end #3%
    {\def\scoop@env{#1}\scoop@i #2\@scoop\begin\@scoop }

\long\def\scoop@i #1\begin #2{\def\scoop@tmp{#2}%
                        \ifx\scoop@tmp\@scoop
                             \expandafter\scoop@end
                        \else\expandafter\scoop@ii
                        \fi }

\long\def\scoop@ii #1\@scoop\begin\@scoop #2\end #3%
     {\scoop@i #2\@scoop\begin\@scoop }

\def\scoop@end {\expandafter\end\expandafter{\scoop@env}}

% 
\def\endscoop {\def\endenumerate{\enit@endenumerate}}
%

\renewenvironment{enumerate}[1][]
  {\ifConcise
       \renewenvironment{enumerate}[1][]{\scoop {enumerate}}{\endscoop \par}%
   \fi
   \enit@enumerate\enitdp@enumerate{enum}\thr@@{#1}}
  {\enit@endenumerate}
\makeatother

\newif\ifConcise


\begin{document}\thispagestyle{empty}

\hrule
\smallskip

\texttt{CONCISE IS TRUE}
\Concisetrue
\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{enumerate}[label=\alph*.]
  \item First point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
  \end{enumerate}
\item Second point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Second point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
   \end{enumerate}
\item Third point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Third point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
  \end{enumerate}
\item Fourth point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Fourth point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\bigskip
\texttt{CONCISE IS NOW FALSE}

\Concisefalse
\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{enumerate}[label=\alph*.]
  \item First point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
   \end{enumerate}
\item Second point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Second point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
   \end{enumerate}
\item Third point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Third point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
   \end{enumerate}
\item Fourth point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Fourth point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\bigskip
\texttt{CONCISE IS AGAIN TRUE}

\Concisetrue
\begin{enumerate}[label=\Roman*.]
\item First point concisely.
  \begin{enumerate}[label=\alph*.]
  \item First point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
  \end{enumerate}
\item Second point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Second point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
   \end{enumerate}
\item Third point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Third point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
   \end{enumerate}
\item Fourth point concisely.
  \begin{enumerate}[label=\alph*.]
  \item Fourth point in elaboration.
    \begin{enumerate}[label=\arabic*.]
    \item Specific details...
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\smallskip
\hrule

\end{document}

concise enumerates

2
  • That seems to work-- I need to pull out a TeXbook to decipher it. Is the use of "enumerate" hardcoded into \def\endscoop ? it might be nice to work for itemize environments too, above a certain level. hoping for something more general.. ideally with an argument [n] to automatically suppress if level > n. But I will play with this and see what I can make it do. – Brandon Kuczenski Oct 14 '13 at 22:29
  • Works like a charm! incidentally, the example is more readable if you put the content of the outline in a \def. – Brandon Kuczenski Oct 15 '13 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.