2

Edit: If yo [sic!] do not want any command starting the paragraphs, use \everypar at your own risk ... you are warned in the comments.

  • The same is true for user @egreg:

There are too many places where \par is used and a number should not appear: not only section titles, but also items in lists (including a single paragraph center environment). One could think to “conditional numbering”, disabling it in the special places. Not a task I'd undertake.

enter image description here

The hook management introduced in 2020 is largely intended for package developers. However, most of the available hooks can also be useful for document authors.

  • Question: Does the new hook management offer an easier way to number each text paragraph without having the risks/issues that were raised in 2015 by egreg and Fran?
  • Remark: If yes, a separate follow-up question would be how to access the numbers: Referencing them in a \label{} and \ref{} pattern.

The MWE shows a not working version that shows the problems (numbers in unwanted places like questions, figures, headings, ...). The MWE is just a modified copy of my MWE from 2015 - please do not consider the code and used packages too much.

\documentclass{article}
\usepackage[excludeor]{everyhook}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{parskip}
\newcounter{paragraphs}[section]

\newcommand{\myFillerAux}{ Test dummy text that has no meaning. } \newcommand{\myFiller}{\myFillerAux\myFillerAux\myFillerAux\myFillerAux\myFillerAux\myFillerAux}

\begin{document} \PushPostHook{par}{% \stepcounter{paragraphs}% \llap{\thesection.\theparagraphs\ \kern\parindent}% }

\tableofcontents

\section{Test 1} \myFiller

\begin{figure} \centering \includegraphics{example-image} \caption{Caption} \label{fig:my_label} \end{figure}

\begin{equation} a^2 + b^2 = c^2 \end{equation}

\section{Test 2} \myFiller

\begin{figure} \centering \includegraphics{example-image} \caption{Caption} \label{fig:my_label} \end{figure}

\begin{equation} a^2 + b^2 = c^2 \end{equation}

\end{document}

enter image description here

0 Answers0