Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
Is there any reason not to use an enumerate list? As far as I understand this would give you the second layout. And then it would be a matter of changing some list parameters (which I'd have to look up, but I'm sure someone here knows) to get the first one. –  Caramdir Jan 7 '11 at 21:30
    
I honestly don't know enough about the flexibility of the enumerate command (or enumitem package) to be sure. Both the problem statements and solutions can be multi-paragraph, multi-display affairs, and I thought \item got ticked off when you tried to include multiple paragraphs in an item. –  jdc Jan 7 '11 at 22:18
1  
Lists are robust enough that you can't break them that way. –  Caramdir Jan 7 '11 at 22:20
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
Thanks. So by fiddling with the \titleformat I could make it, say, the same size as the rest of the type, but slanted? What if I wanted the problem numbers bold, with following periods? Since the problem statements now seem to be sections, can the \section environment, with this package, accommodate multi-paragraph contents, with displays embedded, etc. I would then only want the first line of the problem/section unindented. Occasionally the problems are more expository than anything and go on for half a page. –  jdc Jan 7 '11 at 22:05
    
@jdc: No problem, I will edit my example accordingly. –  Stefan Kottwitz Jan 7 '11 at 22:12
    
Thank you so much! –  jdc Jan 7 '11 at 22:19
    
It isn't seeming to like multi-paragraph sections. The line break throws it off. Also, is there a way to specify a weird section number like 23.5? –  jdc Jan 7 '11 at 22:48
1  
@jdc: The site bases on questions and develops a knowdledge base building on questions. Any good formulated meaningful question is a good contribution to the site. So feel free to post questions. –  Stefan Kottwitz Jan 7 '11 at 23:05
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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