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 would like to write something with numbered paragraphs - for those who know it the style should be the same of EGA. So instead of having something like

blah blah

Theorem 2.1

blah blah

Proof

blah blah

more content after the proof

I would like to have something like

2.1 blah blah

2.2 Theorem. blah blah

2.3 Proof. blah blah

2.4 more content after the proof

Is there a simple way to get this result?

share|improve this question
    
This appears to be a duplicate of a stackoverflow question Also, if you can google the answer, you probably should do that. –  Seamus Apr 5 '11 at 13:31
1  
Yes, I found that question, but the answers there did not seem very satisfying. –  Andrea Apr 5 '11 at 19:21
    
I think that's more to do with the fact that there are no genuinely satisfying solutions, rather than that StackOverflow is somehow deficient. (I think the lack of genuinely satsifying answers on this site too is evidence of this.) The point is, it's just a hard thing to do, given how LaTeX seems to abuse the paragraph hooks. –  Seamus Apr 6 '11 at 11:25

2 Answers 2

up vote 3 down vote accepted

You probably don't want to number all paragraphs. I would do something like this:

\documentclass[a4paper]{article}
\usepackage{amsthm}
\swapnumbers

\newtheorem{num}{\unskip}[section]
\newtheorem{thm}[num]{Theorem}
\newtheorem{demo*}[num]{Proof}
\newenvironment{demo}
  {\pushQED{\qed}\begin{demo*}}
  {\popQED\end{demo*}}

\begin{document}
\section{Start}
\begin{num}
This is a numbered paragraph.

Actually it has two paragraphs.
\end{num}

\begin{thm}
This is a theorem.
\end{thm}

\begin{demo}
This is its proof.
\end{demo}
\end{document}
share|improve this answer
    
I actually want to number every paragraph, but I will try your solution. –  Andrea Apr 5 '11 at 19:21
    
Your solutions works nicely. The only downside is that paragraphs introduced by \num have an additional dot after the number. I wonder whether that can be helped. Thank you very much. –  Andrea Apr 6 '11 at 12:05
    
Ok, I have solved even the last problem by customizing the theorem styles in amsthm and using one without the dot. :-D –  Andrea Apr 6 '11 at 12:16

You can probably use the everyhook package for this. It numbers section names due to the way they are handled, but there is probably a way around that.

\documentclass{article}
\usepackage[excludeor]{everyhook}
\usepackage{lipsum}
\newcounter{paragraphs}[section]
\begin{document}
\PushPostHook{par}{%
        \stepcounter{paragraphs}%
        \llap{\thesection.\theparagraphs\ \kern\parindent}%
}
\section{Foo}
\lipsum
\section{Bar}
\lipsum
\end{document}
share|improve this answer
    
Nice suggestion, but it creates some problems when theorem-like environments are used. Thank you anyway. :-) –  Andrea Apr 6 '11 at 12:06

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.