Use Interlinear Glosses in R Markdown (original) (raw)

The glossr package gives you tools to include interlinear glosses in your R Markdown or Quarto file. If you are writing a linguistics paper and you want some interlinear glosses, this is for you!

Maybe you already use gb4e or expex and you’re happy with your PDF files, good for you! But maybe you want to spice things up, have your examples in one file and read a dataframe to generate them on demand, instead of typing and mistyping and having your examples all over the place. If that’s the case, glossr is for you!

Or maybe you want HTML output to work? If you use gb4e or expex, your examples will disappear from the HTML output! Here glossr can most definitely help. It even offers a helper function for cross-references that work in both formats! In fact, I included two different HTML outputs: one using leipzig.js and a sadder one that might be more accessible, just less pro-looking.

If you also want Word output, glossr can also take care of it, computing the expected width of the words and aligning them accordingly.

But please, don’t take my word for it —you can check the PDF, HTML and MS Word outputs of [vignette("glossr_how")](articles/glossr%5Fhow.html) stored in the repository.

Installation

Install glossr via CRAN:

You can also install the development version of glossr from GitHub with:

# install.packages("devtools")
devtools::install_github("montesmariana/glossr")

Example

This is a basic example; check [vignette("glossr_how")](articles/glossr%5Fhow.html) for more examples and their output.

library(glossr)
use_glossr()

my_gloss <- as_gloss(
  "她 哇的一聲 大 哭起來,",
  "tā wā=de-yì-shēng dà kū-qǐlái,",
  "TSG waa.IDEO-LINK-one-sound big cry-inch",
  translation = "Waaaaa, she began to wail.",
  label = "my-label",
  source = "ASBC (nº 100622)"
)