# Paragraph numbers at left margin

I would like to number some paragraphs of some sections inside a big document as described in https://stackoverflow.com/questions/543208/how-can-one-number-paragraphs-in-latex, see below:

\newcounter{parnum}
\newcommand{\N}{%
\noindent\refstepcounter{parnum}%
\makebox[\parindent][l]{\textbf{[\Alph{parnum}].}}}
% Use a generous paragraph indent so numbers can be fit inside the
% indentation space.
\setlength{\parindent}{2em}


This numbers the paragraphs I wanted, by putting \N before the desired paragraphs.

But I would like the paragraph numbers [A], [B], [C] to be in the left margin, while the paragraphs rest indented normally.

Do you have any suggestions?

One could use the following definition of \N to achieve what you want:

\documentclass{article}

\usepackage[nopar]{lipsum}% Just for this example

\newcounter{parnum}
\newlength{\parnumwidth}
\setlength{\parnumwidth}{3em}
\newcommand{\N}{%
\noindent\refstepcounter{parnum}%
\makebox[0pt][r]{\makebox[\parnumwidth][l]{\textbf{[\Alph{parnum}].}}}%
\hspace*{\parindent}\ignorespaces}
\setlength{\parindent}{2em}

\begin{document}

\lipsum[1]

\N\lipsum[2]

\lipsum[3]

\end{document}


The paragraph number is placed in the margin using a "\llap" which is placed inside a box of width \parnumwidth (set to 3em).

You could also consider using a \marginpar, which allows you to place content in the margin in a more flexible way:

\documentclass{article}

\reversemarginpar% Keep \marginpar in left margin
\newcounter{parnum}
\newcommand{\N}{%
\leavevmode\refstepcounter{parnum}%
\marginpar{\textbf{[\Alph{parnum}].}}}%
\setlength{\parindent}{2em}

\begin{document}

\N Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus maximus tortor id suscipit sodales.
Aenean dui orci, congue in quam id, venenatis dignissim felis. Proin leo massa, convallis eu purus ut,
bibendum iaculis odio. Sed et lacinia nibh. Duis rhoncus rhoncus lorem, vel sodales est feugiat id.
Maecenas consectetur dolor vitae sem elementum tincidunt. Nunc in posuere purus. Sed congue ullamcorper
felis, eget efficitur eros maximus in. Nam placerat justo risus, mollis fermentum velit tempus vestibulum.
Vivamus placerat neque eu dolor rhoncus blandit. Ut aliquet enim eget nisl luctus euismod. Vivamus
laoreet, elit eu aliquet bibendum, \N magna lorem efficitur turpis, ac cursus tellus tellus non magna.
Nullam justo erat, imperdiet vel diam eu, auctor luctus dui. Fusce eleifend sem a pulvinar suscipit.
Praesent facilisis, velit eget placerat mollis, magna magna venenatis est, at fringilla nulla purus sed dolor.

\end{document}


You may adjust the placement, if needed.

• Now I am becoming more demanding :-). If I want the number to float somewhere in the margin, say the left of the starting paragraph. That is, near vitae ornare in the above example that you have provided. Is there a simple solution by modifying the above code? – usr203050 Jun 16 '15 at 18:57
• @PatWern: See the updated answer using \marginpar. It seems to be what you're after rather than a "hard-coded" placement, which is easier to do at the start of the paragraph (not in the middle). – Werner Jun 16 '15 at 19:11
• Yes, that is exactly what I want. I then put \N somewhere inside the paragraph and voilà! Thank you very much. – usr203050 Jun 16 '15 at 19:14
• I have one more question. How do I control the distance of the numbers [A], [B], [C],... from the text without affecting the flow of the margin width chosen for the whole document? – usr203050 Jun 17 '15 at 12:59
• @PatWern: You should again place the content in a box using some form of overlapping. Try the following: \newcommand{\N}{% \leavevmode\refstepcounter{parnum}% \marginpar{\makebox[0pt][l]{\makebox[6em][r]{\textbf{[\Alph{parnum}].}}}}} This sets the number in a box of width 6em (pushing is closer to the text block), flush right (or "ragged left"). Adjust 6em to suit your needs. – Werner Jun 17 '15 at 14:54