2

I am trying to add four specific features to the acronym package and plug it into Overleaf:

  1. \acrounlisted - creates an unlisted acronym, which would be treated like an acronym (in that the first time it's used it would define it and then just use the acronym after that), but it wouldn't appear in the List of Acronyms.
  2. \acfirstuc - Makes the first word in the definition uppercase iff it has not yet be used--otherwise, it's just \ac.
  3. \acalluc - Makes each word in the full definition upper case (e.g., if \ac{ods} expands to "oxide dispersion strengthened (ODS)", then \acalluc would expand to "Oxide Dispersion Strengthened (ODS)").
  4. \aclc - Makes each word in the full definition lower case (e.g., if \ac{ods} expands to "Oxide Dispersion Strengthened (ODS)", then \aclc{ods} would be "oxide dispersion strengthened (ods)").

I have specific reasons for this in my thesis. I realize that unlisted would cause some problems with the link that is generated to between the acronym and the list of acronyms, so that should probably be stripped out, too.

The problem is that I'm a little bit new to LaTeX, and anything I try irreparably breaks the package. I'm using the acronym.sty file from the TDS archive on CTAN, and using \RequirePackage{} to bring in a renamed version of the .sty into my project's class file. I was trying to use \lowercase and \capitalizewords from mfirstuc. I don't know how to just capitalize the very first letter (and if it's terribly difficult, I will leave that one off), or how to properly implement these.

Is anybody willing to take a look and give me some pointers on how to modify this thing?

4
  • I can probably not be of great help here, but you may want to consider splitting your question into several questions for each issue. At least to me the first point is not really related to points 2-4 and so you and others could greatly benefit from separate questions there. See also tex.meta.stackexchange.com/q/7425/35864 on Meta. It might also encourage other people to help you and make it easier for them to get started if you could add a short example document with a few toy acronyms to your question (in the spirit of an tex.meta.stackexchange.com/q/228/35864).
    – moewe
    Commented Dec 5, 2018 at 7:08
  • 1
    Are you tied to the acronym package? Those things can be achieved with the glossaries package. (In fact, mfirstuc was originally part of the glossaries distribution before it was split off into an independent package.) Commented Dec 5, 2018 at 14:51
  • Nicola, I am not tied to it, no. I will have to look into the glossaries package. Thank you for that suggestion! moewe, you have a good point. I'll have to revise this, but it will have to wait until next week. Thank you both!
    – Jordan A
    Commented Dec 6, 2018 at 16:28
  • Do you have any news for us? Is your issue solved? How?
    – Mensch
    Commented Jun 24, 2019 at 7:44

1 Answer 1

0

Here are solutions to your four listed problems. These solutions are for users unable or unwilling to switch from the acronym package to the glossaries package:

  1. Instead of defining an acronym that you do not want listed with \acro{⟨acronym⟩}[⟨short name⟩]{⟨full name⟩} inside of the acronym environment, define the acronym with \newacro{⟨acronym⟩}[⟨short name⟩]{⟨full name⟩} outside of the acronym environment. No new command is needed.

  2. Because the definition is automatically printed only when the acronym has not yet been marked as used (the acronym package documentation explains these circumstances well), you can safely use \Ac to print your acronyms in the text of your document to get your desired output. If the acronym has not yet been marked as used, the definition will print with the first letter of the first word in uppercase; else, if it has been marked as used, just the acronym will print without its definition. No new command is needed.

  3. To accomplish this, I renewed the command that the acronym package defined to capitalize the first letter of the definition so that it capitalizes the first letter of every word in the definition. This required me to use the mfirstuc package. I then called the standard \Ac command so that it would follow the package standard to print the full or short form for whether it had already been used. See the solution in the code block below.

  4. To accomplish this, I renewed the command that the acronym package defined to capitalize the first letter of the definition so that it makes the entire definition lowercase. I also renewed the \acsfont command to make the short form lowercase, which I needed to reset back to its default. I then called the standard \Ac command so that it would follow the package standard to print the full or short form for whether it had already been used. See the solution in the code block below.

Here's the MWE:

\documentclass{article}
\usepackage{acronym}

\usepackage{mfirstuc}
\makeatletter
\DeclareRobustCommand{\acalluc}[1]{%
    \renewcommand{\@firstupper}[1]{\ecapitalisewords{##1}}%
    \Ac{#1}%
}
\DeclareRobustCommand{\aclc}[1]{%
    \renewcommand{\@firstupper}[1]{\expandafter\MakeLowercase\expandafter{##1}}%
    \renewcommand*{\acsfont}[1]{\MakeLowercase{##1}}%
    \Ac{#1}%
    \renewcommand*{\acsfont}[1]{##1}%
}
\makeatother

\begin{document}

\section{Acronyms}
\newacro{DNLM}{do not list me}
\begin{acronym}
\acro{ODS}{Oxide Dispersion Strengthened}
\acro{SOD}{strengthened oxide dispersion}
\end{acronym}

\section{Introduction}
\Ac{DNLM} is not really a good acronym.  I just used \ac{DNLM} for this example.

Sometimes, there is a need to print an acronym in Title Case, like \acalluc{SOD}.  Other times, the whole thing needs to be lowercase, as in \aclc{ODS}.
\acresetall

Then again, it might be sufficient to print them normally, as in \ac{ODS} and \ac{SOD}.  After they are marked as used, only the short form is printed, as in:
\begin{enumerate}
    \item \acalluc{SOD}
    \item \aclc{ODS}
    \item \ac{ODS}
    \item \ac{SOD}
\end{enumerate}

\end{document}

Screenshot of MWE

1
  • This is far more elegant than the solution I came up with--thank you, Possum!
    – Jordan A
    Commented Nov 4, 2022 at 6:46

You must log in to answer this question.

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