5

I am using acro package and like it. However, I have the following problem.

I would like to define for example "dsDNA" using the acronym of "DNA". When I do that, everything is fine as long as I first use "DNA" in the text (section "good" in the working example). However, if I first use "dsDNA" in the text, "DNA" and "dsDNA" are separately displayed in parentheses as shown below (section "bad" in the working example).

\documentclass{scrbook}

\usepackage[single=true,macros=true,xspace=true]{acro}

\DeclareAcronym{dna}{
short = DNA ,
long = deoxyribonucleic acid
}

\DeclareAcronym{dsdna}{
short = ds\acs{dna} ,
long = double-stranded \ac*{dna}
}

\begin{document}

\section*{good}

\Ac{dna} is a very important molecule. 
The virus xyz contains \dsdna.

Apart from that, \dna exists in almost all cells of the body. In most cases it is \dsdna.

\section*{bad}
\acresetall

The virus xyz contains \dsdna.
\Ac{dna} is a very important molecule. Apart from that, \dna exists in almost all cells of the body. In most cases it is \dsdna.


\end{document}

Then it looks like this:

enter image description here

What I would like to get would be something like this:

The virus xyz contains double-stranded deoxyribonucleic acid (dsDNA).
DNA is a very important molecule. 
Apart from that, DNA exists in almost all cells of the body. In most cases it is dsDNA.

Is it possible to achieve this somehow? Using an abbreviation for "double-stranded" doesn't seem feasible to me. In this case I would probably get something like

double-stranded (ds) deoxyribonucleic acid (DNA)

which is not what I want.

8

This is exactly the kind of use case I had in mind when I decided to provide

\acifused{<id>}{<true>}{<false>}

With it you can do the following:

\DeclareAcronym{dsdna}{
  short = ds\acs*{dna} ,
  long = double-stranded \acifused{dna}{\acs*{dna}}{\acl*{dna}}
}

This means that the short form will be typeset if the acronym dna has been used before but the long form if it hasn't. You may notice that I also use the starred form \acs* in the short form of dsdna.

enter image description here

\documentclass{scrbook}

\usepackage[single=true,macros=true,xspace=true]{acro}

\DeclareAcronym{dna}{
  short = DNA ,
  long = deoxyribonucleic acid
}

\DeclareAcronym{dsdna}{
  short = ds\acs*{dna} ,
  long = double-stranded \acifused{dna}{\acs*{dna}}{\acl*{dna}}
}

\begin{document}

\section*{good}

\Ac{dna} is a very important molecule.  The virus xyz contains \dsdna.  Apart
from that, \dna exists in almost all cells of the body. In most cases it is
\dsdna.

\section*{also good}
\acresetall

The virus xyz contains \dsdna.  \Ac{dna} is a very important molecule.  Apart
from that, \dna exists in almost all cells of the body. In most cases it is
\dsdna.

\end{document}
  • Thanks for the answer, this seems like what I have been looking for. However, when trying to use \acifused the console tells me "Undefined control sequence". I am using TexLive-2013 distribution on Mac OS X 10.8.4. This should be included, right? I saw in the documentation that is a feature that was (recently?) added in v1.3 of the package. I am a latex beginner, I don't know how to check if packages are up to date. – MarlinaH Oct 1 '13 at 19:34
  • 1
    @MarlinaH \acifused has been introduced in v1.3e, the current version on CTAN is 1.4b. I guess you're using MacTeX? it should include the tlmgr for updating the TeX distribution. You should be able to find some posts regarding updates on this site... – clemens Oct 1 '13 at 20:00
  • That was it, it works now. – MarlinaH Oct 2 '13 at 5:55

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.