describe el espaciado del paquete

describe el espaciado del paquete

El paquete de esquemas reinicia la numeración del elemento después de una entrada \0, que es una entrada de tipo párrafo. La documentación del paquete de esquemas proporciona un código de preámbulo para evitar el reinicio. También lo uso \usepackage[inline]{enumitem}\setlist{nosep}para reducir el espacio vertical entre los elementos del contorno. El código de preámbulo para evitar reiniciar el contador de esquema no se escribe con el espacio reducido del nivel de elemento después del comando \0. Los niveles de elementos inferiores se componen con el espacio correcto. Mi ejemplo lo demuestra. Me gustaría eliminar el espacio adicional. Me acabo de dar cuenta de que el siguiente código también etiqueta el primer y segundo nivel con números enteros, lo cual no es bueno. Quizás una mejor solución a mi problema específico sea evitar el código de preámbulo adicional y eliminar el comando \renewcommand{\outlinei}{cenumerate}y restablecer el contador del elemento siguiendo un comando \0 manualmente. No he podido hacer esto.

\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}

Respuesta1

¿Algo como esto?

\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}

Quizás el código no esté optimizado. Funciona sólo para dos niveles (pero fácilmente ampliable para 3 o 4 niveles).

ingrese la descripción de la imagen aquí

Respuesta2

Acepté la solución publicada anteriormente por quark67 y luego me di cuenta de que las referencias cruzadas a elementos anidados enumeraban solo el elemento principal. Por ejemplo, una referencia cruzada al punto 1(a) se redujo a hacer referencia al punto 1. Envié a DP Story una nota personal sobre este tema. Don creó una solución diferente, publicada a continuación, que respeta todas las referencias cruzadas y agrega más flexibilidad. La solución de Don permite restaurar el contador de elementos en cualquier nivel anterior anidado siguiendo el comando \0 con un comando \n, donde n es el nivel a continuar. Un entorno de esquema no puede comenzar con un comando \0, por lo que el texto que precede a un esquema debe ingresarse antes de este entorno.

\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}

información relacionada