Skip to contents

Add alternative text into latex

Usage

add_alttext(
  x = list.files(getwd())[grep("skeleton.tex", list.files(getwd()))],
  dir = getwd(),
  alttext_csv = file.path(getwd(), "captions_alt_text.csv"),
  compile = TRUE,
  rename = NULL,
  tagged = TRUE
)

Arguments

x

.tex The name of the .tex file to modify.

Default: "...skeleton.qmd"

dir

The directory containing the .tex file.

Default: the working directory (getwd()).

alttext_csv

Path to the .csv containing alternative text and captions, typically generated by stockplotr::exp_all_figs_tables().

Default: file.path(getwd(), "captions_alt_text.csv")

compile

Logical. If TRUE, renders the .tex file into a .pdf after modifications are complete.

Default: TRUE

rename

Optional new name for the modified .tex file (exclude the ".tex" extension). If NULL, the original file is overwritten.

Default: NULL

tagged

Indicate if the input tex file from dir has the latex package, tagpdf, used so that tagging is present.

Value

This function was made to help add in alternative text to latex documents generated from quarto. Quarto does not currently contain a way to add alternative text to PDF documents, so this function was developed as a work around. The addition of alternative text needs to be found in either the rda files produced from stockplotr::exp_all_figs_tables or in the captions_alt_text.csv also produced from the same function. Users not using this format should create a csv file with columns containing "label" and "alt_text" where the label column contains the exact label name when referencing the image/figure in text. The label is very important as it provides a way for the function to match where the alternative text gets placed. When compile is set to TRUE, the alternative text using this format will not be available and must be used in conjunction with asar::add_tagging() unless tagged is set to FALSE. Default is TRUE.

Examples

if (FALSE) { # \dontrun{
create_template(
  new_template = TRUE,
  format = "pdf",
  office = "NWFSC",
  region = "U.S. West Coast",
  species = "Dover sole",
  spp_latin = "Microstomus pacificus",
  year = 2010,
  authors = c("John Snow" = "AFSC", "Danny Phantom" = "NEFSC", "Patrick Star" = "SEFSC-ML"),
  model_results = "Report.sso",
  model = "SS3",
  new_section = "an_additional_section",
  section_location = "after-introduction",
  figures_dir = getwd()
)

quarto::quarto_render(file.path(getwd(), "report", "SAR_USWC_Dover_sole_skeleton.qmd"))

add_alttext(
  x = "SAR_USWC_Dover_sole_skeleton.tex",
  dir = file.path(getwd(), "report"),
  alttext_csv = "my_alttext_file.csv",
  compile = FALSE,
  rename = "SAR_Dover_sole_tagged"
)
} # }