6

I am trying to format my acronyms and want to use \acfi instead of \ac (which makes the word italic).

The problem is, withpage seems to work only for the \ac command, so the page information for acronyms introduced with \acfi.

Is there a way to add the acfi command to the withpage option? Or is there an easier solution for this? I've found this Post, but it does not solve my issue: acro package: Italicize first occurrence of term

\documentclass{article}  
\usepackage[printonlyused, withpage]{acronym}

\begin{document} 

\section{Acronyms}
\begin{acronym}[Bash]
 \acro{A}{Apple}
 \acro{B}{Ball}
 \acro{C}{Cat}
\end{acronym}

This an \ac{A}, this is a \acfi{B}, but I can't think of a word with C.

This is the \acs{A}\acs{B}\acs{C}

\end{document}

This is the result:

Result

As this is my first Tex question, I wonder if there is a way to add a running example + output directly?

  • 1
    I would recommend considering switching to the acro package and using the answer you link to - I find acro much more powerful while being very similar to acronym at the more basic levels. – Dai Bowen Feb 27 '17 at 16:44
  • @DaiBowen thanks for the hint, I will have a look at it. What may be the major improvements i your eyes? – ppasler Feb 27 '17 at 16:45
  • 1
    The main thing which got me was the \Ac variants which printed a capitalised version (i.e. so you could use \Ac{foo} when starting a new sentence). More generally it has more user access to do things like \acreset{foo} which resets foo as being unused (e.g. if you want all acronyms to be defined in each chapter) there's no equivalent user interface for doing that with acroynm. Probably the most impressive thing is the flexibility you have in printing the list of acronyms which is so much greater. All the while, the \ac and friends are defined and work in acro as in acronym. – Dai Bowen Feb 27 '17 at 18:12
  • So I will definitely have a look at it, thanks again :) – ppasler Feb 27 '17 at 18:17
2

The \acfi macro calls \acfi which is defined as

\newcommand{\acfia}[1]{%
  {\itshape \AC@acl{#1} \nolinebreak[3]} (\ifAC@starred\acs*{#1}\else\acs{#1}\fi)}

Comparing this with the internal definition for \acf

\newcommand*{\@acf}[1]{%
    \ifAC@footnote
       \acsfont{\AC@acs{#1}}%
       \footnote{\AC@placelabel{#1}\AC@acl{#1}{}}%
    \else
       \acffont{%
          \AC@placelabel{#1}\AC@acl{#1}%
          \nolinebreak[3] %
          \acfsfont{(\acsfont{\AC@acs{#1}})}%
        }%
     \fi
     \ifAC@starred\else\AC@logged{#1}\fi}

We see that \acfia seems to be lacking the \AC@placelabel{#1} which appears to be responsible for producing the label.

Adding this in to the definition as (I've also played with the spacing as I think there above definition has two spaces between the long and short versions)

\renewcommand{\acfia}[1]{%
    {\itshape\AC@placelabel{#1}\AC@acl{#1}\nolinebreak[3] }(\ifAC@starred\acs*{#1}\else\acs{#1}\fi)%
}

Running this then creates the label, it also causes the acronym to be marked as used (with the initial definition of \acfia, \acfi{B} \ac{B} becomes "Ball (B) Ball (B)" whereas using the redefinition above the same yields "Ball (B) B".

In a full document

\documentclass{article}  
\usepackage[printonlyused, withpage]{acronym}

\makeatletter
\renewcommand{\acfia}[1]{%
    {\itshape\AC@placelabel{#1}\AC@acl{#1}\nolinebreak[3] }(\ifAC@starred\acs*{#1}\else\acs{#1}\fi)%
}
\makeatother

\begin{document} 

\section{Acronyms}
\begin{acronym}[Bash]
 \acro{A}{Apple}
 \acro{B}{Ball}
 \acro{C}{Cat}
\end{acronym}

This an \ac{A}, this is a \acfi{B}, but I can't think of a word with C.

This is the \acs{A}\acs{B}\acs{C}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.