3

I am using standard astrophysical acronyms that include other acronyms, e.g. Coronal Mass Ejection (CME) Interplanetary Coronal Mass Ejection (ICME) and I would like them to work together, that is if I have already used \ac{CME} and the full version of CME has been printed I would like \ac{ICME} to result in Interplanetary CME (ICME), and if not it should give the full version.

In other words, I would like something like this

\documentclass[paper=a4, fontsize=12pt]{article}
\usepackage[utf8]{inputenc} 
\usepackage[english]{babel} % English language/hyphenation
\usepackage[pdftex]{graphicx}% Enable pdflatex
\usepackage[printonlyused]{acronym}

\begin{document}
\begin{acronym}
\acro{CME}{Coronal Mass Ejection}
\acro{ICME}{Interplanetary \ac{CME}}
\end{acronym}

\section{Text}
\acresetall

The \ac{ICME} is a version of \ac{CME}.

\acresetall

A version of \ac{CME} is called \ac{ICME}.

\end{document}

to result in this What I want it to look like

instead of this, which it does now What it actually looks like

  • I used acronym for my thesis but in the final version (which is the only one I have here) got rid of most of my acronyms at the request of my internal examiner. I'll have a look tonight because I'm sure I had some nested acronym and I'd have hated the "(CME) (ICME)" type of output you have here. I know it's written for acro but this question might help in conjunction with the acronym manual. – Chris H May 29 '15 at 14:49
2

Here is a solution for your problem. I added the macro acx which prints the long or the short version of the acronym and doesn't mark it as used.

EDIT: I changed my previous answer, because it was too complicated on second thought.

enter image description here

\documentclass[paper=a4, fontsize=12pt]{article}
\usepackage[utf8]{inputenc} 
\usepackage[english]{babel} % English language/hyphenation
\usepackage[pdftex]{graphicx}% Enable pdflatex
\usepackage[printonlyused]{acronym}

\makeatletter
\newcommand{\acx}{\protect\@acx}%
\newcommand{\@acx}[1]{%
  \ifAC@dua
   \acl{#1}%
  \else
   \expandafter\ifx\csname ac@#1\endcsname\AC@used
      \acs{#1}%
   \else
      \acl{#1}%
   \fi
  \fi
}
\makeatother

\begin{document}
\begin{acronym}
\acro{CME}{Coronal Mass Ejection}
\acro{ICME}{Interplanetary \acx{CME}}
\end{acronym}

\section{Text}
\acresetall

The \ac{ICME} is a version of \ac{CME}.

\acresetall

A version of \ac{CME} is called \ac{ICME}.

\end{document}
2

My comment almost pointed in the right direction:

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

\begin{document}

\begin{acronym}
    \acro{CME}{Coronal Mass Ejection}
    \acro{ICME}{Interplanetary \acl{CME}}
\end{acronym}

\section{Text}
\acresetall

The \ac{ICME} is a version of \ac{CME}.

\acresetall

A version of \ac{CME} is called \ac{ICME}.

\end{document}

(note the use of \acl{CME} instead of \ac{CME} in the definition of \acro{ICME}) gives:

Output of above code

I thought you might have to play with whether or not acronyms are marked as used but apparently not in this case (\aclu etc.). Do check that the first expansion actually happens though, and/or do \acresetall at the start of the body (and of the abstract if you use them there).

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.