ropensci / bibtex

bibtex parser for R
https://docs.ropensci.org/bibtex/
36 stars 12 forks source link

curley brackets and formatting in titles of bibentries #2

Open boronian opened 10 years ago

boronian commented 10 years ago

Dear Romain,

I came across your nice package to handle bibtex entries in R, which I played around with over the past few days. I came across some things I want to share with you: 1) Sometimes curly brackets seem to confuse the parser:

To display what I mean I give some examples:

S. Lavou\'{e} or S. Lavou\'e

in the bibfile wouldn't make a difference for LaTeX, but reading a bibentry

@ARTICLE{Lavo, author = {S. Lavou\'{e}}, title = {A new species of \textit{Petrocephalus} \textsc{Marcusen} 1854 ({O}steoglossomorpha: {M}ormyridae) from the {S}anaga {R}iver basin, {C}ameroon}, journal = {Zootaxa}, year = {2011}, volume = {2934}, pages = {20-28}, }

will give after calling

bib$author [1] "S. Lavou\' e"

,

bib$author$family [1] "e"

and

bib$author$given [1] "S. Lavou\'"

This all is not a problem for the character é, as one can also write \'e, and LaTeX will know what to do. But for other characters this indeed is a problem. E.g. in the following bibtex entry

@ARTICLE{Bart, author = {L\'{a}szl\'{o} Bartha and Attila {Moln\'ar V.} and Nicolae Drago\c{s} and G\'{a}bor Sramk\'o}, title = {Molecular evidence for reticulate speciation in \textit{Astragalus} (Fabaceae) as revealed by a case study from section \textit{Dissitiflori}}, journal = {Botany}, year = {2013}, volume = {91}, pages = {702-714}, }

One couldn't substitute the \c{s}, by \cs, because LaTeX can't handle this, but bibtex.R gives the following results for the bibentry above:

bib$author[3] [1] "Nicolae Drago\c s"

,

bib$author[3]$given [1] "Nicolae Drago\c"

and

bib$author[3]$family [1] "s"

The same applies to J. Fjelds\r{a} In a bibentry.

2) Further, especially in Biology it is often necessary to include \textit{}. From the example above (@ARTICLE{Bart,), I get the following:

bib$title [1] "Molecular evidence for reticulate speciation in \textit{Astragalus}\n\t(Fabaceae) as revealed by a case study from section \textit{Dissitiflori}"

(note the \n\t in the title)

Do you see a chance, that these limitations (or do they have a reason?) will disappear in a future release of the bibtex package?

Best whishes

Ingo

boronian commented 9 years ago

I guess the following is somehow related (missing implementation of escape characters):

reading the entry

@Article{Blas, Title = {\textit{Glomus tetrastratosum}, a new species of arbuscular mycorrhizal fungi (Glomeromycota)}, Author = {Janusz B{l}aszkowski and Gerard Chwat and Anna G\'oralska and Aleksandra Bobrowska-Chwat}, Journal = {Mycoscience}, Year = {2014}, Eyear = {2014}, Comment = {p}, Doi = {10.1016/j.myc.2014.08.003} }

gives the error

Warning message: In read.bib(file = "~/test.bib") : ~/test.bib:187:12 syntax error, unexpected TOKEN_ABBREV, expecting TOKEN_COMMA or TOKEN_RBRACE Dropping the entry Blas (starting at line 185)

which seems to be because of the {l} which produces the character ł

It would be really great if you could provide proper handling of escape characters!

romainfrancois commented 7 years ago

@boronian can you prepare a reproducible example using the reprex package please ?

mohamedmiranfazil29 commented 1 year ago

Excellent work good work very good work MashAllah