1

I am using the acronym package for translations but I am facing nested parenthesis problems.

The code:

 \usepackage[printonlyused, withpage]{acronym}
 \acro{RTS}{Real-Time Systems}
    
 Sistemas de tempo real (\ac{RTS}) 

PDF (the page number perfectly appears in the list of acronyms):

Sistemas de tempo real (Real-Time Systems (RTS))

Is there a way to replace the parenthesis with "-", so that the final text is like below, and the page number is still referenced in the acronym list?

Sistemas de tempo real (Real-Time Systems - RTS)

I have doubled the text and tried \acf. The final text is ok but it removes the page number from the acronym list.

The code:

\usepackage[printonlyused, withpage]{acronym} %adiciona lista de acrônimos.
\acro{RTS}{\textit{Real-Time System}}

Sistemas de tempo real (\textit{Real-Time Systems} - \acf{RTS}) 

PDF (page number does NOT appear in the list of acronyms):

Sistemas de tempo real (Real-Time Systems - RTS)

Any hints?

Thanks

1 Answer 1

0

Yes, but it's not pretty, and redefines first-style for all acronyms.

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

\makeatletter
\renewcommand*{\@acf}[2][\AC@linebreakpenalty]{%
  \ifAC@footnote
    \acsfont{\AC@acs{#2}}%
    \footnote{\AC@placelabel{#2}\AC@acl{#2}{}}%
  \else
    \acffont{%
      \AC@placelabel{#2}\AC@acl{#2}%
      \nolinebreak[#1] --\nolinebreak[#1] %
      \acfsfont{\acsfont{\AC@acs{#2}}}%
    }%
  \fi
  \ifAC@starred\else\AC@logged{#2}\fi
}
\renewcommand*{\@Acf}[2][\AC@linebreakpenalty]{%
  \ifAC@footnote
    \acsfont{\AC@acs{#2}}%
    \footnote{\AC@placelabel{#2}\AC@Acl{#2}{}}%
    \else
    \acffont{%
      \AC@placelabel{#2}\AC@Acl{#2}%
      \nolinebreak[#1] --\nolinebreak[#1] %
      \acfsfont{\acsfont{\AC@acs{#2}}}%
    }%
  \fi
  \ifAC@starred\else\AC@logged{#2}\fi
}
\makeatother

\begin{document}
\begin{acronym}
\acro{RTS}{Real-Time Systems}
\end{acronym}

Sistemas de tempo real (\ac{RTS}) 

\end{document}

Sistemas de tempo real (Real-Time Systems – RTS)

With acro it's a lot nicer, you can define new styles at the user level and set them both locally and globally, or define new \ac-type commands.

\documentclass{article}
\usepackage{acro}

\DeclareAcronym{RTS}{
  short = RTS,
  long = Real-Time Systems,
  first-style = long-short-dashed
}
\DeclareAcronym{CD}{
  short = CD,
  long = compact disc,
}

\NewAcroTemplate{long-short-dashed}{%
\acroiffirstTF{%
  \acrowrite{long}%
    \acspace--\acspace%
    \acroifT{foreign}{\acrowrite{foreign}, }%
    \acrowrite{short}%
    \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}%
    \acrogroupcite
  }%
  {\acrowrite{short}}%
}

\NewAcroCommand{\acd}{m}{\UseAcroTemplate{long-short-dashed}{#1}}

\begin{document}
\printacronyms[pages={display=all}]

Sistemas de tempo real (\ac*{RTS}) 

\ac{CD}\acreset{CD}

\acd*{CD}

\acsetup{first-style=long-short-dashed}
\ac{CD}

\end{document}

Sistemas de tempo real (Real-Time Systems) compact disc (CD) compact disc – CD compact disc – CD

On top of that, acro has built-in support for foreign acronyms

\documentclass{article}
\usepackage{acro}

\DeclareAcronym{RTS}{
  short = RTS,
  long = sistemas de tempo real,
  foreign = Real-Time Systems,
}

\begin{document}
\printacronyms[pages={display=all}]

\Ac{RTS}

\end{document}

Sistemas de tempo real (Real-Time Systems, RTS)

which seems to be what you're trying to do, and we can change the style to a dash with

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

Sistemas de tempo real (Real-Time Systems – RTS)

1
  • Thank you so much!
    – jamilev
    Apr 7, 2023 at 19:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .