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

Unable to add the style of specific portfolios/templates for chapters #5

Closed JoseBSL closed 4 years ago

JoseBSL commented 4 years ago

I'm doing a thesis by publications and each chapter is a journal article with different authors and affiliations. I'm trying to add specific portfolios/templates of journal articles for different chapters but this does not work when I build all and just when I knit the independent Rmd files.

Examples of the templates that I'm using: https://github.com/Pakillo/template

Any idea how can I include the journal style for these different chapters?

Thanks!

ulyngs commented 4 years ago

It is not possible to assign different templates to different chapters.

In the case of a portfolio thesis where some chapters are previously published, you can instead include the individual pages from those papers as PDF in your thesis.

Benjamin Van Doren did this for his thesis - I think this can be done with knitr::include_graphics?

bmvandoren commented 4 years ago

Yes, I originally used knitr::include_graphics to insert PDFs of published papers into my thesis. However, knitr::include_graphics does not appear to support multi-page PDFs, so I first had to split my PDF into multiple files such that each file had only one page. (I also cropped out the margins of the PDF file in Adobe Acrobat.) In addition, include_graphics doesn't allow any adjustment of the size/width of the PDF. So I ended up using the following code to insert them. It obviously only works for latex output.

```{r, results='asis',echo=F,message=F}
# put the chapter title on its own page and have the 
# embedded PDFs start on the next full blank page.
cat('\\newpage')
pages <- list.files(file.path(PATH_TO_DIRECTORY_WITH_PDF_FILES),
                    pattern="FILENAME_PATTERN",full.names = T)

cat(paste0("\\begin{center} \\makebox[\\linewidth][c]{\\includegraphics[width=1.15\\linewidth]{", pages, "}} \\end{center} \\newpage \n"))
# instead of the above line, knitr::include_graphics(pages) 
# should also work


By changing the value multiplying linewidth (currently 1.15), you can adjust the width of the embedded PDF.
JoseBSL commented 4 years ago

This seems that will do the work. Thanks!

ulyngs commented 4 years ago

We've added a new 'customisations and extensions' chapter in the sample materials which addresses this.