I'd like to use the bib2gls
latex package in my rmarkdown document to insert a list of acronyms from a .bib file when I knit to a pdf document.
Doesn't work:
Using a .bib file to store my acronyms. Example:
abbreviations.bib file:
@abbreviation{ecoli,
short={E.~coli},
long={Escherichia coli}
}
@abbreviation{raustralis ,
short ={R.~ australis},
long={Rickettsia australis}
}
preamble.tex
% fixes problem with glossaries causing mathspec
% to return an error asking for amsmath to be loaded first
\makeatletter
\let\RequirePackage\original@RequirePackage
\let\usepackage\RequirePackage
\makeatother
% using bib2gls
\usepackage[record,abbreviations,style=index]{glossaries-extra}
\setabbreviationstyle{long-short}
\GlsXtrLoadResources[src={abbreviations},selection={all}]
rmarkdown file:
---
output:
pdf_document:
latex_engine: xelatex
includes:
in_header: preamble.tex
title: "mwe"
---
## R Markdown
This is the first instance \gls{ecoli}, \gls{raustralis}. This is the second instance: \gls{ecoli}, \gls{raustralis}.
\printunsrtglossary[title={Abbreviations},type=abbreviations]
The output when I knit the rmarkdown documents looks like:
What works:
Removing \GlsXtrLoadResources[src={abbreviations},selection={all}]
and adding my entries into the preamble.
% using bib2gls
\usepackage[abbreviations,style=index]{glossaries-extra}
\setabbreviationstyle{long-short}
\newabbreviation{ecoli}{E.~coli}{Escherichia coli}
\newabbreviation{raustralis}{R.~australis}{Rickettsia australis}
I'd like to use the separate .bib file in the first approach if possible. Unless there is a better approach to do this in R. Session info is below:
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252