17

I would like to number paragraphs for a covering report I am writing. Paragraphs should increment and not reset with new sections. The text should not be bold. Here is what I have tried

\makeatletter
\renewcommand{\paragraph}{%
  \@startsection{paragraph}{4}%
  {\z@}{0.25ex \@plus 1ex \@minus .2ex}{-1em}%
  {\normalfont\normalsize\fontfamily{phv}\fontsize{10}{15}\selectfont}
  {\arabic{paragraph}}%
}
\makeatother

This has been hacked from various questions on this site.

  \paragraph{Testing 1}
  \paragraph{Testing 2}

gives me

0.0.0.1 1 Testing 1
0.0.0.2 2 Testing 2

desired format is

1 Testing 1
2 Testing 2

Where am I going wrong?

Also what is fontfamily{phv}. Is this different from my default font?

6
  • Have a look at this answer it might fit for your need. tex.stackexchange.com/a/10524/31058
    – Ludovic C.
    Commented Aug 20, 2013 at 15:00
  • @moadeep Are you looking for something like "(19)" at the beginning of a paragraph, or e.g. as a marginpar? Show us what you would like to have!
    – Keks Dose
    Commented Aug 20, 2013 at 15:05
  • @KeksDose Question edited. I would like something like "(19)" at the beginning of each paragraph. The reason being I need to cross reference paragraphs to a table in another chapter
    – moadeep
    Commented Aug 20, 2013 at 15:08
  • 1
    I guess you have a line like \setcounter{secnumdepth}{4} Commented Aug 20, 2013 at 15:15
  • @karlkoeller yes. The number is incrementing as expected. My major issue is the extra 0.0.0.num before num
    – moadeep
    Commented Aug 20, 2013 at 15:16

3 Answers 3

21

\paragraph is like \section the argument should be the title not the whole paragraph, and it should only be used after a higher level sectioning unit (\subsubsection)

Perhaps

\newcounter{para}
\newcommand\mypara{\par\refstepcounter{para}\thepara\space}

Then you can use

\mypara blah blah blah
\mypara foo bar baz
4
  • 2
    Excellent thanks. Can I make the number bold?
    – moadeep
    Commented Aug 20, 2013 at 15:30
  • 3
    @moadeep \textbf{\thepara} Commented Aug 20, 2013 at 15:52
  • Is there a way to make the paragraph title bold also?
    – flamsmark
    Commented Aug 31, 2013 at 0:03
  • 4
    @flamsmark these are untitled paragraphs, if you want titled paragraphs you need something more like \newcommand\mypara[1]{\par\refstepcounter{para}\textbf{\thepara\space#1\space}} Commented Aug 31, 2013 at 8:52
16

This is as simple as:

\renewcommand{\theparagraph}{\S\arabic{paragraph}}
\setcounter{secnumdepth}{4}

If you just wish to also have them in the table of contents:

\setcounter{tocdepth}{4}

Answered taken from How can I number paragraphs without higher level counters?

8

Using the idea from this answer:

\documentclass{book}

\usepackage{mparhack}   % get marginpars to always show up on the correct side (need to compile twice)
\usepackage{lipsum}     % for dummy text

\setlength\parindent{0cm}

\newcommand{\parnum}{(\arabic{parcount})}

\newcounter{parcount}
\newcommand\p{%
    \stepcounter{parcount}%
    \parnum \hspace{1em}%
}

\newenvironment{parnumbers}{%
   \par%
   \everypar{\noindent \stepcounter{parcount}\parnum \hspace{1em}}%
}{}

\begin{document}

\p \lipsum[1]

\begin{parnumbers}
\lipsum[2-4]

\end{parnumbers}

\end{document}

it yields

Output

6
  • 2
    If you use \refstepcounter instead of \stepcounter paragraphs can be used with \label / \ref Commented Aug 20, 2013 at 15:26
  • 1
    also, don't do anything rash, like using a list environment (itemize, enumerate, etc) -- they destroy \everypar Commented Aug 28, 2013 at 10:28
  • This is the best solution, because it does the numbering automatically within the environment. The other solution requires a command to number the paragraph. So this one is better.
    – HSchmale
    Commented Nov 3, 2015 at 20:12
  • This breaks if you interpose a \section{}.
    – g33kz0r
    Commented Sep 25, 2017 at 0:54
  • @g33kz0r out of interest why does a section break this ?
    – jk.
    Commented Nov 27, 2018 at 17:10

You must log in to answer this question.

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