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

Reorder references and appendices #27

Closed jangaijap closed 1 year ago

jangaijap commented 3 years ago

I am having a hard time reordering references and appendices sections. Since the citation format my discipline uses is APA, the bibliography/references section needs to appear between main chapters and the appendices, rather than after the appendices as in the original Oxford thesis template. The appendices seem to be linked to the "body" Rmd files and thus immediately follow the main chapters in appearance. So I tried to delink appendices from the "body" by changing the file name to "_appendices.Rmd." The pdf built after this tweak does place the appendices after bibliography but as subsections of bibliography (and takes on line spacing format of front/back matter) rather than as a separate section. Is there a way to make the appendices appear after bibliography but in the same format as the body chapters? Any help is appreciated.

ulyngs commented 3 years ago

So one easy, albeit slightly hacky, way to achieve this:

  1. Remove the bibliography section from the ordinary template.

Go to templates/template.tex and delete or comment out this section at the end of the file, which inserts the bibliography section:

%%%%% REFERENCES
$if(use-biblatex)$
\setlength{\baselineskip}{0pt} % JEM: Single-space References

% we are setting the title for the references section in front-and-back-matter/99-references_heading.Rmd
{\renewcommand*\MakeUppercase[1]{#1}%
\printbibliography[heading=none]}

$endif$

$if(use-natbib)$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$endif$
  1. Insert the bibliography section by the end of the last chapter

Go to the .Rmd file that has your last chapter (e.g. 07-conclusion.Rmd). If you are using biblatex for references (the default), add this at the end of the file:

```{=latex}
\setlength{\baselineskip}{0pt}
\renewcommand*\MakeUppercase[1]{#1}
\printbibliography[heading=bibintoc,title={References}]

Alternatively, if you are using natbib for references, add this:

````md
```{=latex}
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}


This will place the reference section after the last chapter:

<img width="702" alt="Screenshot 2021-07-13 at 15 32 49" src="https://user-images.githubusercontent.com/23137032/125470678-e453fa8a-bad7-4305-983f-308beb3ee10a.png">
tomislavmedak commented 2 years ago

Hey Ulrik, again me -- submitting in ten days, so it will be less of me soon, but apologies for the time being :-) Is there another way to do this? Per your instruction for biblatex, I get the following error:

! Undefined control sequence. l.1705 \printbibliography [heading=bibintoc,title={\bibtitle}]

I've tried to knit with a minimal biblatex file, a single reference that seemed properly structured, and I get the same result. Is there another way to go about it?

As I use pandoc and zotero, I'm not sure if natbib is an option at all.

Thanks

ulyngs commented 2 years ago

Can you clarify what citation package you are using? i.e. in index.Rmd do you have citation_package: natbib, citation_package: biblatex or nothing?

If you've got nothing, i.e. citations are inserted as CSL references, then this stack overflow answer should work: https://stackoverflow.com/questions/16427637/pandoc-insert-appendix-after-bibliography

tomislavmedak commented 2 years ago

I had neither selected, then did as instructed for biblatex and again I get the same error:

`! Undefined control sequence.

\bibtitle ` However, I have looked into that stackoverflow thread and this seems to work: `::: {#refs} :::` I can add this bit of code to the last chapter .Rmd and it will generate the bibliography in that chapter or I can add it as a separate .Rmd chapter file. The only problem is that it's numbered as a separate chapter -- is there a way to suppress a chapter from being numbered? Using that route, the front and back matter file for references heading should be deleted.
ulyngs commented 2 years ago

The bibtitle error you get is because I changed the way in which the reference section heading is inserted, after I provided the guidance above. (In the current version, the reference heading is generated by front-and-back-matter/99-references_heading.Rmd instead of via a bibtitle parameter in the LaTeX template.)

I just updated the instructions -- can you try if they work now?

tomislavmedak commented 2 years ago

When following instructions, adding the code-chunk at the end of the last chapter, allowing use-biblatex in index.Rmd and commenting out REFERENCES section in template.tex, it works as per usual. Appendices are generated before references.

ulyngs commented 1 year ago

The pandoc ref-placement div (https://pandoc.org/MANUAL.html) is now included in front-and-back-matter/99-references_heading.Rmd, so in order to reorder the appendices and references, just reorder those two files (by default, the files are put together in alphabetical order, so you can simply rename to 98-references_heading.Rmd and 99-appendices.Rmd)

tomislavmedak commented 1 year ago

This seems to work, the only issue I have is that the following piece of code

r params$referenceHeading {-}

creates a "References" heading at the beginning of the bibliography, yet the header throughout the bibliography pages remains from the previous chapter "8. Conclusions". If I change the variable for just # References it works as expected.

In template.txt I have the following code:

%%%%% REFERENCES $if(use-biblatex)$ \setlength{\baselineskip}{0pt} % JEM: Single-space References

% we are setting the title for the references section in front-and-back-matter/99-references_heading.Rmd {\renewcommand*\MakeUppercase[1]{#1}% \printbibliography[heading="References"]}

$endif$

$if(use-natbib)$ \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} $endif$

% set the section header to the references heading \markboth{$params.referenceHeading$}{}

On Sun, Sep 18, 2022 at 11:11 PM Ulrik Lyngs @.***> wrote:

The pandoc ref-placement div (https://pandoc.org/MANUAL.html) is now included in front-and-back-matter/99-references_heading.Rmd, so in order to reorder the appendices and references, just reorder those two files (by default, the files are put together in alphabetical order, so you can simply rename to 98-references_heading.Rmd and 99-appendices.Rmd)

— Reply to this email directly, view it on GitHub https://github.com/ulyngs/oxforddown/issues/27#issuecomment-1250387823, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHGME3A5UWTM2OBBDC3ITPTV66APHANCNFSM5AJF3MRA . You are receiving this because you commented.Message ID: @.***>

JohannesNE commented 1 year ago

The pandoc ref-placement div (https://pandoc.org/MANUAL.html) is now included in front-and-back-matter/99-references_heading.Rmd, so in order to reorder the appendices and references, just reorder those two files (by default, the files are put together in alphabetical order, so you can simply rename to 98-references_heading.Rmd and 99-appendices.Rmd)

This worked for me. Thanks