3

This question is mainly to collect your opinion, and probably to reach a good solution. That said, let's go to the discussion topic and question.

I commonly use the acronym package in my work, mainly to write article with lots of abbreviations. Sometimes I also use glossaries for the same purpose. I know there are others.

Well, when using those, it sometime may happen that an acronym is expanded inside parentheses, e.g.,

the \ac{BS} (also known as \ac{eNB})

become

the Base Station (BS) (also known as Enhanced Node B (eNB))

As it may be seen, in the second expansion, it get nested parentheses. To avoid this, I sometimes use \acs{} instead of \ac{} while inside parentheses. However, it may happen that the acronym is first used inside the parentheses, and with this approach it is not expanded in the first use.

I was reading link 1 and link 2, and while people said it is acceptable, others recommend to rephase, or use brackets. With brackets, my simple example would become

the Base Station (BS) (also known as Enhanced Node B [eNB])

A solution for this, would be use always brackets instead of parentheses while using acronyms. But I don't know if it is acceptable of all purposes or not.

What is your opinion?

Further, is it possible to say to acronym or other package to use brackets inside parentheses?

\documentclass{article}

\usepackage{acronym}

\begin{document}

\begin{acronym}
  \acro{BS}{Base Station}
  \acro{eNB}{Enhanced Node B}
\end{acronym}

the \ac{BS} (also known as \ac{eNB})

\end{document}
4
  • 2
    The \ac{BS}, also known as \ac{eNB}, ...
    – egreg
    Mar 18, 2013 at 17:50
  • @egreg I know that I can most of the times re-work the text. This is just a simple example. But possibly there are others, where it is better to keep parentheses.
    – cacamailg
    Mar 18, 2013 at 17:53
  • You can set the acronym as used even if you use \acs{<label>} by calling \acused{<label>}. That's what I've been doing as a workaround in general. You can probably put those two in a macro if you want to save some keypresses.
    – jja
    Mar 18, 2013 at 18:21
  • That is a possible solution. But as I said in the post, if it is the first time, the acronym is not expanded. The problem become worst if you are in a paper because you should use nolist option to the package.
    – cacamailg
    Mar 18, 2013 at 18:39

2 Answers 2

4

I can't help with the acronym package as I don't use it, but if you don't mind using glossaries instead you can do the following:

\documentclass{article}

\usepackage[shortcuts]{glossaries}

\newacronym{bs}{BS}{Base Station}
\newacronym{enb}{eNB}{Enhanced Node B}

\newcommand*{\pac}[2][]{\ifglsused{#2}{\acs[#1]{#2}}{%
 \glsunset{#2}%
 \acl[#1]{#2} [\acs[#1]{#2}]}}

\begin{document}

\ac{bs} (also known as \pac{enb}).

Later: \ac{bs} (also \pac{enb})

\end{document}

Here you can just use \pac instead of \ac when you want to use the acronym in parentheses.

Result:

Image of resulting text

An alternative approach (which most may consider overkill) is to do:

\documentclass{article}

\usepackage[shortcuts]{glossaries}

\newcount\parencount
\DeclareRobustCommand{\openparen}{\global\advance\parencount by 1\relax
\ifodd\parencount(\else[\fi}
\DeclareRobustCommand{\closeparen}{\ifodd\parencount)\else]\fi
 \global\advance\parencount by -1\relax
}

\catcode`\(=\active
\catcode`\)=\active

\let(\openparen
\let)\closeparen

\renewcommand{\acrfullformat}[2]{#1\space\noexpand\openparen#2\noexpand\closeparen}

\newacronym{bs}{BS}{Base Station}
\newacronym{enb}{eNB}{Enhanced Node B}

\begin{document}

Some parenthesis: (outer level (inner level (getting silly))).

\ac{bs} (also known as \ac{enb}).

\end{document}

Result:

Image of resulting text

Edit: Caveat: it's best not to use the second approach if you use a package such as tikz where parentheses form part of the command syntax.

Edit: Here's an example that switches back and forth, which can either be done by changing the category codes of ( and ) or changing their definition:

\documentclass{article}

\let\orgopenparen(
\let\orgcloseparen)

\newcount\parencount
\DeclareRobustCommand{\openparen}{\global\advance\parencount by 1\relax 
\ifodd\parencount(\else[\fi}
\DeclareRobustCommand{\closeparen}{\ifodd\parencount)\else]\fi
 \global\advance\parencount by -1\relax
}

\catcode`\(=\active
\catcode`\)=\active

\let(\openparen
\let)\closeparen

\begin{document}

Some parenthesis: (outer level (inner level (getting silly))).

% restore original behaviour (changing definition)
\let(\orgopenparen
\let)\orgcloseparen

Some parenthesis: (outer level (inner level (getting silly))).

% switch back

\let(\openparen
\let)\closeparen

Some parenthesis: (outer level (inner level (getting silly))).

% restore original behaviour (changing category code)
\catcode`\(=12\relax
\catcode`\)=12\relax

Some parenthesis: (outer level (inner level (getting silly))).

\end{document}

Result:

Image of resulting text

4
  • Your solution seems very good. I will try it later. It seems to do what I was checking. I think it can be an be an improvement for glossaries or acronym packages
    – cacamailg
    Mar 20, 2013 at 18:23
  • The latest solution does work with acronym if it is loaded before that package. Is it possible in the latest solution get the normal meaning of () after using a command like \ac{}? Something like: 1. save previous meaning; 2. refine meaning in nested mode; 3. use acronym command; 4. restore saved meaning.
    – cacamailg
    Mar 21, 2013 at 13:11
  • @cacamailg I've added an extra example that shows you how to restore the meaning of ( and ). Mar 21, 2013 at 15:22
  • Thanks! I knew that to restore the meaning was something like you did, but I couldn't figure out the catcode.
    – cacamailg
    Mar 21, 2013 at 16:05
0

As to the OP's question:

Further, is it possible to say to acronym or other package to use brackets inside parentheses?

Yes, it is. For acronym package, simply use:

\acrodef{eNB}[{[}eNB{]}]{Enhanced Node B}

Notice that you have to escape the square brackets by putting each inside {}.

You must log in to answer this question.

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