11

How can I create enumerated lists, but without breaking flow if we split it by another article/section/chapter?

Example output I want to achieve:

# Article I
## Section 1 - something
1. something
2. something

## Section 2 - something
3. something
4. something

## Section 3 - something
5 something
6. something

# Article II
## Section 1 - something
7. something
8. something

## Section 2 - something
9. something
10. something

## Section 3 - something
11. something
12. something

Currently I got an idea as below, but it's far from what I'd like to achieve, because for maintenance I'd also have to manually properly count and the list of elements isn't continuous.

\begin{document}

\section*{Article I}

\section{Section 1 - something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\section{Section 2 - something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\section{Section 3 - something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\section*{Article II}

\section{Section 1 - something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\section{Section 2 - something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\section{Section 3 - something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\end{document}
3
  • Welcome to TeX.SE.
    – Mico
    Commented May 20, 2023 at 13:07
  • 1
    The list environments have a [resume] option that doesn't reset the list counter. Have you tried that?
    – Bill Nace
    Commented May 20, 2023 at 13:08
  • 1
    This answer should work: tex.stackexchange.com/a/135727/21053 Commented May 20, 2023 at 23:13

3 Answers 3

24

I suggest defining your own environment, so you can tailor it to your needs. Adding the resume option is the key.

\documentclass{article}
\usepackage{enumitem}

\newlist{points}{enumerate}{1}
\setlist[points]{label=\arabic*.,resume}

\begin{document}

\section*{Article I}

\section{Section 1 - something}
\begin{points}
  \item something
  \item something
\end{points}

\section{Section 2 - something}
\begin{points}
  \item something
  \item something
\end{points}

\section{Section 3 - something}
\begin{points}
  \item something
  \item something
\end{points}

\section*{Article II}

\section{Section 1 - something}
\begin{points}
  \item something
  \item something
\end{points}

\section{Section 2 - something}
\begin{points}
  \item something
  \item something
\end{points}

\section{Section 3 - something}
\begin{points}
  \item something
  \item something
\end{points}

\end{document}

enter image description here

12

I suggest you (a) load the enumitem package in preamble and (b) change all but the first instance of \begin{enumerate} to \begin{enumerate}[resume].

enter image description here

\documentclass{article}
\usepackage{enumitem}
\begin{document}

\section*{Article I}

\section{Section 1---something}
\begin{enumerate}
  \item something
  \item something
\end{enumerate}

\section{Section 2---something}
\begin{enumerate}[resume]
  \item something
  \item something
\end{enumerate}

\section{Section 3---something}
\begin{enumerate}[resume]
  \item something
  \item something
\end{enumerate}

\section*{Article II}

\section{Section 1---something}
\begin{enumerate}[resume]
  \item something
  \item something
\end{enumerate}

\section{Section 2---something}
\begin{enumerate}[resume]
  \item something
  \item something
\end{enumerate}

\section{Section 3---something}
\begin{enumerate}[resume]
  \item something
  \item something
\end{enumerate}

\end{document}
0
0

Intentionally or not, your "example output" is a source markdown text. So one simple way is just compile "as is" the supposed output with quarto in PDF format (via LaTeX). In markdown, only the first number of each list is relevant, so that a sequence of items as "3,7,9" will be renumbered automatically to "3,4,5", so in one hand you have the extreme simplicity of the format but on the other that is up to you fix manually the first number of each sub-list.

---
format: pdf
---

# Article I
## Section 1 - something
1. something
2. something

## Section 2 - something
3. something
4. something
...

MWE

OK, the headers are not as in your LaTeX version but only not numbered sections and subsections, this this can be changed easily in this way:

---
format: pdf
number-sections: true
---

# Article I {.unnumbered}
# Section 1 - something
etc.

If this is not a option anyway (you do not want use markdown and/or fix manually the first item) another option is LaTeX using linguex and use an alternative \item command (\ex.) but avoiding the annoying enumerate environments. In this simplified syntax, however the item must end with an explicit paragraph break (i.e., with a blank line, or \par, that I personally prefer to avoid mistakes and code less scattered). This is confusing at first because people often leave blank lines among items but is also correct type items in contiguous lines (as you have done) or even is the same line (e.g.\item foo \item bah that fortunately is usually avoided for the sake of code readability) but with linguex you must be careful not to remove a blank line between items. In spite of this, is not easier type the following example?

\documentclass{article}
\usepackage{linguex}
% optional: 
    \renewcommand{\ExLBr}{} 
    \renewcommand{\ExRBr}{.}  
    \AtBeginDocument{\renewcommand\Exindent{2em}}

\begin{document}

\section*{Article I}
\section{Section 1 - something}

% end items with \par (= blank line) is mandatory !!!

\ex. something  

\ex. something 

\section{Section 2 - something}
% More compact syntax were you "see" the blank lines 
\ex. something \par
\ex.  something \par
\section*{Article II}
\section{Section 1 - something}

\ex. something \par \ex.  something \par  Some text not in the list 
\ex.  something \par\ex.  something \par

\end{document}

mwe2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .