1. To live preview the output without kniting the file

xaringan::inf_mr()

2. Include code but not run in RMarkdown output

Add back ticks `` around the code.

3. Comment out text

  1. Manually put signs around your comment like: <!-- your comment -->

  2. Use the keyboard shortcut Ctrl + Shift + C to comment out a line of text.

4. Push local changes to GitHub

  1. In RStudio, Tools > Shell

  2. Type these command lines one by one:

       git add -A
       git commit -m “a comment on the motivation for this change”
       git push

5. Indent text

whitespaces are often meaningless in Markdown. Markdown will also ignore spaces used for indentation by default. However, we can use line blocks by starting the line with a vertical bar (|). The line breaks and any leading spaces will be preserved in the output. For example:

| When dollars appear it is a sign   
|   that your code does not quite align  
| Ensure that your math  
|   in xaringan hath  
|   been placed on a single long line

The output is:

When dollars appear it’s a sign
       that your code does not quite align
Ensure that your math
       in xaringan hath
       been placed on a single long line

6. Insert bibliographies and citations

Specify a bibliography file (make sure you choose the same folder as where your R Markdown document lives) using the bibliography metadata field in YAML. For example:

---
output: html_document
bibliography: references.bib  
---

where the BibTeX database is a plain-text file with the *.bib extension that consists of bibliography entries like this:

@Manual{R-base,
  title = {R: A Language and Environment for Statistical
           Computing},
  author = {{R Core Team}},
  organization = {R Foundation for Statistical Computing},
  address = {Vienna, Austria},
  year = {2019},
  url = {https://www.R-project.org},
}

Items can be cited directly within the documentation using the syntax @key where key is the citation key in the first line of the entry, e.g., @R-base. To put citations in parentheses, use [@key]. To cite multiple entries, separate the keys by semicolons, e.g., [@key-1; @key-2; @key-3]. To suppress the mention of the author, add a minus sign before @, e.g., [-@R-base].

7. Insert citations from Google Scholar

  1. Find an article you are interested
  2. Under the return result of that article, click Cite then BibTex, then copy the content then paste to your references.bib file.
  3. Cite this article in your Rmarkdown

8. Insert citations from Mendeley

Open Mendeley and select Mendeley > Tools > Options > BibTeX. Select Escape LaTeX special characters, Enable BibTeX syncing and Create one BibTeX file for my whole library.

Make sure you choose the same folder as where your R Markdown document lives. If you don’t want to do that, it is no longer automatically synced if you change something in Mendeley, so you’ll have to do update the bibtex file manually.

Now go to the R Mmarkdown document. In the YAML header, write ‘bibliography: library.bib’ , so your header will look like something this:

---
title: "Untitled" 
output: html_document 
bibliography: library.bib  
---

In Mendeley, check the citation key of the paper you want to cite (in the Document Details tab). In your R Markdown document, write the citation key in square brackets, for example [@Author2000].

9. Debug when fail to insert citations from Mendeley

Sometimes the article which exists in Mendeley can not be found in library.bib. Now it is worth checking whether this article is in the folder named Needs Review in Mendeley. Needs Review lists any items which Mendeley has imported, but may require extra attention.

Once you review the details and indicate that they’re correct, it will be removed from this list and automatically synced in your library.bib.

10. Find high quality BGU graphic materials, logos, and presentations

BGU logos are in both pdf and png format.

11. After adopt Oxforddown and write my own, compare with the original pdf output

Oxforddown pdf output

Useful references:

  1. R Markdown Cookbook.
  2. Thesis template Oxforddown
  3. Oxforddown learning video tutorial
  4. bs4 formatTutorial on how to use Oxforddown