cboettig / knitcitations

:package: Generate citations for knitr markdown and html files
http://carlboettiger.info
Other
220 stars 28 forks source link

\mathplus in a citation breaks entire parsing (Knit PDF) #69

Closed lmmx closed 10 years ago

lmmx commented 10 years ago

I think it's just an unlucky DOI: 10.1186/1471-2164-9-88

When I use it as citet("10.1186/1471-2164-9-88") it comes out like

Sinha, Amit U, Vivek Kaimal, Jing Chen, and Anil G Jegga. 2008. “Dissecting Microregulation of a Master Regulatory Network.” BMC Genomics 9 (1). Springer Science \mathplus Business Media: 88. doi:10.1186/1471-2164-9-88. http://dx.doi.org/10.1186/1471-2164-9-88.

In the HTML, the \mathplus in big red letters. Pandoc throws an error and no PDF gets knitted when I use Knit PDF rather than HTML though:

Writing 7 Bibtex entries ... OK Results written to file 'readingnotes.bib' output file: Reading_notes.knit.md ! Undefined control sequence. \mathplus l.277 Genomics} 9 (1). Springer Science $\mathplus pandoc: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 Execution halted
lmmx commented 10 years ago

I just installed texlive-full on my machine and it's still failing. It does seem to be a bad control sequence, but it's in this Stack Overflow question being successfully parsed by the looks of things.

...I just asked on the TeX StackExchange and got the solution of \newcommand\mathplus{+}, but still think it's something worth addressing? The first commenter said they'd never seen that, not sure if you could handle errors from this somehow, like with some sort of dictionary of these, I don't know. Wasn't expecting to have to do so upon receiving bibliographic info. Feel free to close if you don't think the package should deal with this.

cboettig commented 10 years ago

Thanks for the report. CrossRef is just providing the bibtex provided by the journal, so ultimately you'd want to tell the journal that they are generating non-standard metadata here. To my mind it makes more sense that such corrections to metadata be handled either at the source or in the final rendering (e.g. your tex template, as you suggest). Since knitcitations will never be able to catch all such cases, I think it's better that it at least have consistent and predictable behavior rather than fixing only the random subset of errors reported here. (Also, in this way knitcitations can be consistent with the behaviour of any other such intermediate tool reading the crossref data).