5

I want to write a specification and each paragraph should automatically be numbered. I found something similar in a book about fitness training:

enter image description here

I prepared a small MWE (two-sided layout):

\documentclass{book}

\usepackage[english]{babel} \usepackage[toc]{blindtext}

\begin{document}

\Blinddocument

\end{document}

Sadly I do not have a starting point for a solution. A manual solution would be to use margin notes.

Ideally the solution does not include a command I have to write before every paragraph.

Update 1

Question/Answer Numbered paragraphs is pretty close:

\documentclass{article}
\usepackage[excludeor]{everyhook}
\usepackage{lipsum}
\usepackage{parskip} % I added this, Manuel Kuehner
\newcounter{paragraphs}[section]
\begin{document}
\PushPostHook{par}{%
        \stepcounter{paragraphs}%
        \llap{\thesection.\theparagraphs\ \kern\parindent}%
}
\section{Foo}
\lipsum
\section{Bar}
\lipsum
\end{document}

It creates an output like this:

enter image description here

So the output is not correct.

The problem is here that every section etc. also gets the additional numbering.

Update 2

Here's another close solution (in German): http://texwelt.de/wissen/fragen/5020

But there's the same problem that I need to use a command for every number.

Update 3 [2020-11-07, i. e. 5 Years later]

  • After using/trying this for about 1.5 years I stopped it.
  • In hindsight, the comments (@egreg for example) were right and it used too many unwanted side effects.
  • I am sorry that I do not have a better update.
  • I ended up using \subsubparagraph and used it for every paragraph with a different formatting compared to the rest of the headings.
  • 3
    A counter and \everypar is probably the way to go. I've written something like this ages ago - will see if I can find it. – Thruston Aug 29 '15 at 10:12
  • Just a note: In Question http://tex.stackexchange.com/questions/10513 they all say that changing \everypar it not a good idea. – Dr. Manuel Kuehner Aug 29 '15 at 10:29
  • Changing of some internals is always bad. However in your case I think it should be much easier to define a single command which puts a number at the beginning of the next paragraph. So you can avoid some complications with other packages and you are more flexibel (e.g. using a table or figure) – Marco Daniel Aug 29 '15 at 11:16
  • My answer would be similar to this one: http://tex.stackexchange.com/questions/10513/automatically-assign-a-number-to-every-paragraph?rq=1 – Marco Daniel Aug 29 '15 at 12:01
  • 1
    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. – egreg Aug 29 '15 at 15:50
  • @egreg See my update (#3) :). You were right (no surprise) :). – Dr. Manuel Kuehner Nov 07 '20 at 21:16

2 Answers2

5

One approach using the linguex package:

enter image description here

\documentclass{article}
\usepackage{lipsum} % for dummy text    
\usepackage{linguex}
% Counter format 
\renewcommand{\ExLBr}{\bfseries}
\renewcommand{\ExRBr}{}
% http://tex.stackexchange.com/a/57279/11604
% Reset \ex. at each section 
\usepackage{chngcntr}
\counterwithin{ExNo}{section}
% add section counter
\renewcommand{\Exarabic}{\thesection.\arabic} 
\begin{document}
\section{First section}
\ex. \lipsum[2]\par
\ex. \lipsum[3]\par
\section{Second section}
\ex. \lipsum[3]\par
\end{document}

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

In the next MWE, the macro \NumPar at the beginning of each section produce the same output that above. As example of the problems about using \everypar, note that a new section cancel the numeration but do not restore the default indentation of 1em, so you must restore it manually.

\documentclass{article}
\usepackage{lipsum}
\parindent1em
\begin{document}
\def\NumPar{%
\parskip0.5em%
\parindent0em%
\everypar={%
\hangindent3em%
\addtocounter{subsection}{1}%
\makebox[3em][l]{\bfseries\thesubsection}%
}}%
\section{First section}
\NumPar
\lipsum[2]\par
\lipsum[3]\par
\everypar{}
\lipsum[3]\par
\section{Second section}
\NumPar % Or \parindent1em to return to normal paragraphs
\lipsum[3]\par
\lipsum[3]\par
\end{document}
Fran
  • 80,769
1

Another solution which is non-automatic, but a handy solution is using the enumitem package. Only itemize each paragraph in the description block:

\documentclass{article}
\usepackage{lipsum} % for dummy text    
\usepackage{enumitem}
\begin{document}
\section{First section}
\begin{description}[style=unboxed,leftmargin=0.7cm]
\item[$\textbf{1.1}$]\lipsum[1]\par
\item[$\textbf{1.2}$]\lipsum[2]\par
\end{description}
\section{Second section}
\begin{description}[style=unboxed,leftmargin=0.7cm]
\item[$\textbf{2.1}$]\lipsum[3]\par
\end{description}
\end{document}
moksef
  • 115
  • 1
    As long as you're using enumitem, you might as well make it an enumerate and have the label automatically created for you. – Teepeemm Jul 19 '19 at 22:20