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 drawing up a document that has numbered paragraphs. 1-36 are numbered normally and I have no problems. However, on paragraph 37, I need something like:

35 Normal paragraph.

36 Normal paragraph.

37-46 The following paragraphs correspond to text text text text, text text.

47 Normal paragraph.

I'm numbering my paragraphs using:

\newcounter{xpar}
\setcounter{xpar}{1}
\newcommand{\xp}{\arabic{xpar}\stepcounter{xpar}.\hspace{.5in}}

Can anyone help me figure out how to number the paragraph with a 37-46, and then continue on with 47?

share|improve this question
3  
Your code contains some errors: instead of \setcounter{xpar}, you should use \setcounter{xpar}{1} (or another value) or \stepcounter{xpar}, and instead of \newcommand{xp}{...} you should use \newcommand{\xp}{...}. –  Gonzalo Medina Aug 4 '11 at 21:44
    
Good catch; I already had those corrections...just typed this in here too quickly. Bad form on my part. Thanks, though. –  Robert Ray Aug 4 '11 at 21:47
add comment

1 Answer

Add an optional argument for the "number of additional paragraphs" to the definition of your \xp macro. If the optional argument is empty, typeset the paragraph label as usual. If not, increase your custom counter as appropriate and also typeset the (new) label.

\documentclass{article}

\newcounter{xpar}
\newcommand{\xp}[1][]{%
  \stepcounter{xpar}%
  \arabic{xpar}%
  \ifx #1\empty
  \else
    \addtocounter{xpar}{#1}%
    --\arabic{xpar}%
  \fi
  .\hspace{.5in}\ignorespaces
}

\begin{document}

\xp Some text.

\xp[3] Some text.

\xp Some text.

\end{document} 
share|improve this answer
    
I think adding #1-1 is a bit more intuitive. –  Caramdir Aug 4 '11 at 21:47
1  
I like this solution better, so I will delete mine. –  Gonzalo Medina Aug 4 '11 at 21:49
2  
Just a suggestion: you could add something like \newlength\mylen before the definition of \xp, and change the \else part to \else \addtocounter{xpar}{#1}\settowidth\mylen{--\arabic{xpar}}% --\arabic{xpar}\hspace{-\mylen}% so that all the paragraphs would have the same indentation. –  Gonzalo Medina Aug 4 '11 at 22:01
    
This solution worked perfectly. –  Robert Ray Aug 4 '11 at 22:03
    
@Robert: Thanks! Don't forget to accept my answer after some time if no better one comes along. :-) –  lockstep Aug 4 '11 at 22:10
add comment

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.