1

The outlines package restarts the numbering of the item following a \0 entry, which is a paragraph type entry. The documentation for the outlines package provides preamble code to avoid the restart. I also use \usepackage[inline]{enumitem}\setlist{nosep} to reduce vertical spacing between outline items. The preamble code to avoid restarting the outline counter does not typeset with the reduced spacing of the item level following the \0 command. Lower item levels typeset with the correct spacing. My example demonstrates this. I would like to remove the extra spacing. I just noticed that the code below also labels the first and second levels with integers, which is not good. Perhaps a better solution to my specific problem is to avoid the extra preamble code and remove the command \renewcommand{\outlinei}{cenumerate}, and reset the counter for the item following a \0 command manually. I have not been able to do this.

\usepackage{outlines}
\usepackage[inline]{enumitem}
  \setlist{nosep}
% The following code comes from the outlines package manual
  \newcounter{cenum}
  \newcounter{cenumsaved}
  \setcounter{cenumsaved}{0}
  \newcommand{\labelcenum}{\arabic{cenum}.}
  \newenvironment{cenumerate}%
    {\begin{list}{\labelcenum}{\usecounter{cenum}}%
    \setcounter{cenum}{\value{cenumsaved}}}%
      {\setcounter{cenumsaved}{\value{cenum}}%
    \end{list}}
\begin{document}
\renewcommand{\outlinei}{cenumerate} % Comment this command to see the change in spacing
\begin{outline}[enumerate]
  \1 First item - notice the extra spacing after this item
    \2 First subitem
    \2 Second subitem
  \0 Some text
  \1 Second item - notice the extra spacing before and after this item
    \2 First subitem
    \2 Second subitem
  \1 Third item - notice the extra spacing before and after this item
    \2 First subitem
    \2 Second subitem
\end{outline}
\end{document}
2

Something like this?

\documentclass{article}
\usepackage{outlines}
  \newcounter{cenumi}
  \newcounter{cenumisaved}
  \setcounter{cenumisaved}{0}
  \newcommand{\labelcenumi}{\arabic{cenumi}.}
  \newenvironment{cenumeratei}%
    {\begin{list}{\labelcenumi}{\usecounter{cenumi}\partopsep=0pt\topsep=0pt\itemsep=0pt\parsep=0pt}%
    \setcounter{cenumi}{\value{cenumisaved}}}%
      {\setcounter{cenumisaved}{\value{cenumi}}%
    \end{list}}

  \newcounter{cenumii}
  \setcounter{cenumii}{0}
  \newcommand{\labelcenumii}{(\alph{cenumii})}
  \newenvironment{cenumerateii}%
    {\begin{list}{\labelcenumii}{\usecounter{cenumii}\partopsep=0pt\topsep=0pt\itemsep=0pt\parsep=0pt}%
    }%
      {%
    \end{list}}


\begin{document}
\renewcommand{\outlinei}{cenumeratei}
\renewcommand{\outlineii}{cenumerateii}
\begin{outline}
  \1 First item - notice the extra spacing after this item
    \2 First subitem
    \2 Second subitem
  \0 Some text
  \1 Second item - notice the extra spacing before and after this item
    \2 First subitem
    \2 Second subitem
  \1 Third item - notice the extra spacing before and after this item
    \2 First subitem
    \2 Second subitem
\end{outline}
\end{document}

Perhaps the code is not optimised. Works only for two levels (but easily expandable for 3 or 4 levels).

enter image description here

1

I accepted the solution posted above by quark67 and later realized that cross-references to nested items listed only the parent item. For example, a cross-reference to item 1(a) reduced to referencing item 1. I sent D.P. Story a personal note concerning this issue. Don created a different solution, posted below, which respects all cross-references and adds more flexibility. Don’s solution allows for restoring the item counter at any nested, previous level by following the \0 command with a \n command, where n is the level to be continued. An outline environment cannot begin with a \0 command so text that precedes an outline should be entered before this environment.

\documentclass{article}
\usepackage{outlines}
\usepackage{enumitem}
\usepackage{calc} % dps
\setlist{noitemsep}
\setlist{nolistsep}
\makeatletter
\newif\if@needsRsm\@needsRsmfalse
\def\resumeToDefault{%
  \global\let\resume@ti\@empty
  \global\let\resume@tii\@empty
  \global\let\resume@tiii\@empty
  \global\let\resume@tiv\@empty
}
\resumeToDefault
\def\ol@csarg#1#2{\expandafter#1\csname#2\endcsname}
% Executed at \0
\def\setPrevLevel{\global\@needsRsmtrue % dps
  \xdef\@prevLevel{\@curLevel}}
