Guardar valor de contadores dinámicos

Guardar valor de contadores dinámicos

Me gustaría obtener la organización de los siguientes artículos:

  • Sección a
    • Categoría 1
      • punto 1.1
      • punto 1.2
    • categoría 2
      • punto 2.1
  • sección B
    • Categoría 1
      • punto 1.3
      • punto 1.4
    • categoría 2
      • punto 2.2
      • punto 2.3
  • sección C
    • Categoría 1
      • punto 1.5
    • categoría 2
      • punto 2.4
      • punto 2.5
      • punto 2.6

con un código como:

\section{A}
\resetcategories
    \nextcategory
        \myitem{}
        \myitem{}
    \nextcategory
        \myitem{}

\section{B}
\resetcategories
    \nextcategory
        \myitem{}
        \myitem{}
    \nextcategory
        \myitem{}
        \myitem{}

\section{C}
\resetcategories
    \nextcategory
        \myitem{}
    \nextcategory
        \myitem{}
        \myitem{}
        \myitem{}

Por lo tanto, hay un contador de elementos dinámico dentro de cada categoría dinámica, pero su valor se guarda y se puede reanudar incluso cuando se reinicia el contador de categorías.

¿Existe una forma sencilla de lograr esto con contadores o variables personalizados?

Respuesta1

La manipulación común con registros TeX se ve así:

\newcount\catnum
\expandafter \newcount\csname itemnum1\endcsname
\expandafter \newcount\csname itemnum2\endcsname
\def\inum{itemnum\the\catnum}

\def\bull#1{\noindent\hskip#1\parindent
            \hangindent=#1\parindent
            \llap{$\bullet$\ }\ignorespaces
}
\def\section#1{\par\bull1 \catnum=0 section #1}
\def\nextcategory{\par\advance\catnum by1 \bull2 category \the\catnum}
\def\myitem{\par
   \advance\csname\inum\endcsname by1 \bull3
   item \the\catnum.\expandafter\the\csname\inum\endcsname}
\let\resetcategories=\relax

\section{A}
\resetcategories
    \nextcategory
        \myitem{}
        \myitem{}
    \nextcategory
        \myitem{}

\section{B}
\resetcategories
    \nextcategory
        \myitem{}
        \myitem{}
    \nextcategory
        \myitem{}
        \myitem{}

\section{C}
\resetcategories
    \nextcategory
        \myitem{}
    \nextcategory
        \myitem{}
        \myitem{}
        \myitem{}

\bye

Respuesta2

¿Quizás algo como esto, usando enumitemlistas de "reanudación"?

\documentclass{article}
\usepackage{enumitem}

\newlist{sectionlist}{enumerate}{3}
\setlist[sectionlist,1]{label={\Alph*}}
\setlist[sectionlist,2]{label={\arabic*}}
\setlist[sectionlist,3]{label*={.\arabic*}}


\begin{document}
\begin{sectionlist}
\item Section

  \begin{sectionlist}
  \item Category 
    \begin{sectionlist}[series=first]
    \item Foo
    \item Other Foo
    \end{sectionlist}
  \item Category
    \begin{sectionlist}[series=second]
    \item Foo
    \item Other Foo
    \end{sectionlist}
  \end{sectionlist}

\item Section

  \begin{sectionlist}
  \item Category 

    \begin{sectionlist}[resume=first]
    \item Foo
    \item Other Foo
    \end{sectionlist}

  \item Category 
    \begin{sectionlist}[resume=second]
    \item Foo
    \item Other Foo
    \item Yet another foo
    \end{sectionlist}
  \end{sectionlist}



\item Section

  \begin{sectionlist}
  \item Category 

    \begin{sectionlist}[resume=first]
    \item Foo
    \item Other Foo
    \item Yet another foo
    \end{sectionlist}

  \item Category 
    \begin{sectionlist}[resume=second]
    \item Foo
    \item Other Foo
    \item Yet another foo
    \item Even yet another foo
    \end{sectionlist}
  \end{sectionlist}



\end{sectionlist}


\end{document}

ingrese la descripción de la imagen aquí

información relacionada