From 907f2071bd92d916876e2fa5ec0c2204ba4db0ff Mon Sep 17 00:00:00 2001 From: Samasaur1 <30577766+Samasaur1@users.noreply.github.com> Date: Wed, 20 Apr 2022 13:14:08 -0700 Subject: [PATCH 1/2] Add an optional list of abbreviations I don't really understand R Markdown, so I edited both copies of the 'template.tex' and 'index.Rmd' files that show up when generating a new project. --- .../rmarkdown/templates/thesis/skeleton/skeleton.Rmd | 8 ++++++++ .../rmarkdown/templates/thesis/skeleton/template.tex | 12 ++++++++++++ inst/rstudio/templates/project/resources/index.Rmd | 8 ++++++++ .../rstudio/templates/project/resources/template.tex | 12 ++++++++++++ 4 files changed, 40 insertions(+) diff --git a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd index bb936e2d..328ad908 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd @@ -45,6 +45,14 @@ dedication: | preface: | This is an example of a thesis setup to use the reed thesis document class (for LaTeX) and the R bookdown package, in general. +abbreviations: + ABC: American Broadcasting Company + CBS: Colombia Broadcasting System + CUS: Computer User Services + PBS: Public Broadcasting System + NBC: National Broadcasting Company +# Note that abbreviations in lowercase letters will NOT be automatically capitalized +# Delete or silence the abbreviations section if you do not want a list of abbreviations # Specify the location of the bibliography below bibliography: bib/thesis.bib diff --git a/inst/rmarkdown/templates/thesis/skeleton/template.tex b/inst/rmarkdown/templates/thesis/skeleton/template.tex index 509170b0..f56d4913 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/template.tex +++ b/inst/rmarkdown/templates/thesis/skeleton/template.tex @@ -207,6 +207,18 @@ \end{preface} $endif$ +$if(abbreviations)$ +\chapter*{List of Abbreviations} +\begin{table}[h] + \centering + \begin{tabular}{ll} + $for(abbreviations/pairs)$ + \textbf{$it.key$} & $it.value$ \\ + $endfor$ + \end{tabular} +\end{table} +$endif$ + $if(toc)$ \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$} \setcounter{secnumdepth}{$toc-depth$} diff --git a/inst/rstudio/templates/project/resources/index.Rmd b/inst/rstudio/templates/project/resources/index.Rmd index bb936e2d..328ad908 100644 --- a/inst/rstudio/templates/project/resources/index.Rmd +++ b/inst/rstudio/templates/project/resources/index.Rmd @@ -45,6 +45,14 @@ dedication: | preface: | This is an example of a thesis setup to use the reed thesis document class (for LaTeX) and the R bookdown package, in general. +abbreviations: + ABC: American Broadcasting Company + CBS: Colombia Broadcasting System + CUS: Computer User Services + PBS: Public Broadcasting System + NBC: National Broadcasting Company +# Note that abbreviations in lowercase letters will NOT be automatically capitalized +# Delete or silence the abbreviations section if you do not want a list of abbreviations # Specify the location of the bibliography below bibliography: bib/thesis.bib diff --git a/inst/rstudio/templates/project/resources/template.tex b/inst/rstudio/templates/project/resources/template.tex index 6db24bcb..efc18274 100644 --- a/inst/rstudio/templates/project/resources/template.tex +++ b/inst/rstudio/templates/project/resources/template.tex @@ -207,6 +207,18 @@ \end{preface} $endif$ +$if(abbreviations)$ +\chapter*{List of Abbreviations} +\begin{table}[h] + \centering + \begin{tabular}{ll} + $for(abbreviations/pairs)$ + \textbf{$it.key$} & $it.value$ \\ + $endfor$ + \end{tabular} +\end{table} +$endif$ + $if(toc)$ \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$} \setcounter{secnumdepth}{$toc-depth$} From 4672cb70855d82f249e6b41857b902cd553218ce Mon Sep 17 00:00:00 2001 From: Samasaur1 <30577766+Samasaur1@users.noreply.github.com> Date: Fri, 23 Sep 2022 15:25:43 -0700 Subject: [PATCH 2/2] Convert inclusion of prelims to block scalars Here's how this process used to work: - the R code is executed first (replacing `r [...]` with the text of the abstract) - YAML processes everything inside single quotes. note that if the abstract has single quotes in it, the YAML "quoted block" will end early, causing a syntax error. Now, we're using a YAML "block scalar", which doesn't allow escapaing and contains everything that's indented. Note how we indent every line of the read file --- inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd | 3 ++- inst/rstudio/templates/project/resources/index.Rmd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd index 328ad908..c346bacf 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd @@ -34,7 +34,8 @@ output: # (e.g., abstract, acknowledgements) below or use code similar to line 25-26 # for the .RMD files. If you are NOT producing a PDF, delete or silence # lines 25-39 in this YAML header. -abstract: '`r if(knitr:::is_latex_output()) paste(readLines(here::here("prelims", "00-abstract.Rmd")), collapse = "\n ")`' +abstract: | + `r if(knitr:::is_latex_output()) paste(readLines(here::here("prelims", "00-abstract.Rmd")), collapse = "\n ")` # If you'd rather include the preliminary content in files instead of inline # like below, use a command like that for the abstract above. Note that a tab # is needed on the line after the `|`. diff --git a/inst/rstudio/templates/project/resources/index.Rmd b/inst/rstudio/templates/project/resources/index.Rmd index 328ad908..c346bacf 100644 --- a/inst/rstudio/templates/project/resources/index.Rmd +++ b/inst/rstudio/templates/project/resources/index.Rmd @@ -34,7 +34,8 @@ output: # (e.g., abstract, acknowledgements) below or use code similar to line 25-26 # for the .RMD files. If you are NOT producing a PDF, delete or silence # lines 25-39 in this YAML header. -abstract: '`r if(knitr:::is_latex_output()) paste(readLines(here::here("prelims", "00-abstract.Rmd")), collapse = "\n ")`' +abstract: | + `r if(knitr:::is_latex_output()) paste(readLines(here::here("prelims", "00-abstract.Rmd")), collapse = "\n ")` # If you'd rather include the preliminary content in files instead of inline # like below, use a command like that for the abstract above. Note that a tab # is needed on the line after the `|`.