Commit e8dcb9b8 authored by Niles Johnson's avatar Niles Johnson

Fix a subtle and annoying 3-way clash between cleveref, hyperref, and amsthm

The problem stems from the way environment counters are handled when multiple
environments share the same counter.

The fix requires a new hack for the amsart documentclass, and changing the
load order of the packages.
parent 55ad1d41
......@@ -5,12 +5,79 @@
%%
%% theorem and numbering declarations
%% v. 6.0 2015-06-24
%% hyperref and cleveref
%% v. 7.0 2015-08-04
%%
\usepackage{amsmath,amsthm}
%% There is a known problem with hyperref when the same counter is
%% used for multiple environments with cleveref
%%
%% The easy and good fix is to load hyperref *before* amsthm, but this
%% is not possible with documentclass amsart. Instead then, one needs
%% to reload amsthm, which is specifically prevented by amsart! So
%% the hack below makes it possible to again load amsthm with the
%% amsart documentclass.
%%
%% http://tex.stackexchange.com/questions/250904/destination-with-the-same-identifier-warning-with-shared-counters-cleveref-an
%%
%% http://tex.stackexchange.com/questions/25047/how-do-i-get-rid-of-particular-pdftex-warning-message
%%
%% make amsthm.sty loadable
\expandafter\let\csname [email protected]\endcsname\relax
%% remove the definitions that will be redone by amsthm
\let\theoremstyle\relax
\let\newtheoremstyle\relax
\let\pushQED\relax
\let\popQED\relax
\let\qedhere\relax
\let\mathqed\relax
\let\openbox\relax
\let\proof\relax\let\endproof\relax
%%
%% end of hack
%%
\usepackage{float}
%\usepackage{subfig,epsfig}
\usepackage[unicode=true, pdfusetitle,
bookmarks=true,bookmarksnumbered=false,
breaklinks=false,
backref=false,
colorlinks=true,
linkcolor=blue!70!black,
citecolor=black,
urlcolor=blue!78!red,
final
]{hyperref}
\usepackage{bookmark}
\usepackage{amsmath,amsthm}
%%
%% cross references
%%
\usepackage[capitalise]{cleveref} % load after hyperref
\newcommand{\fref}{\cref}
\newcommand{\Fref}{\Cref}
\newcommand{\prettyref}{\cref}
\newcommand{\newrefformat}[2]{}
\newcommand{\clevertheorem}[3]{%
\newtheorem{#1}[thm]{#2}
\crefname{#1}{#2}{#3}
}
%% enumeration style
\renewcommand{\theenumi}{\textit{\roman{enumi}}}
......@@ -22,26 +89,29 @@
\numberwithin{equation}{section} %% Comment out for sequentially-numbered
\numberwithin{figure}{section} %% Comment out for sequentially-numbered
\theoremstyle{plain} % bold environment name, italic text
\newtheorem{thm}{Theorem}[section]
\newtheorem*{thm*}{Theorem}
\newtheorem{prop}[thm]{Proposition}
\clevertheorem{prop}{Proposition}{Propositions}
\newtheorem*{prop*}{Proposition}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{conj}[thm]{Conjecture}
\clevertheorem{lem}{Lemma}{Lemmas}
\clevertheorem{cor}{Corollary}{Corollaries}
\clevertheorem{conj}{Conjecture}{Conjectures}
\theoremstyle{definition} % bold environment name, plain text
\newtheorem{defn}[thm]{Definition}
\newtheorem{defns}[thm]{Definitions}
\newtheorem{question}[thm]{Question}
\newtheorem{example}[thm]{Example}
\newtheorem{exercise}[thm]{Exercise}
\newtheorem{notation}[thm]{Notation}
\newtheorem{notn}[thm]{Notation}
\clevertheorem{defn}{Definition}{Definitions}
\clevertheorem{defns}{Definitions}{Definitions}
\clevertheorem{question}{Question}{Questions}
\clevertheorem{example}{Example}{Examples}
\clevertheorem{exercise}{Exercise}{Exercises}
\clevertheorem{notation}{Notation}{Notations}
\clevertheorem{notn}{Notation}{Notations}
\theoremstyle{remark} % italic environment name, plain text
\newtheorem{rmk}[thm]{Remark}
\clevertheorem{rmk}{Remark}{Remarks}
\newtheorem*{note}{Note}
......@@ -50,3 +120,17 @@
%% This makes figures follow the theorem counter
\makeatletter\let\c@figure\c@thm\makeatother
% Additional cleveref definitions
\crefname{figure}{Figure}{Figures}
\crefname{equation}{Display}{Displays} % give 'equation' a more general name
\crefname{eq}{Display}{Displays}
\crefname{eqn}{Display}{Displays}
......@@ -5,9 +5,9 @@
%%
%% page setup stuff:
%% geometry, datetime, hyperref, todonotes, cleverref
%% geometry, datetime, todonotes
%%
%% v. 5.0 2015-06-24
%% v. 6.0 2015-08-04
%%
\usepackage[T1]{fontenc}
......@@ -80,42 +80,5 @@
\PrerenderUnicode{ε}
\PrerenderUnicode{Γ}
\usepackage[unicode=true, pdfusetitle,
bookmarks=true,bookmarksnumbered=false,
breaklinks=false,
backref=false,
colorlinks=true,
linkcolor=blue!70!black,
citecolor=black,
urlcolor=blue!78!red,
final
]{hyperref}
\usepackage{bookmark}
%%
%% cross references
%%
\usepackage[capitalise]{cleveref}
\newcommand{\fref}{\cref}
\newcommand{\Fref}{\Cref}
\newcommand{\prettyref}{\cref}
\newcommand{\newrefformat}[2]{}
% Cleveref definitions
\crefname{lem}{Lemma}{Lemmas}
\crefname{thm}{Theorem}{Theorems}
\crefname{defn}{Definition}{Definitions}
\crefname{notn}{Notation}{Notations}
\crefname{construction}{Construction}{Constructions}
\crefname{prop}{Proposition}{Propositions}
\crefname{rmk}{Remark}{Remarks}
\crefname{cor}{Corollary}{Corollaries}
\crefname{figure}{Figure}{Figures}
\crefname{equation}{Display}{Displays} % give 'equation' a more general name
\crefname{eq}{Display}{Displays}
\crefname{eqn}{Display}{Displays}
No preview for this file type
......@@ -6,9 +6,9 @@
\documentclass[11pt,oneside,draft]{amsart}
\usepackage{fouriernc} % Fourier fonts instead of Computer Modern
\usepackage{Environments} % thm, prop, etc.
\usepackage{Definitions} % macros
\usepackage{PageSetup} % general setup
\usepackage{Environments} % thm, prop, etc.
%%
......@@ -178,13 +178,13 @@ This is the statement of a theorem.
And this shows that the statement is correct.
\end{proof}
\begin{thm}\label{lem:btheorem}
\begin{lem}\label{lem:btheorem}
another theorem. Try changing it to a lemma.
\end{thm}
\end{lem}
\begin{thm}\label{ctheorem}
a third theorem
\end{thm}
\begin{prop}\label{ctheorem}
a proposition
\end{prop}
Here's an equation
\begin{equation}\label{disp1}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment