[Tex/LaTex] How to do numbering with a hanging indent to the left into the page margin

horizontal alignmentindentationnumberingsectioning

I am compiling some solutions to textbook exercises, and I am trying to do so in the style of the book. The way the book does it is that the body of each exercise appears unindented, left-aligned, where one would expect it to be, at the left margin, but the number for the problem is right-aligned to the left of that.

An impression of the result is this:

     This is the left margin.

  1. This is the first problem.

       This is the first paragraph of the first solution, which has a normal first-line
     indent.
       This is the second paragraph of the first solution...

       This is a new paragraph following a line break, still in the first solution.

       This is the second page of the first solution.

  2. This problem follows.
     ...
 10. This is the tenth problem.

I would be equally happy with the following:

This is the left margin.

 1. This is the first problem.

 2. This problem follows.
     ...
10. This is the tenth problem.

The numbers are in boldface and wrap around every chapter (so there are multiple 1's, 2's, etc.), and solutions are (to be) typed in between.

Best Answer

enumerate might be one solution. In that case I would use the enumitem package to customize the list according to the requirements.

For longer solutions, you could better customize the sectioning. For this, I would use titlesec. Here's a short example for such hanging headings and formatting like in your comment below:

\documentclass{book}
\usepackage{titlesec}
\titleformat{\section}{\normalfont\slshape}{\makebox[2em][r]{\textbf{\thesection.}}}{1em}{}
\titlespacing*{\section}{-3em}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}
\begin{document}
\chapter{One}
This is the left margin.
\section{This is the first problem.}
This is the solution.
\section{This problem follows.}
\addtocounter{section}{7}
\section{This is the tenth problem.}
\end{document}

alt text

Here \makebox puts the label into a box of fixed width and aligned to the right. Other values cause the overhanging into the left margin.