6

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?

4
  • This appears to be a duplicate of a stackoverflow question Also, if you can google the answer, you probably should do that.
    – Seamus
    Commented Apr 5, 2011 at 13:31
  • 2
    Yes, I found that question, but the answers there did not seem very satisfying.
    – Andrea
    Commented Apr 5, 2011 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
    Commented Apr 6, 2011 at 11:25
  • What if I want the numbering of paragraphs in brackets too? Commented Mar 19, 2015 at 21:06

2 Answers 2

5

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}
4
  • I actually want to number every paragraph, but I will try your solution.
    – Andrea
    Commented Apr 5, 2011 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
    Commented Apr 6, 2011 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
    Commented Apr 6, 2011 at 12:16
  • Many thanks for being here to give us hands! I shared this post.
    – Mikasa
    Commented Jan 14 at 7:15
3

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}
1
  • Nice suggestion, but it creates some problems when theorem-like environments are used. Thank you anyway. :-)
    – Andrea
    Commented Apr 6, 2011 at 12:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .