TransWikia.com

Issue with acro and fancyhdr package in xelatex - Using acronyms in section titles

TeX - LaTeX Asked by Claymore on July 26, 2021

Intro

Recently, I was plagued by an issue with the acro package, while writing my thesis with xelatex.

My document uses the fancyhdr package, where I set the section title to appear at footer. The section title letters appear in upper case.

The issue

I like to use acronyms when I can. So, I decided to use an acronym request in a section title, such as this:

section{Moving Forward to Distributed ac{sdn} Management}

But for some reason, the engine thought it was funny to forcelly upper case all the text in the section title, transforming an ac{sdn} into an ac{SDN}.

Then, this happened at the footer of the document:
weird footer

Because of this, I was plagued with a phantom acronym appearing two times at the auxiliary file:

acro@used@once {SDN}{78}{78}{89}
acro@used@twice {SDN}{79}{79}{90}

while these phantom acronym requests appeared at the document building log.
No acronym requests existed at the specified lines:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! acro error: "undefined"
! 
! You've requested acronym `SDN' on line 499 but you apparently haven't
! defined it, yet!
! Maybe you've misspelled `SDN'?
! 
! See the acro documentation for further information.
! 
! Type <return> to continue.
!...............................................  

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! acro error: "undefined"
! 
! You've requested acronym `SDN' on line 514 but you apparently haven't
! defined it, yet!
! Maybe you've misspelled `SDN'?
! 
! See the acro documentation for further information.
! 
! Type <return> to continue.
!...............................................  

2 Answers

The solution

It seems that the combination of using the acro package with the fancyhdr package while putting the section title at the footer, has proven to be buggy. Because of this, I removed the ac{sdn} request from the title, which solved the issue of the phantom ac{SDN} request.

Now, the footer of the document is correct and the phantom acronym requests have disapeared. enter image description here

Correct answer by Claymore on July 26, 2021

This is not necessarily bound to fancyhdr. The same happens with a simple pagestyle{headings} in the article class.

The problem is that sectionmark does MakeUppercase on the heading and – since ac and friends are protected commands – changes ac{sdn} into ac{SDN} which then leads to the error message.

  • One obvious “solution” is to define the acronym with an uppercase ID instead:

     DeclareAcronym{SDN}{...}
    

However, this might be a tedious work to change, depending on the number of acronyms and acronym calls in your document. (Although a search&replace might actually be quite easy...)

  • Another possibility might be to use the textcase package which redefines MakeUppercase so that we can tell LaTeX not to uppercase certain parts:

     documentclass{article}
     usepackage{acro}
     usepackage[overload]{textcase}
    
     DeclareAcronym{sdn}{
       short = SDN ,
       long  = some dummy nonsense
     }
    
     pagestyle{headings}
    
     begin{document}
    
     section{Moving Forward to Distributed protectNoCaseChange{acs*{sdn}} Management}
    
     end{document}
    
  • As a third option which does not depend on the way the heading style is defined acro introduced the option case-sensitive earlier this year (with the release of v2.11 2020/01/11) in order to deal with this kind of problems. Assuming you don't have two different acronyms, one using sdn as ID and the other using SDN you can tell acro to treat both as the same:

     documentclass{article}
     usepackage{acro}
    
     acsetup{case-sensitive=false}
    
     DeclareAcronym{sdn}{
       short = SDN ,
       long  = some dummy nonsense
     }
    
     pagestyle{headings}
    
     begin{document}
    
     section{Moving Forward to Distributed acs*{sdn} Management}
    
     end{document}
    

The last two examples both give

enter image description here

Answered by cgnieder on July 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP