Skip to content

Commit

Permalink
Adding Vignette for using the PDF and Word output template
Browse files Browse the repository at this point in the history
  • Loading branch information
wfulp committed Aug 7, 2019
1 parent c73d4bd commit 1e21739
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
^LICENSE\.md$
^VISCtemplates\.Rproj$
^\.Rproj\.user$
^doc$
^Meta$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.Rhistory
.RData
.Rproj.user
doc
Meta
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ LazyData: true
URL: https://github.com/FredHutch/VISCtemplates
BugReports: https://github.com/FredHutch/VISCtemplates/issues
RoxygenNote: 6.1.1
Suggests:
knitr
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
64 changes: 64 additions & 0 deletions vignettes/using_pdf_and_word_template.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: "Using the PDF and Word Output Template"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Using the PDF and Word Output Template}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

The VISC report Rmarkdown template knits to either a PDF or Word document.

* To create a new report, create a new Rmarkdown from the "VISC Report (PDF & Word Output)" template.
* Use the Knit button select either the PDF (visc_report) or Word (word_document2) output.
* Note the shortcut Ctrl-Shift-K will run the first output in the YAML, will be the last output run (starts off as PDF first)
* If you want to run both reports in one command, either use `rmarkdown::render()` with `output_format = 'all'`, or install the loom package and create a RStudio Addin (<https://github.com/thebioengineer/loom>).


There are some new functions and coding conventions that help with knitting the report to both outputs.

## Page breaks

* For page breaks use the `visc_clearpage()` function. You can use this as a simple inline code: `` `r knitr::inline_expr("visc_clearpage()")` ``.
+ `\clearpage` (from previous template) will not work on Word output.

## Referencing
`
**Figure and table references**

* For figure and table references use `visc_ref()` function.
+ For example: `` `r knitr::inline_expr("visc_ref('fig:response-rate-plot')")` ``.
* Make sure chunk names only use dashes or referring will not work (no spaces or underscores).
* Do not use figure or table labels in chunk headings or kable code (e.g., don't use `fig.cap = "My Figure Caption \\label{my_figure_label}"`. Rmarkdown will automatically assign the chunk name as the figure/table reference label.

**Sections**

* For referencing sections, use `[Section header text]` in the text.
+ `[Background]` gives: [Background].
+ `[Biological endpoints]` gives: [Biological endpoints].

**References/Bibliography**

* For referencing papers, simply use the @ symbol before bib file reference (i.e. `@Huang:2013fl`).


## Tables

* Only output one table per code chunk.
* Make sure to have `format = output_type` in the `kableExtra::kable()` call
+ `output_type` is either "latex" or "pandoc" depending on current report output.
* The table name will be chunk name plus "tab:".
+ For example, if chunk name is "descriptive-stats" then the table label will be "tab:descriptive-stats"
* Note that Word output cannot support many kableExtra features, such as `kableExtra::kable_styling()`.
+ Set `warning=kable_warnings` chunk option, otherwise Word output will have unwanted warnings.

## Figures

* Only output one figure per code chunk.
* Figure name will be chunk name plus "fig:".
+ i.e. if chunk name is "-stats" then the table label will be "fig:descriptive-stats".

## P values

* When using `VISCfunctions::pretty_pvalues()` make sure to use `output_type = output_type`, `bold = pandoc_markup`, and , `italic = pandoc_markup`. This will give the appropriate markup depending on PDF or Word output.

0 comments on commit 1e21739

Please sign in to comment.