Chapter 6 Shit gets real
6.1 Imputation
6.2 Tailoring templates
6.3 Conversion from pdf to docx
6.3.1 As closed as source gets!
Adobe Acrobat…
6.4 git
6.5 pandoc
6.6 latex
6.6.1 Tweaking biblatex footnote citations
The defaults from biblatex are either author year, or author title styles in biblatex, i prefer to have author, journal title, year in the footnote citations. To achieve this, I have to manually edit the authoryear.cbx style located in the following folder:
/usr/local/texlive/2018/texmf-dist/tex/latex/biblatex/cbx
This is needed when texlive updates, and say, for texlive 2019, the folder would then be:
/usr/local/texlive/2019/texmf-dist/tex/latex/biblatex/cbx
The edits to the file are the follwing:
Change
\ExecuteBibliographyOptions{labeldateparts,uniquename,uniquelist,autocite=inline} # that last part
to
\ExecuteBibliographyOptions{labeldateparts,uniquename,uniquelist,autocite=footnote} # that last part
and
\newbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
to
\newbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%
\usebibmacro{cite:labeldate+extradate}}
\setunit{\addcomma\space}% # these two lines added
\usebibmacro{journal} # these two lines added
{\usebibmacro{cite:shorthand}}}
6.7 This document
This document is made with bookdown, and I produce html, pdf and word files simultaneousely. Most of the table making functinos are really good at either, but not all. To be able to achieve multiple outpot formats, I make use of a hack, that evaluates r-chunks conditionally from the output format.
You are invited to contribute. The reposistory for this book is stored at: https://bitbucket.org/tormodboe/, and you are welcome to fork, make pull requests and make other contributions.
In the start of the document is the following chunk:
is_docx_output = function() {
knitr::opts_knit$get("rmarkdown.pandoc.to")=="docx"
}
is_latex_output = function() {
knitr::opts_knit$get("rmarkdown.pandoc.to")=="latex"
}
is_html_output = function() {
knitr::opts_knit$get("rmarkdown.pandoc.to")=="html"
}
This captures the document output format. I then use this information to produce tables suitable for html output like this:
{r, eval=!is_latex_output(), results='asis', echo = T}
texreg::htmlreg(list(m1, m2, m3), doctype = F, caption = "texreg table")
and for pdf output (through latex) using this:
{r, eval=is_latex_output(), results='asis', echo = T}
texreg::texreg(list(m1, m2, m3), caption = "texreg table")