twilsonco / latexdiffcite

latexdiffcite is a wrapper around latexdiff to make citations diff properly
BSD 2-Clause "Simplified" License
25 stars 9 forks source link

Citations with accent and umlaut commands do not expand properly #5

Open ftilmann opened 7 years ago

ftilmann commented 7 years ago

When author names in an author-year citation style contain accent or umlaut commands (e.g. \",\') and or braces, they are not expanded properly, leading to errors in the resulting latex file. The following MWE illustrates the problem.

mwe_accentcite.tex:

\documentclass{article}
\usepackage{natbib}

\bibliographystyle{plainnat}
\begin{document}
Breaking citations:

\citep{fontaine2013imaging}

\citep{ligorria1999iterative}

\citep{reiss2016seismic}

\bibliography{biblio}
\end{document}

biblio.bib:

@Article{fontaine2013imaging,
  Title                    = {Imaging crustal structure variation across southeastern {Australia}},
  Author                   = {Fontaine, Fabrice R and Tkal{\v{c}}i{\'c}, Hrvoje and Kennett, Brian LN},
  Journal                  = {Tectonophysics},
  Year                     = {2013},
  Pages                    = {112--125},
  Volume                   = {582},

  Publisher                = {Elsevier}
}

@Article{ligorria1999iterative,
  Title                    = {Iterative deconvolution and receiver-function estimation},
  Author                   = {Ligorr{\'\i}a, Juan Pablo and Ammon, Charles J},
  Journal                  = {Bulletin of the seismological Society of America},
  Year                     = {1999},
  Number                   = {5},
  Pages                    = {1395--1400},
  Volume                   = {89},

  Publisher                = {Seismological Society of America}
}

@Article{reiss2016seismic,
  Title                    = {Seismic anisotropy of the lithosphere and asthenosphere beneath southern {Madagascar} from teleseimic shear-wave splitting analysis and waveform modeling},
  Author                   = {Reiss, M. and R\"umpker, G. and Tilmann, F. and Yuan, X. and Giese, J. and Rindraharisaona, E. J.},
  Journal                  = {accepted by J. Geophys. Res.},
  Year                     = {2016}
}

Run the following sequence (using latexdiffcite 1.0.6):

latex mwe_accentcite
bibtex mwe_accentcite
latexdiffcite file mwe_accentcite mwe_accentcite
latex diff.tex

The last latex command does not run through (of course, it is non-sensical to compare mwe_accentcite to itself, but it is enough to demonstrate the issue).

The reason is obvious from inspection of the expansion that latexdiffcite has done:

[\ldiffentity{\textit{Fontaine and Tkal\vc}, \ldiffentity{2013}}]
[\ldiffentity{\textit{Ligorr\'\ia and Ammon}, \ldiffentity{1999}}]
[\ldiffentity{\textit{Reiss and R\}, \ldiffentity{2016}}]

i.e braces should be preserved, and processing should not stop when encountering \".

cmeeren commented 7 years ago

Thanks for a great bug report, I'll try to have a look at it soon-ish.

cmeeren commented 7 years ago

I've had a look at this now, and unfortunately it's a limitation of the way I have parsed the bib files (using regex). Allowing arbitrary braces inside names is not at all practical the way the bib files are parsed, and would also break a few other tests (since then surnames like {Foo} and Foo would register as two separate names).

I simply can't and won't put in the time required to delve into this and fix this. I of course welcome any pull requests.