2

I have a list that looks like this:

  • Overview of item 1
    • Part 1 of more in depth description of item 1
    • Part 2 of more in depth description of item 1
    • Part 3 of more in depth description of item 1
  • Overview of item 2
    • Part 1 of more in depth description of item 2
    • Part 2 of more in depth description of item 2
    • Part 3 of more in depth description of item 2
  • etc...

I'd like to, without having to copy and paste the items, have a separate list at the top of my document to show only the top-level items in the list to serve as an overview. So, the overview of the list above, would look like:

  • Overview of item 1
  • Overview of item 2
  • etc...

To further clarify, my document looks something like:

\documentclass[10pt, letterpaper]{article}

\usepackage{enumitem}


\begin{document}

\begin{enumerate}
    \item Overview of item 1
    \begin{enumerate}[label = (\Alph*)]
        \item Part 1 of more in depth description of item 1
        \item Part 2 of more in depth description of item 1
        \item Part 3 of more in depth description of item 1
    \end{enumerate}
    \item Overview of item 2
    \begin{enumerate}[label = (\Alph*)]
        \item Part 1 of more in depth description of item 2
        \item Part 2 of more in depth description of item 2
        \item Part 3 of more in depth description of item 2
    \end{enumerate}
    \item etc...
\end{enumerate}

\end{document}

I was wondering what an elegant way of doing this would be.

4
  • 1
    Welcome to TeX.SX! Please provide a compilable document to start with. And at first glance I think, copy and paste is easier, somewhat
    – user31729
    May 16 '16 at 12:56
  • If I only did one time, I'd agree with that. However, with the amount of updates that I need to do, it quickly becomes more of a hassle.
    – zuramu
    May 16 '16 at 14:34
  • Are all lists just like the example? i mean not deeper then level 2.
    – touhami
    May 16 '16 at 17:59
  • The most I have are lists that go up to three or four deep.
    – zuramu
    May 16 '16 at 19:11
1

Here is a solution (a trick)

\documentclass[10pt, letterpaper]{article}

\usepackage{enumitem}
\usepackage{etoolbox}
\newcounter{mt}
\BeforeBeginEnvironment{enumerate}{\stepcounter{mt}\setbox\themt\vbox\bgroup}
\AfterEndEnvironment{enumerate}{\egroup\ifnum\value{mt}=1\unvbox1\fi\addtocounter{mt}{-1}}

\begin{document}

\begin{enumerate}
    \item Overview of item 1 
    \begin{enumerate}[label = (\Alph*)]
        \item Part 1 of more in depth description of item 1
        \item Part 2 of more in depth description of item 1
        \item Part 3 of more in depth description of item 1
    \end{enumerate}
    \item Overview of item 2
    \begin{enumerate}[label = (\Alph*)]
        \item Part 1 of more in depth description of item 2
        \item Part 2 of more in depth description of item 2
        \item Part 3 of more in depth description of item 2
    \end{enumerate}
    \item etc...
\end{enumerate}

bla bla

\begin{enumerate}
    \item Overview of item A1
    \begin{enumerate}[label = (\Alph*)]
        \item Part 1 of more in depth description of item 1
         \begin{enumerate}[label = (\alph*)]
             \item Part 1 of more in depth description of item 1.A
             \item Part 2 of more in depth description of item 1.A
             \item Part 3 of more in depth description of item 1.A
        \end{enumerate}         
        \item Part 2 of more in depth description of item 1
        \item Part 3 of more in depth description of item 1
    \end{enumerate}
    \item Overview of item A2
    \begin{enumerate}[label = (\Alph*)]
        \item Part 1 of more in depth description of item 2
        \item Part 2 of more in depth description of item 2
        \item Part 3 of more in depth description of item 2
    \end{enumerate}
    \item etc...A ...
\end{enumerate}

\end{document}
5
  • I can see where you're going with this, and this seems to be exactly what I'm looking for. However, both examples only show the top-level items.
    – zuramu
    May 17 '16 at 12:37
  • @zuramu sorry may be i don't understand the question isn't this what you look for?
    – touhami
    May 17 '16 at 13:09
  • @zuramu you want to show the top level list first and then the full list? is it?
    – touhami
    May 17 '16 at 13:11
  • Yeah, that's what I want to do, but this shows only the top-level list both times.
    – zuramu
    May 17 '16 at 13:44
  • @zuramu sorry this is not what i understand i will try
    – touhami
    May 17 '16 at 15:26
2

An intermediate version with automatic \item usage and the \toplevel* command wrapper, that ignores \sublevel commands then.

\documentclass{article}

\usepackage{environ}

\usepackage{enumitem}

\usepackage{xparse}

\newif\ifsublevels
\sublevelstrue
\ExplSyntaxOn

\NewDocumentCommand{\sublevel}{m}{%
  \ifsublevels
  \seq_set_from_clist:Nn \l_tmpa_seq {#1}
  \begin{enumerate}
  \seq_map_inline:Nn \l_tmpa_seq {\item ##1}
  \end{enumerate}
  \fi
}


\NewDocumentCommand{\toplevel}{sO{}m}{%
  \IfBooleanT{#1}{%
    \global\sublevelsfalse
  }%
  \seq_set_from_clist:Nn \l_tmpb_seq {#3}
  \begin{enumerate}[#2]
    \seq_map_inline:Nn  \l_tmpb_seq {\item ##1}
  \end{enumerate}
}

\ExplSyntaxOff


\begin{document}

\toplevel{Top item 1 \sublevel{Sub level 1, Sub level 2, Sub level 3}, Top Item 2 \sublevel{Sub level 11, Sub level 21}}

\toplevel*{Top item 1 \sublevel{Sub level 1, Sub level 2, Sub level 3}, Top Item 2 \sublevel{Sub level 11, Sub level 21}}


\end{document}
1

I suggest defining a special environment for this application, which gives you more freedom for choosing what to show.

\documentclass[10pt, letterpaper]{article}

\usepackage{enumitem}
\usepackage{environ}

\makeatletter
\newenvironment{overview}[1]
 {\begin{enumerate}\relax
    \ifnum#1=0
      \let\do@suboverview\@gobble
    \else
      \def\do@suboverview##1{%
        \begin{enumerate}[label=(\Alph*)]##1\end{enumerate}%
      }%
    \fi
 }
 {\end{enumerate}}
\NewEnviron{suboverview}{\do@suboverview{\BODY}}
\makeatother


\begin{document}

\section{Short overview}

\begin{overview}{0}
    \item Overview of item 1
    \begin{suboverview}
        \item Part 1 of more in depth description of item 1
        \item Part 2 of more in depth description of item 1
        \item Part 3 of more in depth description of item 1
    \end{suboverview}
    \item Overview of item 2
    \begin{suboverview}
        \item Part 1 of more in depth description of item 2
        \item Part 2 of more in depth description of item 2
        \item Part 3 of more in depth description of item 2
    \end{suboverview}
    \item etc...
\end{overview}

\section{Long overview}

\begin{overview}{1}
    \item Overview of item 1
    \begin{suboverview}
        \item Part 1 of more in depth description of item 1
        \item Part 2 of more in depth description of item 1
        \item Part 3 of more in depth description of item 1
    \end{suboverview}
    \item Overview of item 2
    \begin{suboverview}
        \item Part 1 of more in depth description of item 2
        \item Part 2 of more in depth description of item 2
        \item Part 3 of more in depth description of item 2
    \end{suboverview}
    \item etc...
\end{overview}

\end{document}

As you see, passing from the short to the long overview only needs to change the argument to overview.

enter image description here

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.