Styling glosses

Mariana Montes

2023-03-18

Line styling

By default, glosses produced with glossr don’t have italics or bold (this may change in the future, by user request). However, it is fairly easy to adapt that at the document level.

The formatting of different lines is stored in options(), with variables starting with “glossr.format.”:

Each of these options can either take a value setting italics (“i”, “it”, “italics” or “textit”) or one setting boldface (“b” “bf”, “bold”, “textbf”).

If you’re familiar with options(), you can set your preference by entering something like this in a chunk:

options(glossr.format.a = "i") # italics in the first line

Alternatively, use_glossr() offers a friendlier interface with a wider variety of names, so you can choose the mnemonic that works for you. The argument “styling” must be a named list, with a key pointing to the line you want to style and the same range of values mentioned above.

If you would like to add other alternatives, let me know!

As an example, if you run the following chunk:

library(glossr)
use_glossr(styling = list(
  source = "b",
  first = "i"
))

…you will set all first lines to italics and the sources to boldface. The next one, on the other hand:

use_glossr(styling = list(
  first = "i",
  trans = "i"
))

…will set the first line and the free translation in italics.

You can always annul a setting by typing options(glossr.format.a = NULL), for example. But this setup is meant to encourage/enforce you to keep the same style across a given file.

Other formatting

Next to the line formatting options, the styling argument can take two other elements.

First, “trans_quotes” (also to be set as options(glossr.trans.quotes = "whatever")) defines the character you want to surround your translation with. By default, this is double quotes, but you might want to select single quotes instead, or remove them altogether. The following chunk of code sets italics in the first line and single quotes for the translation:

use_glossr(styling = list(
  first = "i",
  trans_quotes = "'"
))

And the following removes quotes altogether:

use_glossr(styling = list(
  first = "i",
  trans_quotes = ""
))

Second, “numbering = FALSE” when the output is not PDF allows you to remove the numbering of examples, e.g. in slides.

Latex-specific features

The expex documentation shows a number of parameters that can be manipulated to adjust the spacing of the different parts of a gloss. In all cases the default value is 0, but you can increase them (or reduce them, if some other setting in your template sets a different default value) by providing the right instructions to use_glossr().

The variables that you can manipulate are the following:

For instance, the following sets a spacing of 6pt above and below the example and a spacing of 15pt between the different sections of the example:

use_glossr(styling = list(
  exskip = 6,
  extraglskip = 15
))