8

I want to number theorems by (page number).(sequential in the page). So in page 6 I would have

Thm 6.1 AAAAAABBBVVV

Thm 6.2 BBBGGSDFASFASF

Thm 6.3 AXASDFASDF

and then in page 7 it would be

Thm 7.1 AAAAAABBBVVV

Thm 7.2 BBBGGSDFASFASF

Thm 7.3 AXASDFASDF

I tried using \newtheorem{thm}{Thm}[page]. However, if Thm 7.1 is at the top of page 7, sometimes it would get numbered as Thm 6.4. I assume that this happens because \thepage is called before the actual new page was set. Is there an easy fix for this?

  • 1
    Theorem numbers are used for reference, maybe in other documents; using this approach would invalidate all references in case a new edition of your document is printed where added or removed text changes the placement of theorems. – egreg Oct 10 '13 at 11:47
  • Thank you for your concern. I am not writing a work for reference. Just some lecture notes in a local language. On the other hand, I find it very useful to have such numeration because it helps searching for things very easily. – someone Oct 10 '13 at 19:08
  • I think numbering theorems by page would be the best: whenever I read a book, and I see a reference to a theorem, the fastest way for me to find the theorem would be if I knew which page it is on. I don't understand the comment about different editions or outside references. When a theorem is referenced as "Theorem 123.4 in The Elements" and the appropriate edition of the Elements is cited, I can go, open that edition of the Elements, and find the theorem on page 123. – Máté Wierdl Nov 3 '16 at 17:30
10

You need a \label and \pageref mechanism to fix up the page references on a later run.

enter image description here

\documentclass{article}

\setlength\textheight{4cm}

\newcounter{thminternal}
\newtheorem{thm}{Thm}
\let\zzthm\thm
\makeatletter
\def\@begintheorem#1#2{\trivlist
   \item[%
\protected@edef\zz{\pageref{thm-\thethminternal}}%
        \stepcounter{thminternal}%
\protected@edef\zzz{\pageref{thm-\thethminternal}}%
\ifx\zz\zzz\else\setcounter{thm}{0}\refstepcounter{thm}\fi
\label{thm-\thethminternal}%
        \hskip \labelsep{\bfseries #1\ \pageref{thm-\thethminternal}.#2}]\itshape}



\begin{document}

\begin{thm}aaaa\end{thm} zzz

\begin{thm}bbb\end{thm} \begin{thm}ccc\end{thm}

zzz

\begin{thm}aaaa\end{thm} zzz

\begin{thm}bbb\end{thm} \begin{thm}ccc\end{thm}
\begin{thm}bbb\end{thm} \begin{thm}ccc\end{thm}

zzz
\begin{thm}bbb\end{thm} \begin{thm}ccc\end{thm}
\begin{thm}bbb\end{thm} \begin{thm}ccc\end{thm}

zzz


\end{document}
  • Thanks! This nearly does it. The \ifx starts having problems when the pages get double digits, but that should be easily fixable. – someone Oct 13 '13 at 19:24
  • @someone hmm double digits should work, if it doesn't work for you you could put an example and ping me here – David Carlisle Oct 13 '13 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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