# Automatically capture acronyms

I'm writing my thesis using Latex. And I'm wondering if there is an automatic or an easy way to write my acronyms. I did that before in Microsoft Word where I search for all words that are upper case then add them to my acronyms and sort them alphabetically?

• @Rmano I don't see how this is a similar question. – Tak May 4 '15 at 11:42
• @Rmano: That's a completely different problem. The OP is after automation, not for the basic usage of acronyms – user31729 May 4 '15 at 12:24
• You could use grep to search for all uppercase characters and generate the TeX commands. – Uwe Ziegenhagen May 4 '15 at 13:21
• Just to add to the question: and sort them alphabetically – latex fan May 4 '15 at 14:04
• @latexfan Done :) – Tak May 4 '15 at 14:05

\documentclass{article}
\usepackage{luacode}

\begin{luacode}
function FindAcronyms ( file )
local param
local Table = {}

local f = assert(io.open(file, "r"))
f:close()
for param in t:gmatch ("[^%l]%s?(%u+)%p?%s")
do
table.insert(Table, param)
end

table.sort(Table)
tex.print("\\bigskip")
for i,acronym in ipairs (Table)
do
tex.print (i.." : "..acronym.."\\\\")
end
end

\end{luacode}

\newcommand{\FindAcronyms}{%
\directlua{FindAcronyms("\jobname.tex")}
}

\begin{document}

CCC! SomeThing ELSe AAA, CABA enD BAA

\FindAcronyms

\end{document}

• Are you looking for \jobname.tex? – egreg Aug 3 '15 at 10:49

Not sure I understand what you are after, but may be package acronym will be of interest to you. It expands acronyms on first use and allows you to compile a list of them all.

• I know this. But this is not what I'm looking for in my question. – Tak May 4 '15 at 13:38