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?

Kajsa
  • 677
  • 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 '15 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 '15 at 21:20
  • Why is the command patched twice? – cfr Aug 11 '15 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 '15 at 07:43
  • @Kajsa Just I wouldn't expect the second patch to have any effect because the pattern is no longer matched. – cfr Aug 12 '15 at 21:37

1 Answers1

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}
cfr
  • 198,882
  • 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 '15 at 07:27
  • Now I see the difference. But how can the capitalization of the Q definition be solved? – Kajsa Aug 12 '15 at 07: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 '15 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 '15 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: http://tex.stackexchange.com/questions/26747/tex-macro-and-command-expansion . But that does not work either, just produces a lot of errors. – Kajsa Aug 13 '15 at 06:35
  • @Kajsa I'm not sure: that would just expand \MakeUppercase after \expandafter. So you'd need e.g. \expandafter\expandafter\expandafter\MakeUppercase... or something. But I think that expanding \acx will conflict with the \protect, won't it? – cfr Aug 13 '15 at 14:59
  • I am not using \acx but \ac at present. – Kajsa Aug 13 '15 at 19:33
  • @Kajsa Well, you are using \acx as well in the argument to \acro. – cfr Aug 13 '15 at 21:01
  • No, not in the rms case. At present that is the only \acro in the list. – Kajsa Aug 14 '15 at 18:44