3

I want to make a unique list in which I have two different enumerations, one enumeration for every Demonstration and the other one for the Definitions. Something like:

1) Def. of Pippo

2) Def. of Pluto

[1] Prove that Pluto is the dog of Pippo

3) Def. of Topolino

[2] Prove that Topolino and Pippo are friends

The idea of the code would be something like:

\begin{enumerate} 
\item_def Def. of Pippo
\item_def Def. of Pluto
\item_proof Prove that Pluto is the dog of Pippo
\item_def Def. of Topolino
\item_proof Prove that Topolino and Pippo are friends
\end{enumerate}
1
  • Can you show some code you'd use to represent this type of output? Just use the regular enumerate environment as the base case (which won't provide the correct enumeration, of course). It'll provide some sense of how you want the suggested solutions to adhere to your requirement(s). – Werner Dec 4 '19 at 18:21
2

As an alternative, if you wish to avoid the enumitem package*, this might be of use.

I don't know if you wanted indents - you could always stick some spacing into the definition if so.

\newcounter{enumcounter} % Used to reset counters - if you've only two new itemtypes,
                         % probably as easy to reset them explicitly, but for more this
                         % is more efficient
\newcounter{defcount}[enumcounter] % Counts your definition items,  resets every time enumcounter increments
\newcounter{proofcount}[enumcounter]

\newenvironment{myenumerate}{\begin{description}\stepcounter{enumcounter}}{\end{description}}
% defined a new environment, which uses description instead of enumerate or itemize, to avoid the pre-existing
% counters. The spacing is not identical, granted.

\newcommand*{\itemdef}{\item\addtocounter{defcount}{1}(\thedefcount) } % increments the counter, describes item look 
\newcommand*{\itemproof}{\item\addtocounter{proofcount}{1}[\theproofcount] }

\begin{document}
Here is an example:
\begin{myenumerate} 
\itemdef Def. of Pippo
\itemdef Def. of Pluto
\itemproof Prove that Pluto is the dog of Pippo
\itemdef Def. of Topolino
\itemproof Prove that Topolino and Pippo are friends
\end{myenumerate}

And another list of things to check that counters reset:
\begin{myenumerate}
\itemproof Blah
\itemdef Bleep
\itemproof Bloop
\end{myenumerate}
And another line to check that vertical spacing is fine.

enter image description here

*I realise everyone on here loves it, which is fair enough, but it's one of the first packages that has to be removed when it hits our production editing queue because of clashes with our setup.

3
  • 1
    Wow thank you very much Fintan. Alan solution was good but yours is perfect! – paolopazzo Dec 5 '19 at 7:40
  • Welcome to the site. Could you provide some context for your last comment? No need to give exact information, but what is your production editing queue for? (Also, if you want to use references to the numbered items, you'd be better off using \refstepcounter instead of simple \addtocounter.) – Alan Munn Dec 5 '19 at 14:06
  • I copy edit math articles prior to journal publication; proofreading, tidying Latex, making the tex files fit with journal style etc. We eliminate many of the packages authors include and replace them with lower-level commands, so that we can be more sure of everything that's going on in the tex files we use. The enumitem package, specifically, I'm sure is absolutely reliable, but it doesn't play well with our layout parameters. It's usually straightforward to replace, but it's nice for me if people have avoided it :P Fair point on refstepcounter. – Fintan Dec 5 '19 at 14:38
7

Something like this should do what you want. The enumitem package allows you to easily create custom lists, and lists can be specified to resume. In the current context, since the resumed list is inside the definition list, its counter will be local to that list. Consult the enumitem documentation (or other questions on the site) for spacing parameters etc.

\documentclass{article}
\usepackage{enumitem}
\newlist{defn}{enumerate}{1}
\newlist{demo}{enumerate}{1}
\setlist[defn]{label={\arabic*)}}
\setlist[demo]{label={[\arabic*]},resume}
\begin{document}
\begin{defn}

\item Def. of Pippo

\item Def. of Pluto

\begin{demo}
\item Prove that Pluto is the dog of Pippo
\end{demo}

\item Def. of Topolino

\begin{demo}
\item Prove that Topolino and Pippo are friends
\end{demo}
\end{defn}
\end{document}

output of code

0

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.