# Using page counter in \newtheorem

I would like to use the page counter as a the first part of the label for definitions. I tried

\newtheorem{definition}{Definition}[page]


but that wouldn't work if the definition is at the top of a new page, presumably because of this. Is there any way around it?

-

You can use the perpage package:

\documentclass{article}
\usepackage{amsthm,perpage,etoolbox}

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\MakePerPage{definition}
\renewcommand{\thedefinition}{\theperpage.\arabic{definition}}
% We encourage TeX to break before a definition so the numbering will be correct
\BeforeBeginEnvironment{definition}{\goodbreak}

\usepackage[paperheight=60pt]{geometry} % just for the example

\begin{document}
\begin{definition}
First on first page
\end{definition}

\begin{definition}
Second on first page
\end{definition}

\newpage

\begin{definition}
First on second page
\end{definition}
\end{document}


This will assign numbers 1.1, 1.2 and 2.1

-
This doesn't work if one removes \newpage and adds (in the preamble) \textheight=50pt. – lockstep Dec 25 '12 at 23:49
@lockstep The new version should work better – egreg Dec 26 '12 at 0:05
this works perfectly, thank you so much! – vuce Dec 26 '12 at 0:07
@vuce Yet it might fail in some circumstances; keep an eye on the numbering and if you find that some definition at the top of a page doesn't get numbered correctly, issue a \pagebreak before it. Please have a look at the site FAQ, particularly with respect to what voting means. – egreg Dec 26 '12 at 0:10