I'm using a few acronyms in my thesis, and I want them to appear in the alphabetical index as:
ACR, see acronym
acronym, iii, 5, 48
This is my code:
\documentclass[11pt,a4paper]{book}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{imakeidx}
\usepackage{bookmark} % includes hyperref
\usepackage[toc,acronym]{glossaries}
\makeindex[intoc]
\makeglossaries
\newacronym{fmea}{FMEA}{Fail\-ure Mode and Ef\-fect A\-nal\-y\-sis}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
Occurrence of the acronym \acrlong{FMEA}
\index{FMEA}
\backmatter
\printglossary[type=\acronymtype,nonumberlist]
\index{failure mode and effect analysis|see{FMEA}}
\printindex
\end{document}
This code works perfectly but I have to declare each acronym twice (as newacronym and as index "see").
I introduced this command as a variant of \newacronym
which also generates the corresponding \index
voice:
\newcommand{\newacronymidx}[3]{
\newacronym{#1}{#2}{#3}
\index{\MakeLowercase{#3}|see #2}
}
\newacronym{fmea}{FMEA}{Fail\-ure Mode and Ef\-fect A\-nal\-y\-sis}
I have three problems:
- the "ACR, see acronym" index entry appears at the beginning of the alphabetical index instead of its correct alphabetically-sorted position
- now I get a page number after "ACR, see acronym", whose hyperlink refers to first page (the frontispiece, not included in this MWE)
- for some weird reason I can't understand, FMEA becomes FEA (which does not appear anywhere in my code)
In this example, FMEA is defined with \newacronymidx
, other acronyms with \newacronym and \index{acronym|see ACR}. The only wrong one is FMEA.
Question 1:
I think that the first two problems are related to the position of the \index
command in the source (which is now in the preamble). Is there any way to create an auxiliary files, use \makeacronymidx
to append a new line with the \index
command to this file, and use \include{myAuxFile}
right before \printindex
?
Question 2:
Any idea about FMEA becoming FEA in the index? This does not happen with this MWE, but I can't post the full code here...
Thank you!
EDIT: solved by Nicola Talbot in the comments
\newcommand{\newacronymidx}[3]{
\newacronym{#1}{#2}{#3}
\index{#3@\MakeLowercase{#3}|see {#2}}
}
\newacronymidx
is missing braces for thesee
argument:\index{\MakeLowercase{#3}|see #2}
should be\index{\MakeLowercase{#3}|see{#2}}
(which accounts for Question 2,M
is treated as the second argument which is ignored).\index{#3@\MakeLowercase{#3}|see{#2}}
. (Pretty sure this is a dup.)