# Using Cleveref with LIPICs documentclass fails for theorem environments sharing the same counter

I want theorems and lemmas to be referred to in the text as "Theorem 1" and "Corollary 2", sharing the same counter. This works fine when I'm using the normal article documentclass, but fails when I've to use the custom lipics format a conference requires me to use. (One needs to download and unzip the .tgz file in the same folder as the MWE).

Here's a MWE:

\documentclass[a4paper,UKenglish]{lipics}

\usepackage{amsthm, cleveref}
\crefname{theorem}{theorem}{theorems}
\crefname{corollary}{corollary}{corollaries}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}

\begin{document}
\section{Section title}

\begin{theorem}\label{thm:test}
Here is the theorem.
\end{theorem}

\begin{corollary}\label{cor:test}
Here is the corollary.
\end{corollary}

The theorem reference is given by \cref{thm:test} and the corollary reference is given by \cref{cor:test}.

\end{document}


I've read here that one needs to declare the newtheorem commands after loading cleveref, but the problem as I've discovered is that lipics.cls declares them in the class file at the very outset. So, is there any way for me to redeclare the newtheorem commands after loading cleveref?

Here's the output I currently get:

How do I correct it so that the corollary reference is correct?

• honestly you could redefine stuff so it works but it's bad form to redefine conference styles, the whole point is that it makes it easier for the conference organisers to merge articles to make the proceedings if everyone is using the same macros. even if normally you use cleverref can't you use a standard \ref here? – David Carlisle Nov 24 '14 at 21:45
• Is there any way to load cleveref along with documentclass lipics, so that it can pick up the newtheorem defns from lipics? – TCSGrad Nov 24 '14 at 21:50
• I haven't looked but the answer is always yes, latex is a macro expansion language and you can redefine anything, but if you put definitions before \documentclass and redefine the conference proceedings macros then you are making life for the conference organisers difficult, and if it was my proceedings I'd return the document and tell you to use the mandated style. – David Carlisle Nov 24 '14 at 21:52

Found a rather crude but effective solution: I defined lemma, theorem after loading cleveref in my document, but using different keywords (lemma becomes lem, theorem is thm and so on). I've ensured that the new environments are consistent with the default ones defined in lipics.cls, so the pdf file would look exactly the same, with the benefit that I dont have to use \ref anymore! This seems to be the only way to resolve this issue - I'd be glad if someone found a less crude, more DRY approach!

If cleveref is loaded right after amsthm (that is, before any newtheorem) then it works.

\RequirePackage{afterpackage}
\AfterPackage{amsthm}{
\RequirePackage{hyperref,cleveref}
}

\documentclass[a4paper,english]{lipics}

\begin{document}
\begin{theorem}\label{thm:1}
\end{theorem}
\begin{lemma}\label{lem:1}
\end{lemma}

The \Cref{lem:1} and the \Cref{thm:1}.

\end{document}