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 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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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

enter image description here

share|improve this answer
    
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

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.