Feature Tracker
I’m currently working on a major new version of the datatool package. This may take a while. Please be patient. (Experimental version available for testing.)
ID | 30🔗 |
---|---|
Date: | 2015-01-04 18:12:37 |
Status | Open Sign in if you want to like this report. |
Category | glossaries |
Summary | Always use ranges in number lists |
Sign in to subscribe to notifications about this report.
Description
I think it's inconsistent, that the number lists in glossaries use ranges when using option 2 or 3 and do not use ranges with option 1 (especially as option 1 seems to be the future due to its elegance). I recommend to either use always ranges or make it always configurable.
I implemented the first approach by replacing \glsnoidxloclist
and \glsnoidxloclisthandler
and added some additional code:
\renewcommand*{\glsnoidxloclist}[1]{% % Remove duplicates and compress the list by using ranges. % The basic idea is to save a range begin and a range end, without % immediately printing every element. % Only if the range is complete, print it. This can only be checked when % processing the next element or after processing the list. \def\@gls@noidxloclist@sep{\def\@gls@noidxloclist@sep{\delimN}}% \def\@gls@noidxloclist@prev{}% \forlistloop{\glsnoidxloclisthandler}{#1}% \ifdef\@gls@noidxloclist@range@end{% \@gls@noidxloclist@print@range \undef\@gls@noidxloclist@range@begin \undef\@gls@noidxloclist@range@end }{% \ifdef\@gls@noidxloclist@range@begin{% \@gls@noidxloclist@sep\@gls@noidxloclist@range@begin \undef\@gls@noidxloclist@range@begin }{% }% }% } \renewcommand*{\glsnoidxloclisthandler}[1]{% \ifdefstring{\@gls@noidxloclist@prev}{#1}{% }{% \ifdef\@gls@noidxloclist@range@begin{% \ifdef\@gls@noidxloclist@range@end{% \@gls@noidxloclist@ifsuccessor{\@gls@noidxloclist@range@end}{#1}{% \def\@gls@noidxloclist@range@end{#1}% }{% \@gls@noidxloclist@print@range \def\@gls@noidxloclist@range@begin{#1}% \undef\@gls@noidxloclist@range@end }% }{% \@gls@noidxloclist@ifsuccessor{\@gls@noidxloclist@range@begin}{#1}{% \def\@gls@noidxloclist@range@end{#1}% }{% \@gls@noidxloclist@sep\@gls@noidxloclist@range@begin \def\@gls@noidxloclist@range@begin{#1}% }% }% }{% \def\@gls@noidxloclist@range@begin{#1}% }% \def\@gls@noidxloclist@prev{#1}% }% } \def\@gls@noidxloclist@print@range{% \expandafter\@gls@noidxloclist@ifsuccessor\expandafter\@gls@noidxloclist@range@begin\expandafter{\@gls@noidxloclist@range@end}{% \@gls@noidxloclist@sep\@gls@noidxloclist@range@begin\@gls@noidxloclist@sep\@gls@noidxloclist@range@end }{% \@gls@noidxloclist@sep\@gls@noidxloclist@range@begin\delimR\@gls@noidxloclist@range@end }% } % Executes the true branch if #2 is a successor of #1 in a mathematical sense (e.g., 5 is successor of 4). \def\@gls@noidxloclist@ifsuccessor#1#2{% % The first argument gets expanded once so that both arguments consist of five tokens. \expandafter\@gls@noidxloclist@ifsuccessor@\expandafter{#1}{#2}% } \def\@gls@noidxloclist@ifsuccessor@#1#2{% % The fifth token is extracted and expanded, as it contains a group. \expandafter\edef\expandafter\@gls@noidxloclist@firstnum\expandafter{\@fifthoffive#1}% \expandafter\edef\expandafter\@gls@noidxloclist@secondnum\expandafter{\@fifthoffive#2}% % The page number can be checked now. \ifnumequal{\@gls@noidxloclist@firstnum + 1}{\@gls@noidxloclist@secondnum}% } \long\def\@fifthoffive#1#2#3#4#5{#5}The code can probably be quite a bit improved, simplified and generalized. Testing is also necessary, I only tested it with one document in one configuration.
Patrick Häcker
MWE
No mwe.tex
Evaluation
Option 1 is an option of last resort if you are unable to use any external indexing tools for some reason. The build time is already slow with option 1, range-forming would further add to it. If you require ranges then you are far better off using an indexing application which can perform this action far more efficiently than TeX.
Note that if you use explicit ranges (with the (
and )
formats), the glossaries-extra.sty (which modifies \glsnoidxdisplayloc
) will implement the range.
Comments
0 comments.
Add Comment
Page permalink: https://www.dickimaw-books.com/featuretracker.php?key=30