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

share|improve this question
    
Make a complete example that can be used for testing. –  Ulrike Fischer Sep 13 '12 at 11:51
    
I edited the post with a MWE. –  nunolopes Sep 13 '12 at 11:55
    
I don't get warnings about duplicate labels if I add \acresetall before or after \chapter{two} –  Ulrike Fischer Sep 13 '12 at 12:00
    
Right, it seems to be some strange interaction with the cleveref package. I still found no other answer so I updated the question title and text. –  nunolopes Sep 13 '12 at 12:12

2 Answers 2

up vote 4 down vote accepted

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
}%
\makeatletter
\acrodef{ac}{Acronym}

\begin{document}
\chapter{one}

\ac{ac}

\acresetall
\chapter{two}

\ac{ac}
\end{document}
share|improve this answer

Package cleveref extends \label{<name>} to add \label{<name>@cref}. And package acronym sets a label \label{acro:ac} twice, in the first and second chapter. However it undoes the first label before setting the second, from the .aux file:

\undonewlabel{acro:ac}
\newlabel{acro:ac}{{1}{1}}

The patch below makes the same for the added label by cleveref:

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

\makeatletter
\newcommand*{\org@overidelabel}{}
\let\org@overridelabel\@verridelabel
\renewcommand*{\@verridelabel}[1]{%
  \@bsphack
  \protected@write\@auxout{}{\string\undonewlabel{#1@cref}}%
  \org@overridelabel{#1}%
  \@esphack
}
\makeatother

\acrodef{ac}{Acronym}

\begin{document}
\chapter{one}

\ac{ac} 

\acresetall
\chapter{two}

\ac{ac}
\end{document}

The .aux file:

relax 
\reset@newl@bel
\newacro{ac}[ac]{Acronym}
\@writefile{toc}{\contentsline {chapter}{\numberline {1}one}{1}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\undonewlabel{acro:ac@cref}
\undonewlabel{acro:ac}
\newlabel{acro:ac}{{1}{1}}
\newlabel{acro:ac@cref}{{[chapter][1][]1}{1}}
\acronymused{ac}
\@writefile{toc}{\contentsline {chapter}{\numberline {2}two}{2}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\undonewlabel{acro:ac@cref}
\undonewlabel{acro:ac}
\newlabel{acro:ac}{{2}{2}}
\newlabel{acro:ac@cref}{{[chapter][2][]2}{2}}
\acronymused{ac}
share|improve this answer

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.