plk / biber

Backend processor for BibLaTeX
Artistic License 2.0
338 stars 38 forks source link

extracting bibtex items and also crossrefs #322

Closed stefan11 closed 4 years ago

stefan11 commented 4 years ago
biber --output_format=bibtex <documentname>.bcf -O citedbibentries.bib

gets me the cited bibtex items, but it does not include the crossrefs. Could this be fixed? Here is some discussion and a MWE.

https://tex.stackexchange.com/questions/551993/printing-extracting-all-bibtex-items-that-are-cited-in-a-edited-volume

Thanks!

plk commented 4 years ago

I would class this as a bug as it should have worked - should be fixed in 2.15 DEV - the various output-resolve options should now work properly for bibtex output in non-tool mode. Regression tests are in place for this now.

stefan11 commented 4 years ago

Thanks! Tried to compile the binaries but got this:

perl Build.PL WARNING: the following files are missing in your kit: META.json META.yml Please inform the author.

Created MYMETA.yml and MYMETA.json Creating new 'Build' script for 'biblatex-biber' version '2.15'

Best Stefan

plk commented 4 years ago

Do you need to compile? Can you not just download a DEV binary? Those messages are normal - "perl Build.PL" just creates the build script you'd then have to do "Build install" to install the (non binary) biber.

stefan11 commented 4 years ago

Ah, sorry! Did not notice that there are binaries. I managed to compile now. I thought the message above was an error, but everything worked quite nicely.

And my problem is solved. Everything is included in the lexical items now. I got 215 pages of references :-). \o/

stefan11 commented 4 years ago

There is one thing that does not seem to work. I used the ids-field to keep wrong ids of bibtex items where I fixed the citation key. biber/biblatex finds those for generating bbl files, but biber does not extract the respective items when creating bibtex files.

plk commented 4 years ago

Can you post a MWE of this issue here?

stefan11 commented 4 years ago

I found the reason. I think it is easy to fix. The ids are not exported:

   \documentclass{scrbook}

    \begin{filecontents}{ref.bib}
    @book{degroote2000a,
            Address = {Louvain-la-neuve, Belgium},
            Editor = {de Groote, Philippe},
            Publisher = {Academia},
            Series = {Cahiers du Centre de Logique},
            number = 8,
            ids = {test-id},
            Title = {Test item The {Curry-Howard} Isomorphism},
            Year = 2000}

    @book{degroote95a,
            Address = {Louvain-la-neuve, Belgium},
            Annote = {13.7.03},
            Editor = {de Groote, Philippe},
            Key = {curry-howard isomorphism, logic, type theory},
            Publisher = {Academia},
            Series = {Cahiers du Centre de Logique},
            number = 8,
            Title = {The {Curry-Howard} Isomorphism},
            Year = 1995}
    \end{filecontents}

    \usepackage[
    %   natbib=true,
    %   style=\bibstylepath langsci-unified,
    %   citestyle=\bibstylepath langsci-unified,
            style=authoryear,
            backend=biber,
    ]{biblatex}
    \addbibresource{ref.bib}

\begin{document}

\cite{test-id,degroote95a}

\printbibliography
    \end{document}

By the way: Is there a way to keep year, address and journal rather than date, location and journaltile? Thanks!

stefan11 commented 4 years ago

I found the reason. I think it is easy to fix. The ids are not exported:

   \documentclass{scrbook}

    \begin{filecontents}{ref.bib}
    @book{degroote2000a,
            Address = {Louvain-la-neuve, Belgium},
            Editor = {de Groote, Philippe},
            Publisher = {Academia},
            Series = {Cahiers du Centre de Logique},
            number = 8,
            ids = {test-id},
            Title = {Test item The {Curry-Howard} Isomorphism},
            Year = 2000}

    @book{degroote95a,
            Address = {Louvain-la-neuve, Belgium},
            Annote = {13.7.03},
            Editor = {de Groote, Philippe},
            Key = {curry-howard isomorphism, logic, type theory},
            Publisher = {Academia},
            Series = {Cahiers du Centre de Logique},
            number = 8,
            Title = {The {Curry-Howard} Isomorphism},
            Year = 1995}
    \end{filecontents}

    \usepackage[
    %   natbib=true,
    %   style=\bibstylepath langsci-unified,
    %   citestyle=\bibstylepath langsci-unified,
            style=authoryear,
            backend=biber,
    ]{biblatex}
    \addbibresource{ref.bib}

\begin{document}

\cite{test-id,degroote95a}

\printbibliography
    \end{document}

By the way: Is there a way to keep year, address and journal rather than date, location and journaltile? Thanks!

plk commented 4 years ago

IDS issue fixed in DEV 2.15. You could revert those fields but you'd have to do:

\DeclareDriverSourcemap[datatype=bibtex]{}

in the preamble to disable the bibtex legacy field mapping you'll see in biblatex.def and then use a custom .dbx datamodel to reinstate those legacy fields in the default data model so that they are output.

stefan11 commented 4 years ago

Uff, thanks! Could you please be a bit more detailed about how to do this? I have no idea what to do. Thanks! The latex code would go to my minimal example, right? I also mention the datamodel as an option to biblatex, right? But I do not know what should be in the datamodel. Thanks!

plk commented 4 years ago

Instead, I've added a new option in 2.15 DEV which allow last-minute remapping of field names to allow bibtex format output of legacy fields so simply call with the option e.g:

--output-field-replace=location:address,journaltitle:journal,date:year
stefan11 commented 4 years ago

You rock! Thank you very, very much!!!!

stefan11 commented 4 years ago

There is actually one issue left, but maybe this should be another bug report. If I have year = 2019 and month=Jun, biber creates me a year={2019-06} and complains about this.

plk commented 4 years ago

I was thinking about this too, I have added a dedicated option in 2.15 DEV for this as dates are complicated. So, now you can get what you want with the options:

--output-field-replace=location:address,journaltitle:journal --output-legacy-dates

There are natural limitations on this (see biber --help output) in cases where a date can't be converted into legacy format without loss of information but these won't be an issue for data which assumes only YEAR/MONTH on input.

stefan11 commented 4 years ago

Thanks! This works! \o/ But I get a lot of warnings. I guess they are related to crossreferencing other items. The warning reads:

WARN - Date in entry 'Sag2012a' has DAY or ENDYEAR, cannot be output in legacy format.

@incollection{Sag2012a, author = {Sag, Ivan A.}, crossref = {BS2012a-ed}, ids = {Sag:12}, langid = {english}, pages = {69--202}, title = {{Sign-Based Construction Grammar}: {An} Informal Synopsis}, } @book{BS2012a-ed, editor = {Boas, Hans C. and Sag, Ivan A.}, publisher = {CSLI Publications}, booktitle = {{Sign-Based Construction Grammar}}, langid = {english}, number = {193}, series = {CSLI Lecture Notes}, title = {{Sign-based Construction Grammar}}, year = {2012}, }

plk commented 4 years ago

Please get biber DEV version again - this was a small logic issue and should be fixed now - the warning was being issues when not necessary.

stefan11 commented 4 years ago

Thanks! It works now.

stefan11 commented 4 years ago

Ah, and could one keep urldate rather than urlyear, urlmonth and urlday? This seems to be slit in extraction/conversion. Thanks.

plk commented 4 years ago

That was a bug - should be fixed in DEV - the option will only apply to YEAR/MONTH now and not to any other date fields as they are not legacy fields, meaning that URLDATE etc. will not be split in bibtex format output, nomatter what the setting of the option.