4

My question is really a further question of this post.

I've used the following code from there in my tex doc.:

    \documentclass{article}
    \usepackage{acronym}
    \usepackage{etoolbox}
    \makeatletter
    \newif\if@in@acrolist
    \AtBeginEnvironment{acronym}{\@in@acrolisttrue}
    \newrobustcmd{\LU}[2]{\if@in@acrolist#1\else#2\fi}

    \newcommand{\ACF}[1]{{\@in@acrolisttrue\acf{#1}}}
    \makeatother

    \begin{document}
    \begin{acronym}
    \acro{SRS}{\LU{S}{s}patial \LU{R}{r}eference \LU{S}{s}ystem}
    \acro{DC}{\LU{D}{d}irect \LU{C}{c}urrent}
    \end{acronym}

    Batteries run on \ac{DC} and \ac{SRS} are different things.
    \end{document}

This works great. But what happens if you would normally want the acronym lower case but, since it appears at the start of a sentence, you want only the first letter of the first word to be capitalised?

I'm now using the same code fragments as above, but when I start the sentence with:

\ac{dc} lorum impsom...

It gives me:

direct current lorum impsom...

instead of:

Direct current lorum impsom...

Is this an easy fix?

FYI, I've already tried \Ac{} or \Acp{} but they didn't work. I suspect I need to create a new command, but I don't know how, which is why I'm coming to you lovely people.

Further, I'm having issues with pluralisation. If I want to pluralise something, I would normally use the \acp{} command. However, if I want capitals AND pluralisation, \ACP{} doesn't work.

E_L
  • 581

3 Answers3

5

One possibility would be to switch to the acro package. It provides what you need:

\documentclass{article}
\usepackage{acro}
\acsetup{list-long-format=\capitalisewords}
\usepackage{mfirstuc}% provides \capitalisewords

\DeclareAcronym{SRS}{
  short = SRS ,
  long  = spatial reference system
}
\DeclareAcronym{DC}{
  short = DC ,
  long  = direct current
}

\begin{document}

Batteries run on \ac{DC} and \ac{SRS} are different things.
Batteries run on \ac{DC} and \ac{SRS} are different things.

\Acl{DC} bla ...

\printacronyms

\end{document}

enter image description here

cgnieder
  • 66,645
  • Have tried using acro before but I had major issues. Unfortunately I don't document anything and my memory is appalling so I can't remember what the issues were. So I'm trying again. I think I've managed to get it to work but biblatex/biber has completely spazzed out and is preventing compilation, so once I've finished that I'll report back. – E_L Nov 02 '12 at 15:49
  • 1
    @E_L if you're having issues with acro it'd be nice if you reported them to https://bitbucket.org/cgnieder/acro/issues – cgnieder Nov 02 '12 at 15:57
  • Will do @cgnieder. Like I said, I can't remember the original reasons I gave up on acro but if I find some clangers I let you know. – E_L Nov 05 '12 at 09:17
  • I'm getting loads of errors:
        `! Undefined control sequence.
    l.38 \newacro
             {dc}[\AC@hyperlink{dc}{DC}]{\LU {D}{d}irect \LU {C}{c}urrent}
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., '\hobx'), type 'I' and the correct
    spelling (e.g., 'I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.`
    
    – E_L Nov 05 '12 at 14:28
  • As you can see in my example acro does not use \newacro. Have you read the manual? – cgnieder Nov 05 '12 at 15:20
  • I did read the manual and I couldn't see where it was going wrong. But after some more investigation, it seems that it was some crud left over in the .aux file and acro or TeXnicCenter wasn't changing/clearing it. Deleting the .aux seemed to sort that and it now looks like it works on a basic level. Still have a couple of questions but hopefully I'll be able to solve them by playing with the various package options. Will let you know how it goes. – E_L Nov 05 '12 at 16:08
  • Hi @cgnieder, all looks to be working now. Just one thing I can't work out: if I use the phrase analogue-to-digital converter, it gets represented by the acro package as Analogue-to-digital Converter instead of Analogue-to-Digital Converter. ie. the d doesn't get capitalised. Is there a way to tell the package that this letter is to be capitalised when necessary? The alternative is that I could remove the hyphens but then the 'to' gets capitalised too, and I'd then need a command to force that word specifically to be lower case. Thanks – E_L Nov 06 '12 at 10:15
  • 1
    That's because \capitalisewords from mfirstuc recognizes “analogue-to-digital” as one word. Leaving the hyphens out the package suggests something like \capitalisewords{analogue\space to digital converter} to produce “Analogue to Digital Converter” – cgnieder Nov 06 '12 at 10:24
2

I had the same problem and solved it for my purposes by simply definiing two acronyms, one for use in mid-sentnece, and one for initial sentence use. Each marks the other acronym as used.

\newacro{abr}[abr\acused{Abr}]{abbrevation} % Mid-sentence
\newacro{Abr}[abr\acused{abr}]{Abbrevation} % Sentence initial
Andreas
  • 867
1

[This is an attempt at a solution, not a solution!]

The ability to choose between mixed cases in the acronym package is desperately lacking. The new command you alluded to in your original question would be really helpful. I've had a crack but can't get it to work, it needs to be something like:

\newrobustcmd{\LU}[4]{\if@in@acrolist#1\else#2\fi} % upper case in acronym list lower case elsewhere
\newcommand{\AC}[1]{{\@in@acrolisttrue\ac{#1}}} % for choosing upper case elsewhere
\newcommand{\UAC}[1]{{\@in@acrolisttrue\ac{#3}}} % for choosing upper/lower case elsewhere
\newcommand{\LAC}[1]{{\@in@acrolisttrue\ac{#4}}} % for choosing lower/upper case elsewhere

\begin{acronym}
\acro{Abr}[\LU{A}{a}{a}{A}br]{\LU{A}{a}{A}{a}bbreviation}
\end{acronym}

Getting the commands to work might involve using ## and \protect. Hope this inspires someone to give it a go.

Kidja
  • 11