4

I'm trying to format my text according to the following rules:

  1. From the second paragraph on, paragraphs should be numbered.
  2. Paragraph numbers should be inside text area, aligned to left margin.
  3. First line of paragraph text should be indented by 2.5cm (starting from margin, not from number)

So far I have achieved the following.

\documentclass[12pt,a4paper]{article}
\usepackage{indentfirst} %indent first paragraph
\usepackage{lipsum}

\setlength{\parindent}{2.5cm} %paragraphs should be indented by 2.5 cm from margin

\newcommand{\parnum}{\arabic{parcount}.}
\newcounter{parcount}
\newcommand\p{%
    \stepcounter{parcount}%
    \parnum \hspace{1em}%
}
\stepcounter{parcount} % start at number 2
\newenvironment{parnumbers}{%
   \setlength{\parindent}{0cm}
   \par%
   \everypar{\noindent \stepcounter{parcount}\parnum \hspace{2.3cm}}% NEED TO ADJUST. Paragraph text (not numbers) should be indented by 2.5cm from margin.
}{}

\begin{document}
\lipsum[1]
\begin{parnumbers}
\lipsum[2-15]
\end{parnumbers}
\end{document}

enter image description here

Instead of having a fixed \hspace after the paragraph counter, how do I insert 2.5cm minus the length of the paragraph number and the dot? For example, when I have double digits paragraph numbers, the fixed \hspace makes the text slightly more indented then it should be.

enter image description here

Any thoughts?
Thank you in advance.
Rossi

  • Welcome to TeX.SE. What is the point of numbering the paragraphs and omitting the 1st one? – user31729 Jan 25 '17 at 14:52
  • Thanks! I have no idea. It's a standard I have to follow at work for a few types of official documents. – Rossi Jan 25 '17 at 17:27
3

The numbox can be set into some \hbox of specified with.

\hbox to \boxindent {content\hfill} will fill the box and place a box of the relevant width into the beginning of the paragraph.

\documentclass[12pt,a4paper]{article}
\usepackage{indentfirst} %indent first paragraph
\usepackage{lipsum}

\newlength{\boxindent}
\setlength{\boxindent}{2.5cm}
\setlength{\parindent}{\boxindent} %paragraphs should be indented by 2.5 cm from margin

%\newcommand{\parnum}{\arabic{parcount}.}
\newcounter{parcount}
%\newcommand\p{%
%    \stepcounter{parcount}%
%    \parnum \hspace{1em}%
%}
\renewcommand{\theparcount}{\arabic{parcount}.}
\setcounter{parcount}{1}
\newenvironment{parnumbers}{%
   \setlength{\parindent}{0em}
   \par%
   \everypar{\hbox to \boxindent{\raggedright\stepcounter{parcount}\theparcount\hspace{1em}%
       \hfill}}
}{}

\begin{document}
\lipsum[1]
\begin{parnumbers}
\lipsum[2-20]
\end{parnumbers}
\end{document}

enter image description here

2

A referenceable variant, with a simple \makebox[2.5cm], and \hangindent\hangafter in case you want the left margin of the paragraphs to be 2.5cm right of the document left margin:

\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} %\usepackage{indentfirst} %indent first paragraph
\usepackage{lipsum}

\setlength{\parindent}{2.5cm} %paragraphs should be indented by 2.5 cm from margin

\newcommand{\parnum}{\arabic{parcount}.}
\newcounter{parcount}
\stepcounter{parcount} % start at number 2
\newenvironment{parnumbers}{%
   \setlength{\parindent}{0cm}
   \par%
   \everypar{\noindent\hangindent=2.5cm\hangafter=1 \refstepcounter{parcount}\label{par-\arabic{parcount}}\makebox[2.5cm][l]{\arabic{parcount}.}}%
}{}

\usepackage[colorlinks]{hyperref} %

\begin{document}
\lipsum[1]

{\begin{parnumbers}
\lipsum[2-15]
\end{parnumbers}}

We see in §\,\ref{par-10}…

\end{document} 

enter image description here

  • Thank you for the answer, I'll keep it for future reference. In this case only the first line of the paragraph should be indented, though. – Rossi Jan 25 '17 at 18:40
  • If that is the case (your formulation was ambiguous), you just have to remove \hangindent=2.5cm\hangafter=1. You still have the cross-references. – Bernard Jan 25 '17 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.