1

I am writing a large report with many acronyms, some of which include each other. I asked about a way to let them do this in a specific way and got a very nice answer. Acronyms that include other acronyms

Now I find that i would like my acronyms to start with a capital letter in the list and I found a way to do this, Capitalize the first letter in acronym list, but when I try to use these together I get two errors Argument of \@acx has an extra } and Paragraph ended before \@acx was completed

Here is a minimal example

\documentclass[a4paper, 10pt]{report}

\usepackage[utf8]{inputenc} 
\usepackage[english]{babel} % English language/hyphenation
\usepackage{amsmath,amsfonts,amsthm}        % Math packages
\usepackage[pdftex]{graphicx}   % Enable pdflatex


\usepackage[printonlyused]{acronym}
\usepackage{etoolbox}


\makeatletter
\patchcmd{\AC@@acro}{] #3}{] \MakeUppercase #3}{}{}
\patchcmd{\AC@@acro}{] #3}{] \MakeUppercase #3}{}{}
\makeatother

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

\begin{document}

\begin{acronym}
\acro{q}[$Q$]{\acx{rms}reactive power}
\acro{rms}{root mean square}
\end{acronym}

\section{Text}

The \ac{q} is..... \ac{rms}...

\end{document}

EDIT:

I want the result to look like:

Result

Why is this happening? How can I solve it?

5
  • You're basically trying to do \MakeUppercase\acx, which of course fails. It's not really clear what you want \acx to do.
    – egreg
    Aug 11, 2015 at 17:20
  • @egreg The result I want is the one in the added picture. The first link explains the function of the \acx macro and this works perfectly without the upper case code. Yes I would like to do \MakeUppercase \acx why is this not possible? Could it be solve by forcing \acx to expand first?
    – Kajsa
    Aug 11, 2015 at 21:20
  • Why is the command patched twice?
    – cfr
    Aug 11, 2015 at 22:41
  • @cfr I do not know. That was the way it was written in the second link, where I found it.
    – Kajsa
    Aug 12, 2015 at 7:43
  • @Kajsa Just I wouldn't expect the second patch to have any effect because the pattern is no longer matched.
    – cfr
    Aug 12, 2015 at 21:37

1 Answer 1

1

Like this?

premature expansion

\documentclass[a4paper, 10pt]{report}
\usepackage[printonlyused]{acronym}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\AC@@acro}{] #3}{] \expandafter\MakeUppercase#3}{}{}
\makeatother

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

\begin{document}

\begin{acronym}
\acro{q}[$Q$]{\acx{rms}reactive power}
\acro{rms}{root mean square}
\end{acronym}

\section{Text}

The \ac{q} is..... \ac{rms}...

\end{document}
9
  • Almost. As you can see Q is not defined with a capital letter in the list. Is there any other difference than the \patchcmd{\AC@@acro}{] #3}{] \expandafter\MakeUppercase#3}{}{} line only being used once in this example and twice in mine?
    – Kajsa
    Aug 12, 2015 at 7:27
  • Now I see the difference. But how can the capitalization of the Q definition be solved?
    – Kajsa
    Aug 12, 2015 at 7:37
  • Why does \expandafter\MakeUppercase\ac{rms} used in the document cause ! Argument of \WSF@suffixcheck has an extra }. and ! Paragraph ended before \WSF@suffixcheck was complete.? Should it not mean that \ac{rms} is first expanded to 'root mean square' giving \MakeUppercase root mean square which should become 'Root mean square'?
    – Kajsa
    Aug 12, 2015 at 20:37
  • @Kajsa Well, it will try to expand just the \ac bit before \MakeUppercase, I think - it won't include the {rms} bit.
    – cfr
    Aug 12, 2015 at 21:38
  • Ok. That explains why it does not work. Is there a war to force it to expand the whole \ac{rms} command? I tried \expandafter\MakeUppercase\expandafter{\ac{rms}} which I found here: tex.stackexchange.com/questions/26747/… . But that does not work either, just produces a lot of errors.
    – Kajsa
    Aug 13, 2015 at 6:35

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.