Giter Club home page Giter Club logo

oxforddown's Introduction

I encourage someone to fork this repository and make it work with Quarto! :)

How to cite

If you use this template to write your thesis, please cite it! 🥰 (and/or click 'Sponsor' and buy me a coffee... 😉 )

DOI

@misc{lyngsOxforddown2019,
  author = {Lyngs, Ulrik},
  title = {oxforddown: An Oxford University Thesis Template for R Markdown},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/ulyngs/oxforddown}},
  doi = {10.5281/zenodo.3484681},
}

Contents

Oxforddown

A template for writing an Oxford University thesis in R Markdown. The template uses the bookdown R package together with the OxThesis LaTeX template, plus lots of inspiration from thesisdown.

Examples of theses written with oxforddown (see also Google Scholar):

NOTE: If you've used this template to write your thesis, drop me a line at [email protected] and I'll add a link showcasing it!

Requirements

  • R and RStudio version 1.2 or higher

  • The R packages rmarkdown, bookdown, tidyverse, kableExtra, and here

  • a LaTeX installation

    • Option 1: Use TinyTeX (a minimal LaTeX installation intended for use with R Markdown)

      remotes::install_github('yihui/tinytex')
      tinytex::install_tinytex()
      • Then install the LaTeX packages used by oxforddown (diskspace taken up by TinyTex with the required packages installed is about 280 Mb)
      missing_packages <- c(
        "appendix", "babel-english", "babel-greek", "babel-latin", 
        "biber", "biblatex", "caption", "cbfonts-fd", "colortbl", "csquotes", 
        "enumitem", "environ", "eso-pic", "fancyhdr", "greek-fontenc", 
        "grfext", "hyphen-greek", "hyphen-latin", "lineno", "logreq", 
        "makecell", "microtype", "minitoc", "multirow", "notoccite", 
        "oberdiek", "pdflscape", "pdfpages", "quotchap", "soul", "tabu", 
        "threeparttable", "threeparttablex", "titlesec", "tocbibind", 
        "trimspaces", "ulem", "units", "utopia", "varwidth", "wrapfig",
        "fvextra", "xurl"
        )
      tinytex::tlmgr_install(missing_packages)
    • Option 2: Use an ordinary LaTeX distribution

  • If on Mac

    • Command line developer tools. If you haven't got these installed already, your mac will probably automatically prompt you to install them. Otherwise, you can install them by opening a terminal and typing xcode-select --install

How to use

  • download the ulyngs/oxforddown repo as a zip
  • open oxforddown.Rproj in RStudio

How-to chapters

Read the 'How to use' chapter to understand the structure of oxforddown and how to do the basic things like building your thesis.

Note: bibliography files cannot have underscores in their names!

For how to use R Markdown syntax in general and in oxforddown in particular, read the dedicated chapters on this (R Markdown basics, Citations, cross-references, and collaboration, and Tables).

See also the general, official R Markdown resources R Markdown: The Definitive Guide and the R Markdown Cookbook.

Video tutorials

I am in the process of updating the tutorial videos to v3 - I've noted below which have yet to be updated, but are still informative, and struck out those that no longer apply:

Writing your thesis

  • update the YAML header (the stuff at the top between '---') in index.Rmd with your name, college, etc.
  • write the individual chapters as .Rmd files in the root folder
  • write the front matter (abstract, acknowledgements, abbreviations) and back matter (appendices) by adjusting the .Rmd files in the front-and-back-matter/ folder

.Rmd files you don't want included in the body text must be given file names that begin with an underscore (e.g. front-and-back-matter/_abstract.Rmd and front-and-back-matter/_acknowledgements.Rmd). (Alternatively, specify manually in _bookdown.yml which files should be merged into the body text.)

Building your entire thesis

  • Build the entire thesis by opening index.Rmd and clicking the 'knit' button.
  • The generated thesis files are saved in the docs/ folder
  • To choose output formats, go to the top of index.Rmd's YAML header and edit the line thesis_formats <- "pdf"; to the format(s) you want (options are "pdf", "bs4", "gitbook", and "word")
  • You can build to multiple formats simultaneously with, e.g., thesis_formats <- c("pdf", "bs4", "word")
  • If you want to customise the build function, edit scripts_and_filters/knit-functions.R

PDF output

knit: (function(input, ...) {
    thesis_formats <- "pdf";
    ...

When you build the entire thesis to PDF, Latex generates a whole bunch of auxillary files - these are automatically removed after the build process end by the custom knit function that is used when you knit index.Rmd.

To change how this removal is done, edit scripts_and_filters/knit-functions.R. The line file.remove(list.files(pattern = "*\\.(log|mtc\\d*|maf|aux|bcf|lof|lot|out|toc)$")) within if ("pdf" %in% output_format){ is the one that removes files after PDF output is generated.

BS4 book output (HTML)

knit: (function(input, ...) {
    thesis_formats <- "bs4";
    ...
  • NOTE: the bs4 book output requires the downlit and bslib R packages (install them with install.packages)
  • Note also that to deploy a BS4 book on GitHub Pages, there must be a .nojekyll file in the docs/ folder, otherwise GitHub does some voodoo that causes some filepaths not to work. This file is generated automatically by oxforddown's knitting function.

Gitbook output (HTML)

knit: (function(input, ...) {
    thesis_formats <- "gitbook";
    ...
  • Note that to deploy a gitbook on GitHub Pages, there must be a .nojekyll file in the docs/ folder, otherwise GitHub does some voodoo that causes some filepaths not to work. This file is generated automatically by oxforddown's knitting function.

Word output

knit: (function(input, ...) {
    thesis_formats <- "word";
    ...
  • Note that the Word output has no templates behind it, and many things do not work (e.g. image rotation, highlighting corrections). I encourage pull requests that optimise the Word output, e.g. by using tools from the officer package.

Building a single chapter

To knit an individual chapter without compiling the entire thesis:

  1. open the .Rmd file of a chapter
  2. add a YAML header specifying the output format(s) (e.g. bookdown::word_document2 for a word document you might want to upload to Google Docs for feedback from collaborators)
  3. click the knit button (the output file is then saved in the root folder)

As shown in the sample chapters' YAML headers, to output a single chapter to PDF, use e.g.:

output:
  bookdown::pdf_document2:
    template: templates/brief_template.tex
    citation_package: biblatex
documentclass: book
bibliography: references.bib

The file templates/brief_template.tex formats the chapter in the OxThesis style but without including the front matter (table of contents, abstract, etc).

NOTE: The bibliography path in your individual chapters' YAML headers needs to be identical to the one in index.Rmd - otherwise your individual chapters' bibliography path may override the path in index.Rmd and cause trouble when you knit the entire thesis.

Customisations and extensions

  • for common things you might want to do in your thesis, read through the sample content
  • the 'Customisations and extensions' chapter (thanks @bmvandoren!) has tips on how to include PDF pages from a published typeset article in your thesis, and much more!

Limitations

Gotchas

  • don't use underscores (_) in your YAML front matter or code chunk labels! (underscores have special meaning in LaTeX, so therefore you are likely to get an error, cf. https://yihui.org/en/2018/03/space-pain/)

    • bad YAML: bibliography: bib_final.bib
    • good YAML: bibliography: bib-final.bib
    • bad chunk label: {r my_plot}
    • good chunk label: {r my-plot}

Output formats

  • at the moment only PDF and HTML output have been properly implemented; I may improve on the Word output further down the line

Enjoy!

oxforddown's People

Contributors

bmvandoren avatar johannesne avatar shirdekel avatar ulyngs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

oxforddown's Issues

Commenting out the "university-logo" in the yaml leads to an error

I do not want to include a logo and therefore I comment out the corresponding line in the yaml as follows:

#university-logo: templates/beltcrest.pdf

and it leads to the following error:

output file: _main.knit.md

! Undefined control sequence.
\HyOrg@maketitle ...e *{\gapbeforecrest } {\crest 
                                                  \par } \vspace *{\gapafter...
l.267 

Error: LaTeX failed to compile _main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See _main.log for more info.
Execution halted

How can I solve this? :)

URLs in references section not wrapping

Hi again, when exporting my thesis to PDF, URLs in the references section stretching across three lines do not wrap, here is an example:

pdf

I assume that's a latex quirk?

Thanks

Enable cache options for main document

Hi,
Is there a way a to enable the cache options for the knitting process from the index.Rmd for all chapters ?
The cache options work for individual chapters chunks :


```{r complex_ggplot, cache = TRUE}

ggplot()+....

```_

However, every time I knit the main document (i.e., index.Rmd) it starts the process ignoring any cache.

Command \textomega unavailable in encoding T1

Hello,
Rmarkdown is not printing $\omega$, $\Delta$ or $\Psi$. The error message is-

! LaTeX Error: Command \textomega unavailable in encoding T1.

Is there a solution for that?

Thanking you,
Mohammad Tanbir Habib

One side document class within a doubleside one

I have prepared the thesis with alternate headers with fancyhdr and I'm very happy with the output. However, the sections before the chapters I would like them with a single side page.

I have set twoside \documentclass[a4paper, twoside,$if(page-layout)$$page-layout$$endif$]{templates/ociamthesis} but I want to have single side pages on the declaration, acknowledgements, etc...

I ilustrate it here the issue. I'm trying to avoid this white page.

Screen Shot 2021-11-08 at 10 36 57 am

I've seen that switching between \setboolean{@twoside}{false} and \setboolean{@twoside}{true}, using \cleardoublepage or \newgeometry could be possible solutions but I haven't been able to change it.
Any advice with this?

Cleaning scripts inadvertently delete a chapter

I have a chapter which was in a file named 03-methodology.Rmd, and every time I built the full pdf it would be deleted. Fortunately I had backups and could find and restore the file, but needless to say it's not ideal.

After some investigation I've realised that the cleaning scripts were inadvertently deleting it because it has 'log' in the filename (ie methodology), even though this isn't the file extension. I assume that it's some/all of the following lines from the Makefile:

clean:
	Rscript -e 'file.remove(list.files(pattern = "*.(log|mtc|maf|aux|bbl|blg|xml)"))'
	
clean-knits:
	Rscript -e 'file.remove(list.files(pattern = "*.(docx|html|pdf|log|maf|mtc|tex|toc|out|lof|lot|bcf|aux)"))'
	Rscript -e 'unlink(list.files(pattern = "*_(files|cache)"), recursive = TRUE)'

I've easily been able to get around this by renaming the file 03-methods.Rmd, but thought it worth noting should it be a problem for anyone else.

Insert a PDF as an alternative title page

Hi,

Is there a way to insert a PDF as an alternative title page? My university requires a specific PDF file from their platform to be the title page. Converting this file to .tex is not a feasible option.

Thanks a lot for this fantastic package!

Best,

Bruno

Question on understanding-this isn't an issue, so please delete if you prefer!

Hi!
Thank you for your excellent guide to oxford down. The YouTube videos and help pages are incredibly helpful.
Please forgive the v basic question. I have recently started using R bookdown, to try write papers (and ultimately my thesis, at Oxford). I've read the cookbook and book down guide, as well as your files and the others you link to. I use rmardown, and understand that, but I don't understand how bookdown 'knows' what to put together.

As instructed by the helpsheets, I have several chapters:

  • an index
  • 01-introduction (mainly free text)
  • 02 methods (mainly tables)
  • 03 results (outputs, graphs, tables)
  • 04 conclusion (free text).

Normally in rmarkdown, every new file I open, I have a 'r set up' chunk where I set the initial global decisions for the doc (echo=TRUE for example). I also install and load all packages I need for that specific document.
Do I still need to do this in bookdown? Or do I do it only once in the index chapter? I just don't quite understand what to put in index and what not to put in the other chapters.

Graphs/Tables: If I create a graph in chapter 3 can I put it in chapter 2? Or does it render in order of chapters, and is the better way to have a separate file for all the code for my graphs? I need to find a good way to integrate the writing with the stats, would you do each of these in separate files?

Thanks so much

Japanese

I would like to use it for my thesis in Japanese, but to output it in Japanese on your template, it was garbled.

I have just started using Rstudio and found your excellent template in RMarkdown and would be happy to modify it to my graduate school of Health and Sports Sciences format for use.

Some characters appear incorrectly when using xelatex or lualatex

Disclaimer that this issue might not be entirely one of oxforddown but it goes away when I don't specify template: templates/brief_template.tex, so I assume it's caused by something within that template.

When I use the characters ¹ / ² / ³ with the xelatex or lualatex engines, they get rendered as ź / š / ş in the pdf output.

How to reproduce:

I knit a .Rmd with the following YAML:

---
title: "superscript reprex"
output:
  bookdown::pdf_document2:
    template: templates/brief_template.tex
    latex_engine: pdflatex (or lualatex/xelatex)
---

and the following content:

unicode superscript:

1: ¹

2: ²

3: ³

Results

output when latex_engine: pdflatex:
image

output when latex_engine: lualatex:
image

output when latex_engine: xelatex:
image

While this reprex uses the brief_template.tex template, it also occurs when I knit a whole thesis using the main template. It also occurs when I swap out the font for another one, so I don't think that's the issue (and in any case pdflatex does show the correct characters, so they're definitely there).

As a side note, I do know how to use normal superscript in markdown and have been usually using that, but haven't found a way to do so with kableExtra::add_header_above(), hence the use of the ² character as a workaround – if anyone reading this does know how to do this do let me know! Or if there is any other workaround that will allow me to use ² with lualatex or xelatex (pdflatex gives me other unrelated errors), that would be greatly appreciated!

Formatting tables

I have not been able to format tables as I do in markdown. Is there another way to format tables and control their sizes?

Here is an example of a table that I'm formatting using kableExtra, I'm not very familiar with bookdown so I may be missing something relevant, I do apologize if that's the case.

#load libraries
library(knitr)
library(kableExtra)

Species <- c("Brassica oleracea", "Brassica rapa", "Eruca sativa", "Sinapis alba", "Ipomoea aquatica", "Ipomoea purpurea", "Capsicum annuum", "Petunia integrifolia", "Solanum lycopersicum", "Solanum melongena")
Species <- as.character(Species)
  
Common_names <- c("Wild cabbage", "Pak choi", "Rocket", "White mustard", "Water spinach", "Morning glory", "Capsicum", "Petunia", "Tomato", "Eggplant")
Common_names <- as.character(Common_names)
Variety <- c("Capitata", "Chinensis", "", "", "", "", "California Wonder", "", "Tommy Toe", "Little Fingers") 
Variety <- as.character(Variety)
Source <- c("https://www.mrfothergills.com.au/", "https://www.mrfothergills.com.au/", "https://www.mrfothergills.com.au/", "https://www.mrfothergills.com.au/", "https://www.theseedcollection.com.au/", "http://www.shaman-australis.com.au", "https://www.edenseeds.com.au", "https://www.dianeseeds.com/", "https://www.mrfothergills.com.au/", "https://www.4seasonsseeds.com.au/")
Source <- as.character(Source)
t <- data.frame(Species, Common_names, Variety, Source)
colnames(t) <- c("Species", "Common names", "Varieties", "Source")
kable(t, format = "latex", longtable = T, booktabs = T,linesep = "\\addlinespace",
             caption = "\\textbf{Table S1.} Species names, common names, varieties and sources of the different seeds.") %>%
  kable_styling(latex_options = c("repeat_header","striped"), font_size = 10, full_width=T) %>% row_spec(0,bold=TRUE)  %>%
  column_spec(1,italic =T)

This table in markdown runs well with this YAML

output:
pdf_document:
keep_tex: yes
fig_caption: yes
toc: no
html_document:
toc: no
df_print: paged
fontsize: 12pt
header-includes:

  • \usepackage{setspace}\doublespacing
  • \usepackage{float}
  • \usepackage{caption}

However, in bookdown I'm unable to run it with the kable_styling specifications. Sorry if this is not an issue!

Modify chapter numbering format

I am using an adapted version of this project for my master thesis.

I tried to fiddle with the latex templates but I didn't manage to change the huge grey numbers that appear as defaults at the beginning of each chapter. Moreover, I wasn't able to identify the package responsible for their rendering.

I tried the titlesec approach, as suggested by many on StackOverflow, but it doesn't seem to work. Can you provide me with a minimal example that makes the format of chapter names editable?

Thank you in advance for your time!

Changing the title size of the thesis

Is there a way to decrease the title size? My current title size is so big that there are 2 title pages whereas I want to have only 1 title page where everything is included.

Fix overflowing lines in code blocks

I fixed this in actual code blocks that are being processed by knitr (with scripts_and_filter/wrap_lines.R), but blocks of code that are simply being marked up with syntax highlighting can still overflow (see end of the customisations and extensions sample PDF content)

! LaTeX Error: This NFSS system isn't set up properly.

! LaTeX Error: This NFSS system isn't set up properly.

Error: Failed to compile _main.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See _main.log for more info.
In addition: Warning messages:
1: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains authoryear.dbx
2: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains biblatex-dm.cfg
3: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains latin.lbx
Execution halted
make: *** [pdf] Error 1

R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] tinytex_0.13

loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0 xfun_0.7 packrat_0.5.0

Changing chapter title position

From haohua:

Can I change the chapter title position from the "Top Right" corner with a big number, to the "Top Left" corner?

`hidelink: false` does not unhide links

Currently, index.Rmd has

hidelinks: true # false to highlight clickable links with a colored border

However, changing this to false does not add the border. I think that this is because hyperref's hidelinks option is not a boolean, but it is its presence that turns on the link hiding (see page 10 of the manual). Manually removing this option from template.tex re-enables the default borders.

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

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!

Citation styles (.csl files)

Hi,

First of all, thanks a lot for this project.

Is there a way to use .csl files to change the citation styles, like here?

I'm having some problems with the format given by biblatex and natbib (even when changing the .bst file).

Thanks in advance!

Multiple abstracts with different languages

Hello,

Is there any options to add second abstract in different language?

I tried to update the template.tex as below, but it still render the title as "Abstract", not "Résumé"

%%%%% ABSTRACT -- Nothing to do here except comment out if you don't want it.
\begin{otherlanguage}{french} 
\begin{abstract}
	$abstract2$
\end{abstract}
\end{otherlanguage}

Thanks

Failed to knit the master version

Hi!

While trying to knit the master version, I am getting the following error message:

output file: _main.knit.md

! Paragraph ended before \MT@prot@l was complete.
<to be read again> 
                   \par 
l.318 

Error: LaTeX failed to compile _main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See _main.log for more info.
In addition: Warning messages:
1: In get_engine(options$engine) :
  Unknown language engine 'yaml' (must be registered via knit_engines$set()).
2: In get_engine(options$engine) :
  Unknown language engine 'yaml' (must be registered via knit_engines$set()).
3: In get_engine(options$engine) :
  Unknown language engine 'yaml' (must be registered via knit_engines$set()).
Execution halted

Here is my session info:

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.1.2  bookdown_0.24   fastmap_1.1.0   htmltools_0.5.2 tools_4.1.2     yaml_2.2.1      rmarkdown_2.11 
 [8] knitr_1.36      xfun_0.28       digest_0.6.28   rlang_0.4.12    evaluate_0.14

Thank you very much for your help!

Make page number, not text, be link in TOC

Next to the linkcolor-rgb value in index.Rmd there is a comment that says that "In the coloring normal links looks a bit excessive, as it highlights also all links in the table of contents"

Adding linktocpage to hypersetup makes the links appear only for the page numbers, not the text, in the TOC. This makes the amount of link highlighting a little less excessive.

For instance:

\hypersetup{
  hidelinks,
  colorlinks,
  linktocpage,
  linkcolor=$if(linkcolor-rgb)$mylinkcolor$else$.$endif$,
  urlcolor=$if(urlcolor-rgb)$myurlcolor$else$.$endif$,
  citecolor=$if(citecolor-rgb)$mycitecolor$else$.$endif$
}

Obviously this could be made optional and be controlled from index.Rmd. Happy to submit a PR.

Original date of publication

First, thank you for generating this thesisdown template. As I'm new to latex and rstudio from the markdown territory, I'm struggling a bit to get some things to work. My biggest bugbear is the original date of publication. It seems that the current chicago author-year style for biblatex does not support the original date of publication, e.g. (Marx and Engels [1848] 2010, 488). I'm not able to figure out how to disable biblatex and use pandoc-citeproc, as the latter pandoc-citeproc what I expect in docx and gitbook formats. As you recommend in the Customisations chapter of your guide, I comment out all bib and natbib lines in template.tex and get an error. Neither am I able to get biblatex-chicago, which supports origdate, to work in oxforddown. I'm a bit out of my depth.

Template does not knit

Hi,

While running the template, I am getting this error message:

Quitting from lines 759-762 (_main.Rmd) 
Error in 1:header_rows_end : NA/NaN argument
Calls: <Anonymous> ... kable_styling -> pdfTable_styling -> styling_latex_repeat_header
In addition: Warning messages:
1: In yaml::yaml.load(..., eval.expr = TRUE) :
  NAs introduced by coercion: 10,052 is not an integer
2: In yaml::yaml.load(..., eval.expr = TRUE) :
  NAs introduced by coercion: 10,052 is not an integer
Execution halted

Could you please check if I am doing anything wrong? Thanks a lot!

Here is my session information:

R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.0.5    bookdown_0.21     htmltools_0.5.1.1 tools_4.0.5       yaml_2.2.1        rmarkdown_2.7     knitr_1.32        xfun_0.22         digest_0.6.27    
[10] rlang_0.4.10      evaluate_0.14    

Adding Acknowledgements and Abstract to table of contents with visible roman page numbering

Hello,

Any recommendations on how to edit what is included in the table of contents? For instance, my school requires the acknowledgement & abstract sections to be included in the table of contents.

Relatedly, I am required to have the roman numbering for the front matter to start on the Acknowledgements page, rather than on the List of Figures page.

I see in docs → _main.tex (see below) that the roman page numbers are invisible until ToC, but I can't seem to find a way to unhide them.

% JEM: Pages are roman numbered from here, though page numbers are invisible until ToC. This is in
% keeping with most typesetting conventions.
\begin{romanpages}

Therefore, the table of contents would be something like this, with corresponding, visible roman numbering on the Acknowledgements and Abstract pages:

Acknowledgements........................... ii
Abstract........................... iii
List of Tables.............vii
List of Tables.............viii

I've been absolutely loving this package so far, thank you so much for setting it up!

(FYI this is my first time creating an issue, so happy to clarify further as needed).

Best,

Keana

Reorder references and appendices

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.

unable to build book

I am able to knit the individual files without any issues , however,
attempt to compile the entire files by hitting build book spits out the following error:

pandoc: unrecognized option `--lua-filter=scripts_and_filters/correction_filter.lua'
Try pandoc --help for more information.
Error: pandoc document conversion failed with error 2.

In addition, there seems to be a conflict btwn these files [index.Rdm & main.Rmd], because even upon replacing the above Pandoc's argument with the one in bookdown ("Yihui Xie"), ie, pandoc_args: --top-level-division=chapter?
it also spits out a different error prompt:

The file _main.Rmd exists. Please delete it if it was automatically generated, or set a different book_filename option
in _bookdown.yml. If you are sure it can be safely deleted, please set the option 'delete_merged_file' to true in _bookdown.yml.

Write thesis in latex but I wanna use oxforddown when thesis is finished !

Hey buddy,

Great project, thanks for this awesome work!

I have a question. I would like to write my thesis using oxforddown and generate an html version of it. But my professors would also like to work on my thesis and they are more comfortable with latex.

I would like to ask what are the possible options I have? Is it possible for me to write my thesis in a latex template and then, toward the end of my PhD, I convert everything to rmarkdown and then use oxforddown to generate html?

What is the best strategy for me ?

Kindly help.

sections instead of chapters

Hi Ulrik,

thank you so much for putting together such clean and well-organized templates.

I want to build a single paper based on your oxforddown.
Can I convert the chapters into sections, so that there will be no page break for each section?

Also, can I change the chapter title position from the "Top Right" corner with a big number, to the "Top Left" corner?

thank you
andy

Integrating my University logo to oxforddown project

I am trying to integrate my own University logo changing university-logo: templates/beltcrest.pdf to university-logo: templates/my_uni_logo.png. But it gives me an error:

output file: _main.knit.md

! Missing endcsname inserted.
<to be read again> 
                   protect 
l.232 

Error: LaTeX failed to compile _main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See _main.log for more info.
Execution halted

I am doubting that it only accepts images in pdf format? Is there a way to use a png logo? If so, is it still recommended to use a pdf format?

Instructions on using TinyTeX

Following #4, I tried to build this project with TinyTeX, and below is what I found, which could be used to update the LaTeX requirements in readme: https://github.com/ulyngs/oxforddown#requirements

First install the base TinyTeX:

remotes::install_github('yihui/tinytex')
tinytex::install_tinytex()
p1 = tinytex::tl_pkgs()

Then render the book, and let tinytex automatically install missing LaTeX packages (this will take a while for the first time):

bookdown::render_book('index.Rmd')
p2 = tinytex::tl_pkgs()

Check which new packages were required:

p3 = setdiff(p2, p1) 

So the instructions on using TinyTeX can tell users to install these additional packages (so normal users won't need to do the above steps by themselves but simply run the code below):

p3 = c(
  "appendix", "babel-english", "babel-greek", "babel-latin", 
  "biber", "biblatex", "caption", "cbfonts-fd", "colortbl", "csquotes", 
  "enumitem", "environ", "eso-pic", "fancyhdr", "greek-fontenc", 
  "grfext", "hyphen-greek", "hyphen-latin", "lineno", "logreq", 
  "makecell", "microtype", "minitoc", "multirow", "notoccite", 
  "oberdiek", "pdflscape", "pdfpages", "quotchap", "soul", "tabu", 
  "threeparttable", "threeparttablex", "titlesec", "tocbibind", 
  "trimspaces", "ulem", "units", "utopia", "varwidth", "wrapfig"
)
tinytex::tlmgr_install(p3)

Then this 280Mb TinyTeX should match the 4Gb MiKTeX and produce the expected PDF output.

`header-includes` works but `includes: in_header` does not

I have a preamble.tex file with the following:

\usepackage{pdflscape}
\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}

It gives me the ability to add landscape pages ad hoc in the document. However, running bookdown::render_book(output_format = "bookdown::pdf_book") in an oxforddown fork using the following doesn't work:

output:
  bookdown::pdf_book:
    includes:
      in_header: "preamble.tex"

I get the following error, which suggests that preamble.tex isn't being read.

! Undefined control sequence.
l.363 \blandscape

On the other hand, using the following works:

header-includes:
  - \usepackage{pdflscape}
  - \newcommand{\blandscape}{\begin{landscape}}
  - \newcommand{\elandscape}{\end{landscape}}

I'm guessing that the issue might have to do with something in template.tex because using includes: in_header works fine in bookdown-demo.

Do you have any idea what might be causing this before I do more digging?

Session info
xfun::session_info("bookdown")
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Locale: en_AU.UTF-8 / en_AU.UTF-8 / en_AU.UTF-8 / C / en_AU.UTF-8 / en_AU.UTF-8

Package version:
  base64enc_0.1.3   bookdown_0.21.7   digest_0.6.27     evaluate_0.14    
  glue_1.4.2        graphics_4.0.2    grDevices_4.0.2   highr_0.8        
  htmltools_0.5.1.1 jsonlite_1.7.2    knitr_1.31        magrittr_2.0.1   
  markdown_1.1      methods_4.0.2     mime_0.10         rlang_0.4.10     
  rmarkdown_2.7.4   stats_4.0.2       stringi_1.5.3     stringr_1.4.0    
  tinytex_0.30.2    tools_4.0.2       utils_4.0.2       xfun_0.22        
  yaml_2.2.1       

How to prevent the text in the list of figures to be too long

I add a title and text explaining the figure when I add a figure to a pdf output.

For example, when I do:

```{r, fig.cap="I want this sentence to appear in list of figures section of the output pdf. But I do not want any sentences after the first one to appear there. But I still want all sentences to appear under the figure in the output."}
knitr::include_graphics("somefigure.pdf")

The whole sentence will go to the list of figures section. This is a dummy example and I have much longer texts that I have to write in the fig.cap="". Is there a way to fix this? :)

Individual .bib files for each chapter

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.

License

Hey, just stumbled across this and looks like a really neat project. I was wondering, would you mind adding a license to this repository? Thanks.

mintoc: triple spacing between lines on second page

One chapter has a long TOC, and the minitoc goes onto the second page.
The spacing is perfect on the first page, then the minitoc continues with enormous spaces between lines.

How can I fix the minitoc spacing issue, when it's only different on the second page?
Also, how can you insert a manual page break inside a long minitoc like this?

Thanks!

PDF does not open after being rendered (using Makefile)

When clicking on "Build All" button in RStudio, the PDF renders just fine, but will not open. I have found out that this is actually a problem with browseURL() command. When replaced with system2("open", "docs/_main.pdf"), everything compiles and opens according the expectations.

EDIT: There is sort of important argument, which should be used for our purpose and the line should then be like:
Rscript -e 'system2("open", "docs/_main.pdf", wait = FALSE)'. Otherwise, RStudio Build pane waits for something I do not really understand and the red STOP button is active. With wait = FALSE, this behaviour is corrected.

Here is the error message:

Rscript -e 'browseURL("docs/_main.pdf")'
Error in shell.exec(url) : 'docs/_main.pdf' not found
Calls: browseURL -> shell.exec
Execution halted
make: *** [Makefile:4: pdf] Error 1

Exited with status 2.

And sessionInfo:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=Czech_Czechia.1250 
[2] LC_CTYPE=Czech_Czechia.1250   
[3] LC_MONETARY=Czech_Czechia.1250
[4] LC_NUMERIC=C                  
[5] LC_TIME=Czech_Czechia.1250    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2   rsconnect_0.8.16 tools_4.0.2     
[4] packrat_0.5.0 

`lineno` seems to screw up encoding

When I turn on line numbers my PDF document becomes unsearchable, and copy-pasting text leads to weird characters. Visually, however, it looks perfectly fine.

When I have some more time I'll come back and provide a reprex, but I just wanted to note this for now in case someone else has this issue. (Also, it doesn't look like lineno has active support when I follow the link in CTAN: http://www.webdesign-bu.de/uwe_lueck/contact.html.)

The part before "Why use it?" in the Introduction is now in Japanese as attached.

The part before "Why use it?" in the Introduction is now in Japanese as attached.
BTW, Is this the correct way to contact you?

#########################################

options for knitting a single chapter

#########################################

オックスフォード大学で自分の博士論文を書く際に作成したRMark-down用の論文テンプレート、oxforddown [@lyngsOxforddown2019]へようこそ。このテンプレートでは、RMarkdownで書きながら、美しく実績のあるOxThesisLaTeXテンプレートでPDF出力をフォーマットすることができ,かつ,長い間使われてきた美しいOxThesisLaTeXテンプレートでPDF出力をフォーマットすることができます。my own PhD thesis at the University of Oxford.
もしあなたがTeXやLaTeXを使ったことがないのであればR Markdownで論文を書くことで、OxThesisテンプレートへのより良いインターフェイスを提供できることを願っています。さらに重要なことは、R Markdownを使うと、論文の中にコードの塊を埋め込むことができ、コピー&ペーストの手順を避けて、基礎となるデータから直接プロットや表を生成することができるということです。これにより、再現可能な研究を行う習慣が身に付き、研究者としての長期的な利益となり、将来的にあなたの結果を再現したり構築したりしようとする人の助けにもなるのです。

Why use it? {.unnumbered}

-------Error message------
processing file: 00-introduction.Rmd
output file: 00-introduction.knit.md

! Package inputenc Error: Unicode character オ (U+30AA)
(inputenc) not set up for use with LaTeX.

Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. See https://bookdown.org/yihui/rmarkdown-cookbook/latex-unicode.html
エラー: LaTeX failed to compile 00-introduction.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See 00-introduction.log for more info.
追加情報: 警告メッセージ:
1: grep("^\s*$", x) で: 入力文字列 1824 はこのロケールでは不適切です
2: grep("^! ", x) で: 入力文字列 1824 はこのロケールでは不適切です
実行が停止されました

Originally posted by @kizen777 in #42 (comment)

Sorting references in alphabetical order using natbib

I want to use natbib for my references, and therefore I set use-biblatex: false and use-natbib: true in the YAML and change nothing else. When I knit the document, the references are ordered (in the references section) not in an alphabetical order, but some strange/unpredictable order. How I can solve this?

References using CSL

Hi Ulrik,

Thanks for maintaining this package! It makes my life easier.

I would like to specify a specific citation style using CSL - as you've recommended here -https://ulyngs.github.io/oxforddown/cites-and-refs.html#citation-appearance-

I have written that file here:

output:
  bookdown::pdf_book:
    citation_package: biblatex
    template: templates/template.tex
    keep_tex: true
    pandoc_args: "--lua-filter=scripts_and_filters/colour_and_highlight.lua"
  bookdown::bs4_book: 
    css: 
      - templates/bs4_style.css
      - templates/corrections.css # remove to stop highlighting corrections
    theme:
      primary: "#6D1919"
    repo: https://github.com/ulyngs/oxforddown
    pandoc_args: "--lua-filter=scripts_and_filters/colour_and_highlight.lua"
  bookdown::gitbook:
    css: templates/style.css
    config:
      sharing:
        facebook: false
        twitter: yes
        all: false
  bookdown::word_document2:
    toc: true   
csl: bibliography/vancouver.csl
link-citations: true
documentclass: book
always_allow_html: true #this allows html stuff in word (.docx) output

I also have this:

citation and bibliography style

bibliography-heading-in-pdf: References

biblatex options

unless you run into 'biber' error messages, use biblatex as it lets you customise your bibliography directly

use-biblatex: true
bib-latex-options: "style=numeric-comp, sorting=none, backend=biber, maxcitenames=2, useprefix, doi=true, isbn=false, uniquename=false" #for science, you might want style=numeric-comp, sorting=none for numerical in-text citation with references in order of appearance

However the reference style that I get is not what I anticipated, it looks like the standard LaTeX references? I was wondering if you can help me with this?

Best regards,

Gladymar

make word fails on Ubuntu

$ uname -a
Linux 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ make clean && make word
rm -f *.log *.mtc* *.maf *.aux *.bbl *.blg *.xml
Rscript -e 'options(bookdown.render.file_scope = FALSE); bookdown::render_book("index.Rmd", output_format = "bookdown::word_document2")'


processing file: _main.Rmd

...

output file: _main.knit.md

UTF-8 decoding error in _main.utf8.md at byte offset 33057 (f8).
The input must be a UTF-8 encoded text.
Error: pandoc document conversion failed with error 92
In addition: Warning messages:
1: In read_utf8(file) :
  The file pandoc5f3663777eed is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 3, 4, 5, 6, 7, 8, ...
2: In hook(x[i], reduce_plot_opts(options)) :
  Chunk options fig.align is not supported for docx output
3: In hook(x[i], reduce_plot_opts(options)) :
  Chunk options fig.align is not supported for docx output
4: In hook(x[i], reduce_plot_opts(options)) :
  Chunk options fig.align is not supported for docx output
5: In hook(x[i], reduce_plot_opts(options)) :
  Chunk options fig.align is not supported for docx output
6: In read_utf8(file) :
  The file pandoc5f36489bcc80 is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 3, 4, 5, 6, 7, 8, ...
7: In read_utf8(file) :
  The file pandoc5f36364cfd3 is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 3, 4, 5, 6, 7, 8, ...
8: In read_utf8(file) :
  The file pandoc5f36740b5691 is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 3, 4, 5, 6, 7, 8, ...
9: In readLines(con, warn = FALSE) :
  invalid input found on input connection '_main.knit.md'
Execution halted
Warning message:
In file.remove(intermediate_html) :
  cannot remove file '_main.utf8.tmp.html', reason 'No such file or directory'
Makefile:11: recipe for target 'word' failed
make: *** [word] Error 1

Default latex engine doesn't work at times

Specify latex engine

  • The default pdflatex engine throws a UTF-8 encoding error
  • Perhaps, add a line to let users select a latex_engine in the index.Rmd file that works?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.