5

"For abbreviations and acronyms in the midst of normal text, use spaced small caps."—Bringhurst

What I generally see is that people wrap acronyms in something like \acro, as in TUGboat:

https://www.tug.org/tugboat/sampleart.ltx

I've been using something like the following in my own documents:

\usepackage{relsize}
\newcommand{\acro}[1]{{\textsmaller[0.5]{#1}}}

and of course there are other ways to do this.

Question: Any good solutions for doing this automatically? Like, could (La)TeX recognize that a word is all capitals and automatically typeset it accordingly? I'm happy to give it a list of words. I know I could write a script (e.g., python) that would replace all instances of each of those strings with \acro{string}, and maybe that's the only way to do it, but it would be nice to be able to do this within LaTeX as opposed to having to turn to an outside script.

Edit: Strongly prefer pdflatex solutions; I don't want to switch LaTeX engines just to solve this one small problem.

2
  • Did you find any good solution?
    – rainman
    Commented Aug 3, 2022 at 0:17
  • I did not. But I'm all ears!
    – jowens
    Commented Aug 4, 2022 at 16:56

1 Answer 1

3

Note that \acro already exists at least in acronym package, so it is better to use another name for a user macro.

Before trying any strategy to deal with acronyms, check in CTAN the packages designed for this purpose, or may you later regret starting this journey.

Said that, there is not an easy way to replace the format of some words except using macros, but there are xelatex/lualatex solutions to automatically search a list of words to change the format. For example, see Highlight every occurrence of a list of words?, Macro: Replace all occurrences of a word and Emphasizing all occurrences of given word in document. For instance, using xelated, a possible solution is using xesearch. Example:

\documentclass[twocolumn]{article}
\usepackage{xesearch,graphicx,xcolor}
\UndoBoundary{-} % hyphens in acronyms !!
\SearchList{acro}{\resizebox{!}{1.25ex}{\color{red!50!black}%
\uppercase{#1}}}{covid?,rna,DNA,elisa,*WHO,?pcr}
\SearchList{acrocase}{\resizebox{!}{1.25ex}{\color{red!50!black}%
#1}}{SARS-CoV-2}
\SearchList{countries}{\textsc{\color{blue!50!black}\lowercase{#1}}}{CZ,USA}
\begin{document}
Mr. So and So, from the WHO,   % case-sensitive acronym   
who                            % not an acronym !! 
has announced yesterday in the UK  % oops, not in the list!!
and the UsA that the eLiSa         % case-insensitive acronyms
test to detect antibodies against 
SARS-CoV-2                     % acronym with lower case 
in covid-19 patients with      % acronym  with wild suffix  
with first signs of the disease is useless,     
said now that even pcr         % wild case-insensitive acronym  
test like the RT-pcr           % prefix accepted as part of the acronym                     
Multiplex-{}pcr                % prefix rejected an part of the acronym 
used too early in the course of infection 
might produce false negative results.  
\end{document}

mwe

1
  • What is the difference between \lowercase and \MakeLowercase?
    – rainman
    Commented Aug 3, 2022 at 0:31

You must log in to answer this question.

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