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?
Asked
Active
Viewed 1,209 times
2 Answers
3
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
function FindAcronyms ( file )
local param
local Table = {}
local f = assert(io.open(file, "r"))
local t = f:read("*all")
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}
Tarass
- 16,912

glossariesoracro? – cgnieder May 04 '15 at 17:18sed -i .bak "s@[[:<:]][A-Z][A-Z][A-Z]*[[:>:]]@\\\ac{&}@g" file.texdoes what you want on my system. This will replace any "word" in the filefile.texthat consists of 2 or more capital letters with\ac{<word>}. The original file is saved asfile.tex.bakjust to be safe. – May 04 '15 at 23:09.s in the regular expression would be easy enough, but I agree it's unlikely to be complete accurate. As for cdROM, surely it would be CD or CDROM:) – Jun 03 '15 at 21:10