ulyngs / oxforddown

Template for writing an Oxford University thesis in R Markdown; uses the OxThesis LaTeX template and was inspired by thesisdown.
https://ulyngs.github.io/oxforddown/
MIT License
221 stars 81 forks source link

Individual .bib files for each chapter #35

Closed JoseBSL closed 2 years ago

JoseBSL commented 2 years ago

Hi Ulrich,

I'm trying to have a different bib file for each chapter section of the thesis. I have achieved it for 3 sections but surprisingly to me when I add a next one I get an error. I can overcome that by adding all refs in the same bib.file but that is no ideal...

I'm going to try to show here what I have done and if its makes sense, maybe you have some other alternative ideas.

First I read all the .bib files in the thesis project by adding this on the yaml of index.rmd

`#######################

bibliography path

####################### bibliography: "r list.files(pattern = '^.+\\.bib$')" bibliography-heading-in-pdf: REFERENCES biblio-style: apa biblatexoptions: [refsegment=chapter]`

Would be better to have all bib.files on a References folder but I haven't been able to achieve that but that is another story.

Then, I have added on both template.tex and brief_template.tex the individual bib files

\addbibresource{references.bib} \addbibresource{refsintro.bib} \addbibresource{refschap1.bib} \addbibresource{refschap2.bib}

But when I add an extra bib file (e.g., refschap3, refschap4, refsdiscu) I always get this error ! LaTeX Error: Missing \begin{document}.

(I have double checked that the names are correctly added on YAML of the respective chapters)

I have google it but I don't find a solution for it. Any suggestion of how to best handle this?

Note: I'm compiling everything with build all.

UPDATE:

I have used another computer (other mac) and I'm able to add the .bib files for the other chapters. Seems that may be related with tex versions that I have in the other computer.

By updating maktex, miktex and rstudio now is working. I had to do some slight changes on the YAML because it was being printed.

ulyngs commented 2 years ago

Interesting - as per your update, can you confirm that it's working for you?

Also, your YAML options look different to the current version of oxforddown. In the current version, you can simply supply a list of named .bib files in the YAML header, like in the sample content:

#######################
## bibliography path ##
#######################
bibliography: [bibliography/references.bib, bibliography/additional-references.bib]

The calls to \addbibresource{some-bib.bib} will be inserted automatically into the .tex file for each of the .bib files named in the YAML header?

JoseBSL commented 2 years ago

Yes, I do confirm that is working for me. I updated R and the latex packages and the error ! LaTeX Error: Missing \begin{document}. disappeared.

I guess that because I was using an older version of oxforddown and older packages I was struggling with it. This new way seems pretty straightforward. I haven't changed to this new easier version for a matter of time but if I do find the time I'll give a try!

This is what is working for me: bibliography: "r list.files(pattern = '^.+\\.bib$')"

The bib files are in the main project with all the documents.

And in each chapter I call them by their specific names in the yaml (e.g., bibliography: refschap1.bib ) and then a specific \addbibresource{refschap1.bib} in the templates folder on both brief_template.tex and template.tex

I compile everything with build all

Thanks as always!! You'll get a citation soon from a PhD thesis :)