Is there a way to force LaTeX to automatically use small-caps for abbreviations and acronyms (or more specifically, strings of two or more uppercase letters)?


I think it's difficult to implement such macros. However, we can do it with help from some preprocess. It easy to write a script to do this. For example, an one-line script of sed:

sed -e "s/\(\s\)\([A-Z]\+\)\([^A-Z]\)/\1\\\textsc{\2}\3/g" foo.tex

You may modify it as your wish.

On windows platform sed have to be installed manually, from GNUWin32 or MingW. Just write a batch file and configure the editor to call it.

  • I thought of doing something similar to that; however, I want to keep this type of styling separate from the content, if at all possible. – squidbear Dec 31 '10 at 6:13
  • @squidbear: But this way you can keep styling separate from content. Your content is in foo.tex; this is the master file that you edit. Your styling is in a script. Your makefile (or whatever you use to produce the final PDF document) first invokes the script to produce bar.tex from foo.tex, and after that it runs pdflatex, etc., on bar.tex. File bar.tex is just a temporary file that you can delete after compilation. – Jukka Suomela Jan 1 '11 at 11:16
  • A slightly less complicated implementation of that sed command is as follows: sed -E -e "s/([A-Z][A-Z]+)/\\\textsc{\\\MakeLowercase{\1}}/g" foo.tex. It doesn't do any front/back of word checking, but it does incorporate the use of \MakeLowercase to format the small-caps words properly when wrapped in the \textsc command. – squidbear Jul 25 '13 at 6:08

You might want to take a look at the glossaries package.

\newacronym{WHO}{WHO}{World Health Organisation}
The \gls{WHO} recommends...
  • This would be useful if I were writing an extensive informative paper, but I am more interested in an application for novels. In other words, I would like to see the small-caps styling applied to words such as "AM" and "PM" (where it doesn't necessarily make sense to put such words in a glossary context). – squidbear Dec 31 '10 at 19:43
  • Wouldnt it be much easier to just do this in the texteditor with find/replace with ? The list of abbreviations used in a novel won't be very big. If you use a texteditor that supports Perl style regex, you can even do this in one go with a simple command. – Timtico Jan 1 '11 at 12:59
  • @squidbear: I would write with lowercase and periods: a.m. and p.m. Why should they be (small)capitalized when none of the other latin abbreviations are? – mk12 May 19 '13 at 22:57

If you don't need all of the power of the glossaries package, you could use the acronym package instead. The main idea remains the same. If you want LaTeX to do something with particular types of elements, you must create a markup for them. So if you want to do this within LaTeX itself, (which IMO is preferable) then you will need to explicily mark the relevant elements every time you use them. (This also has the advantage that if you decide later that they shouldn't be in small caps, one change will change them all.) Here's a solution to your problem using the acronym package.



At 3:00~\ac{PM} John went out.  He didn't return until 2:00~\ac{AM}.

(Note that since textsc{AM} is indistinguishable from AM, we need to change your existing uppercase acronyms to lowercase before making them small caps. This is what the \acsfont macro is doing.)


I've been thinking about this myself, as I will need it soon.

For you, Wouldnt it be much easier to just do this in the texteditor with find x/replace function (\textsc{x})? The list of abbreviations used in a novel won't be very big.

If you use a texteditor that supports Perl style regex or simpler regex, you can even replace all wanted abbreviations in one single run.

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.