[Tex/LaTex] acronym \acresetall & cleveref: multiply defined labels

acronymscleveref

I'm using the acronym package to expand acronyms and I'm also using the cleveref package. I would like to have acronyms expanded once per chapter. For instance in the following code, both acronyms should produce the expansion:

\documentclass{report}
\usepackage{acronym}
\usepackage{cleveref}

\acrodef{ac}{Acronym}

\begin{document}
\chapter{one}

\ac{ac} 

\acresetall
\chapter{two}

\ac{ac}
\end{document}

According to the acronym manual I found that calling \acresetall before each chapter produces the desired result but I get warning about duplicate labels (somehow a conflict with cleveref). Is there another way to get the desired result or avoid the warning?

Best Answer

You can try this:

\documentclass{report}
\usepackage{acronym}
\usepackage{cleveref}
\makeatletter
\renewcommand*\@verridelabel[1]{%
  \@bsphack
  \protected@write\@auxout{}{\string\undonewlabel{#1}}%
  \protected@write\@auxout{}{\string\undonewlabel{#1@cref}}%Added for cleverref
  \label{#1}%
  \@overriddenmessage rs{#1}%
  \@esphack
}%
\makeatother
\acrodef{ac}{Acronym}

\begin{document}
\chapter{one}

\ac{ac}

\acresetall
\chapter{two}

\ac{ac}
\end{document}