4

I am using the acronym package. It happens often in my texts that I have something like:

1. We first use a \ac{NA} \citep{exocom2019} and then the text continues.
  1. We learn a \ac{VL} (i.e., something we did not know before).

What will look like the following in a text.

  1. We first use a New Acronym (NA) (Exocom, 2019) and then the text continues.

  2. We learn a Valuable Lesson (VL) (i.e., something we did not know before).

Is there a way in the acronym package to do this so that I can merge the parentheses? In a way the output becomes something like:

  1. We first use a New Acronym (NA; Exocom, 2019) and then the text continues.

  2. We learn a Valuable Lesson (VL; i.e., something we did not know before).

In case somebody has another good solution or workaround to the problem, please let me know.

PS: I tried to update the examples and add code as asked. I hope that helps.

PPS: An MWE

--- mwe.tex ---

\documentclass[12pt]{book}

\usepackage[printonlyused]{acronym} % used for the nice acronyms \usepackage[style=authoryear-comp,citestyle=authoryear,natbib=true,backend=bibtex,maxbibnames=99,maxcitenames=1]{biblatex} %NEW BIB: needed so that bibentry works

\bibliography{mweBib}

\begin{document}

\begin{acronym} \acro{NA}{New Acronym} \acro{VL}{Valuable Lesson} \end{acronym}

  1. We first use a \ac{NA} \citep{exocom2019} and then the text continues.

  2. We learn a \ac{VL} (i.e., something we did not know before).

\end{document}

--- mweBib.bib ---

@inproceedings{exocom2019,
  title={My title},
  author={Exocom},
  year={2019},
  booktitle = {Proc. Stackexchange}
}

--- command ---

latexmk -pvc mwe.tex
JamesT
  • 3,169
Exocom
  • 576
  • 1
    It is quite hard to follow what you are asking. To be able to reproduce the issue, please post a compilable code sample. – Alex Povel Aug 14 '19 at 07:44
  • 1
    I don't know how to do it with citations, but with normal parenthesis you could solve the problem by hand with explicit commands: \acl{NA} (\acs{NA}; ....) – Ignasi Aug 14 '19 at 08:40
  • I can imho not use the \acl{} and \acs combination, as this leads to the acronym being written out fully twice. Once where I do it by hand and once by the package that thinks the next time it encounters an \ac{} it has not been introduced yet. – Exocom Aug 14 '19 at 09:29
  • 2
    I believe this is something acro supports with the cite key/group-citation package option, though I've never used it. See this question/answer for an example. – Dai Bowen Aug 14 '19 at 09:41
  • 1
    @Exocom You could include an \acused command to prevent the acronym being fully printed twice. – Ignasi Aug 14 '19 at 09:46
  • @DaiBowen: Yes, thanks, that is true. For a few cases, this works. – Exocom Aug 14 '19 at 09:47
  • @Ignasi: Thanks, this does work. Not a very elegant solution, but I did not ask for that ;-). – Exocom Aug 14 '19 at 09:48

1 Answers1

1

This is doable with the acro package:

  • The citation is already built in by setting the option cite/group = true and adding the citation to the definition of the acronym.

  • A one-time addition is possible by redefining the default template…

      \RenewAcroTemplate{long-short}{%
        \acroiffirstTF{%
          \acrowrite{long}%
          \acspace(%
            \acroifT{foreign}{\acrowrite{foreign}, }%
            \acrowrite{short}%
            \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}%
            \acaddition % <<< new
            \acrogroupcite
          )%
        }{%
          \acrowrite{short}%
          \acaddition % <<< new
        }%
      }
    

    …and the command \ac:

      \providecommand\acaddition{}
      \RenewAcroCommand\ac{mo}{%
        \IfNoValueF{#2}{\def\acaddition{, #2}}%
        \UseAcroTemplate{first}{#1}%
      }
    

    Commands defined by \NewAcroCommand and friends are local to a group so we don't need to worry about the definition of \acaddition afterwards.

A complete example:

enter image description here

\documentclass{article}

\usepackage[style=authoryear-comp,citestyle=authoryear]{biblatex} \addbibresource{\jobname.bib}

\begin{filecontents}{\jobname.bib} @inproceedings{exocom2019, title={My title}, author={Exocom}, year={2019}, booktitle = {Proc. Stackexchange} } \end{filecontents}

\usepackage{acro}

\RenewAcroTemplate{long-short}{% \acroiffirstTF{% \acrowrite{long}% \acspace(% \acroifT{foreign}{\acrowrite{foreign}, }% \acrowrite{short}% \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}% \acaddition % <<< new \acrogroupcite )% }{% \acrowrite{short}% \acaddition % <<< new }% }

\providecommand\acaddition{} \RenewAcroCommand\ac{mo}{% \IfNoValueF{#2}{\def\acaddition{, #2}}% \UseAcroTemplate{first}{#1}% }

\acsetup{ cite/group = true }

\DeclareAcronym{NA}{ short = NA , long = New Acronym , cite = exocom2019 } \DeclareAcronym{VL}{ short = VL , long = Valuable Lesson }

\begin{document}

\begin{enumerate} \item We first use a \ac{NA} and then the text continues. \item We learn a \ac{VL}[i.e., something we did not know before]. \end{enumerate}

\end{document}

cgnieder
  • 66,645