mkucej / i-librarian

Legacy I, Librarian - collaborative PDF manager. Not maintained, new version is at https://github.com/mkucej/i-librarian-free
https://i-librarian.net
98 stars 38 forks source link

Bibtex export #47

Open arwinj opened 8 years ago

arwinj commented 8 years ago

Hi. When exporting references in bibtex format, most of the fields contains an extra '{' and '}'.

@article{Nowak-2001-ID504,
author    = {{Nowak, U. and Misra, A. and Usadel, K. D.}},
title     = {{Domain state model for exchange bias}},
journal   = {{Journal of Applied Physics}},
year      = {{2001}},
volume    = {{89}},
pages     = {{7269--7271}},
doi       = {{10.1063/1.1358829}},
abstract  = {{Monte Carlo simulations of a system consisting of a ferromagnetic layer
            exchange 

Thanks.

Version : 4.0 and 4.1 OS : Linux 3.16.0-38-generic, Ubuntu 14.04.

mkucej commented 8 years ago

As far as I know it is a valid format? Extra curly braces should protect capitalization. Is your external software throwing errors?

arwinj commented 8 years ago

I haven't recall about capitalization. As I understand it :

I am not sure that protecting the whole title is recommended, as the automatic uncapitalization depends on the style used. For a general purpose bibliography, I would recommand to only force capitalization when needed. However, I don't know other bibliography driver (like Endnote, RIS, ...) and how the behave if you put brackets manually in the i-librarian entries. If it is not possible to specify which capital should stay capitalized, I understand putting an extra brackets around the title fields is the best option. This extends to other type of characters, like subscripts, accented, greeks, etc.

ssokolen commented 8 years ago

This issue is a bug as it breaks citation formatting using either bibtex or biber reference back-ends in latex (example below). "Protecting" the author field with double brackets treats all authors as a single long name. Using double brackets in other fields may also impact latex formatting.

My pdf upload is being rejected, but hopefully this screenshot shows up: pdf_screenshot

Latex code:

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@BOOK{broken,
  AUTHOR    = {{Anon, Joe and Anon, Jill}},
  TITLE     = {{Book Title}},
  PUBLISHER = {{Publisher}},
  YEAR      = {{2016}},
}
@BOOK{ok,
  AUTHOR    = {Anon, Joe and Anon, Jill},
  TITLE     = {Book Title},
  PUBLISHER = {Publisher},
  YEAR      = {2015},
}
\end{filecontents*}

\documentclass{article} 
\usepackage[%
  backend=bibtex,   % bibtex backend
% backend=biber,    % biber backed
  style=authoryear, 
  maxcitenames=1,
  uniquelist=false
]{biblatex} 
\addbibresource{\jobname.bib}
\begin{document} 
This reference uses double curly brackets and breaks author field: 

\parencite{broken}

\vspace{1cm}

This reference uses single curly brackets and is fine: 

\parencite{ok}

\printbibliography 
\end{document}
arwinj commented 8 years ago

I also noticed that some characters need to be escaped. For example, a '%' in an abstract field is interpreted as a comment by bibtex, and therefore generates an error. What is odd is that I haven't have any problem with that before with latex…

mkucej commented 8 years ago

I am going to remove the double bracketing. I will try to protect only multiple consecutive caps. Hopefully, these problems will go away.

ssokolen commented 8 years ago

That sounds like a good compromise. Thanks.

One suggestion may be to protect a whole word that features multiple caps -- such as H-NMR or KernSmooth.

mkucej commented 8 years ago

Do you guys have a list of special characters that need to be escaped?

ssokolen commented 8 years ago

I personally haven't encountered too many problems. That said, %, $, and & are good candidates as they are occasionally found in abstracts or titles (and can be taken at face value). Other major symbols include _, {, }, and #. I'd be cautious about where/when the escape process takes place. I wouldn't want curly brackets that I've placed into the abstract to be escaped by an automated process. But that might be just me.

Might be some more useful info here: https://www.rpi.edu/dept/arc/training/latex/LaTeX_symbols.pdf

mkucej commented 8 years ago

Wow, that's too much. I'll see what I can do. I think modern Latex tools deal well with UTF-8, which is what I, Librarian natively works with. If you guys are on Linux, you can export into RIS and then convert to Bibtex using the excellent Bibutils: https://sourceforge.net/p/bibutils/home/Bibutils/

(I might also be able to translate some of Bibutils classes to PHP.)

ssokolen commented 8 years ago

Personally, I don't think it's necessary to escape anything other than % and maybe $ or &. I just added the pdf for reference... I use biblatex with biber, which work natively with UTF.

mkucej commented 8 years ago

Will be fixed in 4.2.

mkucej commented 6 years ago

One of the titles in my database:

"Impedance-Source Networks for Electric Power Conversion Part I: A Topological Review"

is exported in bibtex as

title = {Impedance-Source Networks for Electric Power Conversion Part I: A Topological Review}

instead of

title = {Impedance-Source Networks for Electric Power Conversion Part {I}: A Topological Review}
mkucej commented 6 years ago

Protect single caps too.

gkaf89 commented 6 years ago

This should work! Protecting single caps solves other problems too. For instance inserting the title

A Filippov sliding vector field on an attracting co-dimension 2 discontinuity surface, and a limited loss-of-attractivity analysis

results in a BibTeX exported file containing

title = {A Filippov sliding vector field on an attracting co-dimension 2 discontinuity surface, and a limited loss-of-attractivity analysis}

where as I would expect

title = {{A} {F}ilippov sliding vector field on an attracting co-dimension 2 discontinuity surface, and a limited loss-of-attractivity analysis}

so that the surname (Filippov) starts with an uppercase in the document.

My expectation is that the title will be reproduced exactly as it was entered in the database with respect to capitalization.