Deactivate underscores when expanding natbib's \bibitem[label]#2385
Deactivate underscores when expanding natbib's \bibitem[label]#2385dginev wants to merge 2 commits intobrucemiller:masterfrom
Conversation
|
This idea may warrant some extra discussion... If we want math mode constructs to still expand in this argument,such as: \bibitem[Ex$\ddot{a}$mple(1899)]{...}then Maybe I should invent a new parameter type, which only deactivates the underscore? Thoughts welcome. That would look a bit more on the lines of: DefParameterType('NatbibSemiVerbatim', sub {
# deactivated underscore
my $arg = $_[0]->readArg;
my @inactive = map {Equals($_, T_SUB) ? T_OTHER("_") : $_ } $arg->unlist;
return Tokens(@inactive); });Edit: a slightly more direct version of a new parameter, which only deactivates underscore. A bit patchy possibly, but it is a little unclear which behavior natbib is aiming for exactly. |
06e0e91 to
b8731d7
Compare
|
The general observation is that when a bare label is used in natbib's So, for now, I have decided to not change the parameter types, but instead guard LaTeXML's emulation which uses an explicit I also added a test for this kind of tortured use case. |
|
Your last observation almost gets it, I think. This label argument is getting expanded before writing to the aux file, but it is not digested until later, and only if the bibitem is cited. So that would mean that undefined macros or |
|
Good point, we should be approaching this even more generally. Having a dedicated parameter type that "postpones" the errors of certain Digest steps could be tricky... But maybe there is something there. We have a natural place to anchor such a new parameter, at the |
This is a minor change avoiding a needless error in natbib's \bibitem.
A minimal motivating example (that I could turn into a test) is:
Note the underscores in the
\bibitemuse, especially the one in the optional label[]argument. These survive well under pdflatex -- and to my observations are largely ignored, at least in the specific document I am studying that uses this.With the current latexml master, this example produces two unfortunate errors of the kind:
The PR simply switches the offending argument to
Semiverbatimin the natbib parser, deactivating the underscore's math behavior.