2

I would like to print in a defined location only the long foreign version of an acronym using acro. What I currently tried was \acf{}, but this gives me both the long translated version as well as the long original.

For clarity, if I have this:

\DeclareAcronym{ym}{ short = {YM}, long = {Ministry of the Environment}, foreign={Ympäristöministeriö / Miljöministeriet}, foreign-format = \textit, tag = org, pdfcomment = {Ministry of the Environment} } 

I would like to print in a defined location only the foreign attribute of this acronym (i.e., for this acronym "Ympäristöministeriö / Miljöministeriet").

Current MWE and output:

\documentclass[12pt]{report} % --- Essential Packages --- \usepackage[T1]{fontenc} \usepackage[british]{babel} \usepackage{xcolor} \usepackage[most]{tcolorbox} \usepackage{tabularray} \UseTblrLibrary{booktabs} \usepackage[en-GB]{datetime2} \usepackage{acro} \DeclareAcronym{ym}{ short = {YM}, long = {Ministry of the Environment}, foreign={Ympäristöministeriö / Miljöministeriet}, foreign-format = \textit, tag = org, pdfcomment = {Ministry of the Environment} } \begin{document} Print here \acf{ym}. \end{document} 

enter image description here

2
  • where does Miljöministeriet come from? I don't see that in the input? Commented Nov 2 at 17:22
  • @cfr: Sorry, please see amended MWE. Commented Nov 2 at 18:46

2 Answers 2

1

In order to take full advantage of acro in this regard you need to define a template, which just prints the foreign key (automatically with foreign-format)

\NewAcroTemplate{just-foreign}{\acrowrite{foreign}} 

which then allows you to define multiple commands that use the template, to cover the various cases that might come up.

\NewAcroCommand\acforeign{m}{\UseAcroTemplate{just-foreign}{#1}} \NewAcroCommand\Acforeign{m}{\acroupper\UseAcroTemplate{just-foreign}{#1}} \NewAcroCommand\acforeignpl{m}{\acroplural\UseAcroTemplate{just-foreign}{#1}} 

So in full

\documentclass[12pt]{report} \usepackage[T1]{fontenc} \usepackage{acro} \NewAcroTemplate{just-foreign}{\acrowrite{foreign}} \NewAcroCommand\acforeign{m}{\UseAcroTemplate{just-foreign}{#1}} \NewAcroCommand\Acforeign{m}{\acroupper\UseAcroTemplate{just-foreign}{#1}} \NewAcroCommand\acforeignpl{m}{\acroplural\UseAcroTemplate{just-foreign}{#1}} \DeclareAcronym{ym}{ short = {YM}, long = {Ministry of the Environment}, foreign={ympäristöministeriö / Miljöministeriet}, foreign-format = \textit, pdfcomment = {Ministry of the Environment} } \begin{document} Print here \acf{ym}. Print now only foreign \acforeign{ym}. Print now only capitalised foreign \Acforeign{ym}. Print now only foreign as plural \acforeignpl{ym}. \end{document} 

Print here Ministry of the Environment (ympäristöministeriö /Miljöministeriet, YM).

Print now only foreign ympäristöministeriö / Miljöministeriet.

Print now only capitalised foreign Ympäristöministeriö / Miljöministeriet.

Print now only foreign as plural ympäristöministeriö / Miljöministeriets.

Of course, I imagine the actual plural here would need correcting by explicitly setting foreign-plural-form for the acronym.

1
  • Superb, thanks a lot! Just what I was looking for... Commented Nov 5 at 13:19
2

In the dire straits I was in, looking for a quick answer, I came up with the following:

\NewAcroCommand\acforeign{m}{\emph{\acrofield{#1}{foreign}}} 

This gives me for:

\documentclass[12pt]{report} % --- Essential Packages --- \usepackage[T1]{fontenc} \usepackage[british]{babel} \usepackage{xcolor} \usepackage[most]{tcolorbox} \usepackage{tabularray} \UseTblrLibrary{booktabs} \usepackage[en-GB]{datetime2} \usepackage{acro} \DeclareAcronym{ym}{ short = {YM}, long = {Ministry of the Environment}, foreign={Ympäristöministeriö / Miljöministeriet}, foreign-format = \textit, tag = org, pdfcomment = {Ministry of the Environment} } \begin{document} Print here \acf{ym}. Print now only foreign \acforeign{ym}. \end{document} 

The following output:

enter image description here

It's not particularly nice aesthetically insofar as the code goes, especially as the foreign-style option is set, but I didn't find a way to apply that directly to the field.

I'd be happy to accept a better (more robust) answer in lieu of this one.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.