PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
266 stars 208 forks source link

index entries with certain characters fail #1123

Open kcrisman opened 5 years ago

kcrisman commented 5 years ago

Unbelievable how picky LaTeX is with indexing. Yet another exhibit:

Consider the code

<idx sortby="interact"><c>@interact</c></idx>

In html, all is well, as usual. However, in .tex this yields

\index{interact@\mono{@interact}}%

which fails to compile, as one can see by checking the .ilg or .idx file created by LaTeX. There is also the very small suggestion of a warning

Scanning input file ntic.idx....done (666 entries accepted, 1 rejected).

It turns out that for the characters !, @, and |, we have to instead escape them for the index to work - with ", of all things!

\index{interact@\mono{"@interact}}%

I have no idea whether this is worth trying to hack our way around, or just to warn authors. I certainly can imagine, as the original poster says in the tex.SE question, someone authoring a book including ! for various purposes in an index that included frequently used commands.

rbeezer commented 5 years ago

Oscar made an issue for something similar to this. I failed dramatically to implement the suggestions.

We could render the HTML-index logic as LaTeX instead?

On 6/28/19 2:55 PM, kcrisman wrote:

Unbelievable how picky LaTeX is with indexing. Yet another exhibit:

Consider the code

|c>@interact</c |

In html, all is well, as usual. However, in |.tex| this yields

|\index{interact@\mono{@interact}}% |

which fails to compile, as one can see by checking the |.ilg| or |.idx| file created by LaTeX. There is also the very small suggestion of a warning

|Scanning input file ntic.idx....done (666 entries accepted, 1 rejected). |

It turns out that https://tex.stackexchange.com/questions/324842/is-it-possible-to-index-an-exclamation-point for the characters |!|, |@|, and |||, we have to instead escape them for the index to work - with |"|, of all things!

|\index{interact@\mono{"@interact}}% |

I have no idea whether this is worth trying to hack our way around, or just to warn authors. I certainly can imagine, as the original poster says in the tex.SE question, someone authoring a book including |!| for various purposes in an index that included frequently used commands.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rbeezer/mathbook/issues/1123?email_source=notifications&email_token=AAOLM4TSYVY4YQGJ3LGLTRLP42CDPA5CNFSM4H4IX3G2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4M5VHQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOLM4Q4VTW25T7BT7VNGCTP42CDPANCNFSM4H4IX3GQ.

kcrisman commented 5 years ago

We could render the HTML-index logic as LaTeX instead?

Wow, that sounds ambitious. I'm not sure this would automatically work in this case, because the @ character would still be there - I don't think that is handled specially in the html case, is it?

Ideally this would somehow be detected by the xsl, but I don't know that it will do regex; one could cop out and tell publishers to be wary and possibly do hand-edits, as I am told they already have to do now with the tex.

kcrisman commented 5 years ago

This is the same issue as #691 as @rbeezer points out. I didn't see it because it didn't have idx in it! Sorry. @oscarlevin even linked to the same tex.SE place!

kcrisman commented 3 years ago

Some possible ideas for how to naively accomplish this solely in XSLT 1.0: