diff --git a/MANIFEST b/MANIFEST index 6dfd9301f..c879cb0fe 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1674,6 +1674,9 @@ t/structure/lit.bib t/structure/crazybib.pdf t/structure/crazybib.tex t/structure/crazybib.xml +t/structure/crazybibkeys.pdf +t/structure/crazybibkeys.tex +t/structure/crazybibkeys.xml t/structure/csquotes.pdf t/structure/csquotes.tex t/structure/csquotes.xml diff --git a/lib/LaTeXML/Package/natbib.sty.ltxml b/lib/LaTeXML/Package/natbib.sty.ltxml index d7e9bd31e..e009cff3a 100644 --- a/lib/LaTeXML/Package/natbib.sty.ltxml +++ b/lib/LaTeXML/Package/natbib.sty.ltxml @@ -528,7 +528,7 @@ DefPrimitiveI('\reset@natbib@cites', undef, sub { # Kinda rediculous simulating this here (we can almost pull it off in TeX) # but the TeX tends to be quite brittle in the wilds of arXiv, so... -DefMacro('\lx@NAT@parselabel Semiverbatim {}', sub { +DefMacro('\lx@NAT@parselabel {}{}', sub { my ($gullet, $label, $key) = @_; my ($number, $year, $authors, $fullauthors); my $bare = 1; @@ -560,7 +560,10 @@ DefMacro('\lx@NAT@parselabel Semiverbatim {}', sub { ($a1, @tokens) = NAT_peel_arg(@tokens); $authors = $a1; $year = Tokens(@tokens); $bare = 0; } } if ($bare) { - @tokens = Expand($label)->unlist; + # Goal: deactivate underscores + # (but not quite Semiverbatim, as math should be active things like \ddot{a}) + my @safe_tks = map { Equals($_, T_SUB) ? T_OTHER("_") : $_ } $label->unlist; + @tokens = Expand(Tokens(@safe_tks))->unlist; # \bibitem[Jones et al.(1990)]{key}... # \bibitem[Jones et al.(1990)Jones, Baker, and Williams]{key}... # \bibitem[Jones et al., 1990]{key}... diff --git a/t/structure/crazybibkeys.pdf b/t/structure/crazybibkeys.pdf new file mode 100644 index 000000000..7ed870706 Binary files /dev/null and b/t/structure/crazybibkeys.pdf differ diff --git a/t/structure/crazybibkeys.tex b/t/structure/crazybibkeys.tex new file mode 100644 index 000000000..d09a8b8eb --- /dev/null +++ b/t/structure/crazybibkeys.tex @@ -0,0 +1,14 @@ +\documentclass{article} +\usepackage{natbib} +\begin{document} +% These could cause problems if used with \cite, but are OK standalone in {thebibliography}. +\begin{thebibliography}{} + +\bibitem[_xy(1899)]{_xyz_1899} + A name of something. (accessed Nov 01, 1899). + +\bibitem[Ex$\ddot{a}$mple(1899)]{mathy} + Another name. + +\end{thebibliography} +\end{document} \ No newline at end of file diff --git a/t/structure/crazybibkeys.xml b/t/structure/crazybibkeys.xml new file mode 100644 index 000000000..f25bfe5c6 --- /dev/null +++ b/t/structure/crazybibkeys.xml @@ -0,0 +1,51 @@ + + + + + + + + + References + + + + 1 + 1899 + ˙xy + ˙xy (1899) + _xyz_1899 + + +A name of something. (accessed Nov 01, 1899). + + + + + 2 + 1899 + Ex + + + ¨ + a + + + mple + Ex + + + ¨ + a + + + mple (1899) + mathy + + +Another name. + + + + +