Depending on the usage, enumitem
allows to specify a label
(and ref
) option to enumerate
. Here is a minimal example that steps some counter (mycount
) at the start of every enumerate
, and prints that counter in "fractional amounts":
\documentclass{article}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\newcounter{mycount} \renewcommand{\themycount}{\arabic{mycount}}%
\AtBeginEnvironment{enumerate}{\stepcounter{mycount}}% Increment mycount at \begin{enumerate}
\setlist[enumerate]{label=\themycount.\arabic*,ref=\themycount.\arabic*}
\begin{document}
\noindent Here is some text.
\begin{enumerate}
\item An item
\item Another item
\item Yet another item
\end{enumerate}
Here is some more text.
\begin{enumerate}
\item An item
\item Another item
\item Yet another item
\end{enumerate}
\end{document}
etoolbox
provides the means to "tap into" the start of enumerate
and update the mycount
counter and every instance.
label
refers to how the enumeration label will be typeset, while ref
refers to how it will be referenced from within the document (if you're using \label
and \ref
). The settings for enumerate
are made global (via \setlist[enumerate]{...}
), although it could also be localized to a particular enumerate
environment via an option argument:
\begin{enumerate}[label=.., ...]
If you're interested in labelling lists via some other counter (like section
, or subsection
, for instance), this is easily modifiable.
Leave a blank line (or use \par
):
\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{enumerate}
\item
\begin{lstlisting}
x = [x for x in xrange(4, 9)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\end{enumerate}
\end{document}
Or use \lstinline
:
\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{enumerate}
\item
\lstinline{x = [x for x in xrange(4, 9)]}
\item
\lstinline{x = [x for x in xrange(6)]}
\item
\lstinline{x = [x for x in xrange(6)]}
\end{enumerate}
\end{document}
Best Answer
I hope this helps (under the assumption that you are trying to create a continuous list of enumerated which are nested, based on your example).
By invoking
enumitem
package and usingresume
option, you can achieve what you (might) want.which gives you
You can play with the type of counters to change their apperance :)
As OP requested,
Update in MWE:
to get: (not able to upload the images)
https://imgur.com/kh3gfbT