[Tex/LaTex] Page order in list of acronyms with roman numbering

acronymsglossariesindexingpage-numbering

I have a document with three parts and different numbering: small roman numbers, arabic numbers and capital roman numbers. When printing the list of acronyms, the page order of an entry is always small roman number, capital roman number, arabic number, although the capital-roman-numbered pages are the last ones. How can I fix this?

\glshyperlinkis not an option since I still want the page numbers to appear.

\documentclass{article}
\usepackage[acronym,shortcuts,toc,hyperfirst=true,numberedsection=nolabel]{glossaries}
\setacronymstyle{long-short}
\makeglossaries
\newacronym{ABC}{ABC}{a blue cherry}
\newacronym{DEF}{DEF}{dry eggplant fruit}
\newacronym{GHI}{GHI}{green humongous iceberg lettuce}
\newacronym{JKL}{JKL}{jelly kiwi lentils}
\begin{document}
\pagenumbering{roman}
Today, I ate not only \ac{ABC}, but also \acp{DEF}.
\clearpage
\pagenumbering{arabic}
\Ac{ABC} is sweeter than a \ac{DEF}. And I ate a bit of \ac{GHI}.
The only thing I did not eat were \ac{JKL}.
\clearpage
\pagenumbering{Roman}
~
\clearpage
\ac{JKL} are even worse than \acp{DEF}.
\clearpage
\printglossary[type=\acronymtype,title={List of Abbreviations}]
\end{document}

list of abbreviations


EDIT: As was pointed out, the question boils down to "how do I teach makeindex to behave differently, or is there an alternative for makeindex?" with answers for both cases.

Best Answer

If makeindex is used and not xindy, there's a little bit more to do.

makeindex uses .ist (index style files) in which the precise setup for glossaries is written by glossaries on-the-fly, unless an explicit different file is given.

Here is the file that is generated for the jobname glossariespageorder.tex:

% makeindex style file created by the glossaries package
% for document 'glossariespageorder' on 2016-3-29
actual '?'
encap '|'
level '!'
quote '"'
keyword "\\glossaryentry"
preamble "\\glossarysection[\\glossarytoctitle]{\\glossarytitle}\\glossarypreamble\n\\begin{theglossary}\\glossaryheader\n"
postamble "\%\n\\end{theglossary}\\glossarypostamble\n"
group_skip "\\glsgroupskip\n"
item_0 "\%\n"
item_1 "\%\n"
item_2 "\%\n"
item_01 "\%\n"
item_x1 "\\relax \\glsresetentrylist\n"
item_12 "\%\n"
item_x2 "\\relax \\glsresetentrylist\n"
delim_0 "\{\\glossaryentrynumbers\{\\relax "
delim_1 "\{\\glossaryentrynumbers\{\\relax "
delim_2 "\{\\glossaryentrynumbers\{\\relax "
delim_t "\}\}"
delim_n "\\delimN "
delim_r "\\delimR "
headings_flag 1
heading_prefix "\\glsgroupheading\{"
heading_suffix "\}\\relax \\glsresetentrylist "
symhead_positive "glssymbols"
numhead_positive "glsnumbers"
page_compositor "."
suffix_2p ""
suffix_3p ""

The crucial point for this issue about the page order is the page_precedence key which is by default "rRnaA", not "rnR" as requested by the O.P.

As far as I know there's no easy way to use glossaries to write user-defined settings into this \jobname.ist file.

Here's a hack that sets the page_precedence to "rnRAa", i.e. lower case Roman numbers, arabic numbers, upper case Roman numbers, uppercase letters and lower case lettersby writing into the\glswrite` file.

Improved version

\documentclass{article}
\usepackage{xpatch}


\usepackage[nomain,acronym,shortcuts,toc,hyperfirst=true,numberedsection=nolabel]{glossaries}


\newcommand{\glspageprecedence}{rnRaA}

\newcommand{\glswritehookextra}{%
  \write\glswrite{page_precedence \string"\glspageprecedence\string"}
}

\xpatchcmd{\writeist}{%
  \fi
  \closeout\glswrite
  \let\writeist\relax
}{%
  \fi
  \glswritehookextra
  \closeout\glswrite
  \let\writeist\relax
}{}{\typeout{Error: patching \string\writeist failed}}


\setacronymstyle{long-short}
\makeglossaries
\newacronym{ABC}{ABC}{a blue cherry}
\newacronym{DEF}{DEF}{dry eggplant fruit}
\newacronym{GHI}{GHI}{green humongous iceberg lettuce}
\newacronym{JKL}{JKL}{jelly kiwi lentils}
\begin{document}
\pagenumbering{roman}
Today, I ate not only \ac{ABC}, but also \acp{DEF}.
\clearpage
\pagenumbering{arabic}
\Ac{ABC} is sweeter than a \ac{DEF}. And I ate a bit of \ac{GHI}.
The only thing I did not eat were \ac{JKL}.
\clearpage
\pagenumbering{Roman}
~
\clearpage
\ac{JKL} are even worse than \acp{DEF}.
\clearpage
\printglossary[type=\acronymtype,title={List of Abbreviations}]
\end{document}
Related Question