\def\@prevLevel{0}
% Placed within \curLevel, which is expanded at the beginning of \1, \2, \3, \4
\def\resumeIfNeeded#1{\if@needsRsm\def\@next{\expandafter
  \resumeAt\expandafter{\csname#1\endcsname}}\else\let\@next\relax\fi\@next}
% Expanded within each level: \1, \2, \3, \4
\def\curLevel#1{\def\@curLevel{#1}\resumeIfNeeded{#1}}
% dps modify outline package: \ol@z (insert \item[] so we can use \0 at any level
\renewcommand{\ol@z}{%
  \ol@commands%
    {}%                                        0
    {\ol@inci}%                                1
    {\ol@inci\item[]\ol@incii}%                2
    {\ol@inci\item[]\ol@incii\item[]\ol@inciii}%             3
    {\ol@inci\item[]\ol@incii\item[]\ol@inciii\item[]\ol@inciiii}}% 4
% dps modify outline package: outline env (add \olsave, \curLevel)
\renewenvironment{outline}[1][]{%
  \ifthenelse{\equal{#1}{}}{}{\renewcommand{\ol@type}{#1}}%
  \ol@z%
  \newcommand{\0}{\olsave\setPrevLevel\ol@toz\ol@z}% dps incorporate \olsave into level \0
  \newcommand{\1}{\curLevel{1}\ol@toi\ol@i\resume@ti\item}%
  \newcommand{\2}{\curLevel{2}\ol@toii\ol@ii\resume@tii\item}%
  \newcommand{\3}{\curLevel{3}\ol@toiii\ol@iii\resume@tiii\item}%
  \newcommand{\4}{\curLevel{4}\ol@toiiii\ol@iiii\resume@tiv\item}%
}{%
  \ol@toz\ol@exit%
}
\def\UD#1{\noexpand\setcounter{enum#1}{\@nameuse{s@veAt#1}}%
  \global\noexpand\ol@csarg\let{resume@t\@roman\@tempcnta}\noexpand\@empty}
\newcommand\resumeAt[1]{\global\@needsRsmfalse\begingroup\resumeToDefault
  \edef\r@t{\expandafter\@roman\expandafter\@gobble\string#1}%
  \edef\n@t{\expandafter\@gobble\string#1}%
% When we are resuming at a higher level then the previous level,
% we zero all counters out below (new environment starting)
  \ifnum\n@t>\@prevLevel\relax
    \zeroOutBelow{\@prevLevel}\olsave\fi
  \@tempcnta=0\relax\toks@={}%
  \@whilenum\@tempcnta<\n@t\relax\do{\advance\@tempcnta\@ne
    \edef\x{\UD{\@roman\@tempcnta}}%
    \toks2=\expandafter{\x}\edef\y{\the\toks@\the\toks2 }%
    \toks@=\expandafter{\y}%
  }%
  \edef\x{\noexpand\ol@csarg\noexpand
    \xdef{resume@t\r@t}{\noexpand\the\noexpand\toks@}}\x
  \endgroup\ignorespaces
}
\def\zeroOutBelow#1{\begingroup
  \@tempcnta#1\relax
  \@whilenum\@tempcnta<4\relax\do{%
    \advance\@tempcnta\@ne
    \setcounter{enum\@roman\@tempcnta}{0}}%
  \endgroup
}
\def\olsave{\@tfor\n:={i}{ii}{iii}{iv}\do{%
  \ol@csarg\xdef{s@veAt\n}{\the\value{enum\n}}}% do
}
\makeatother
\begin{document}
We begin the outline here
\begin{outline}[enumerate]
  \1 First item
    \2  First subitem
      \3\label{cr} Item with label
        \4  Fourth level
        \4  Fourth level, again
\0 This is another comment
    \2 Second subitem
\0 Some text here, let's make it long to see what happens when we wrap around to the next line.
    \1 Second item
      \2 \textbf{See item} \ref{cr}
        \3 The above reference reads``See item 1''
          \4 Let's not forget level 4
          \4 Another level 4
\0 Hello world!
    \2 Second subitem
    \2 Second subitem
\0 Make my day!
  \1 A third top level
    \2 Level 2 item
      \3 Level 3 item
\0 Let's break the outline here with a comment
      \3 Level 3 item
\0 Do we continue as expected ?
      \3 Level 3 for testing
%        \4 More four to follow
\0 Now test level 4 in the same way
      \4 Level 4
      \4 Level 4, again
\0 Back to level 1
  \1 back to level 1
    \2 Another important point
\end{outline}
\end{document}

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.