Package 'InsectLabelR'

Title: Create Labels for Insect in Collection
Description: Streamlines the creation of high-quality labels for insect pinning. By taking a dataset as input, the package allow to generate printable labels in 'LaTeX' and PDF format, helping researchers and entomologists maintain accurate and standardized specimen records. Requires a compatible installation of 'pdflatex' (e.g. <https://www.tug.org/texlive/>). For enhanced accessibility, the package includes a user-friendly 'shiny' application (accessible online <https://nicolas-moiroux.shinyapps.io/InsectLabelR/>), which provides a graphical interface for generating labels without requiring programming expertise.
Authors: Nicolas Moiroux [aut, cre] (ORCID: <https://orcid.org/0000-0001-6755-6167>), Nil Rahola [aut] (ORCID: <https://orcid.org/0000-0003-4067-6438>)
Maintainer: Nicolas Moiroux <[email protected]>
License: GPL (>= 3)
Version: 1.0.4
Built: 2026-04-03 21:34:50 UTC
Source: https://github.com/Nmoiroux/InsectLabelR

Help Index


Generate a Complete 'LaTeX' Document and Compile it into a PDF

Description

This function generates a 'LaTeX' document by sequentially adding a header, printing labels for each raw of a data table, appending a footer, and then compiling the 'LaTeX' code into a PDF document. The 'LaTeX' code is adapted from work by Samuel Brown (see https://github.com/sdjbrown/publicFiles/blob/master/labels.tex and http://the-praise-of-insects.blogspot.com/2010/03/latex-insect-labels.html). Ensure you have a compatible installation of 'pdflatex' (see https://www.latex-project.org/get/).

Usage

create_pdf(
  file_out,
  ind_list,
  print_info,
  lab_width = 15,
  lab_height = 9,
  font_size = 4,
  n_col = 8,
  col_N_name = NA,
  hl_col = "orange",
  compile = TRUE
)

Arguments

file_out

A character string specifying the name of returned 'LaTeX' and PDF files.

ind_list

A data frame containing individual data. Each row represents data for one individual to be printed in the document.

print_info

A data frame specifying the parameters for printing, including field names, formatting options, what data to print and, on how many labels.

lab_width

An integer specifying the width (in mm) for the labels (default is 15 mm).

lab_height

An integer specifying the height (in mm) for the labels (default is 9).

font_size

A real (one digit) specifying the size of the font for the label (default is 4)

n_col

An integer specifying the number of label columns in the 'LaTeX' document (default is 8 columns).

col_N_name

A character string specifying the column name to be used for labels duplication (default is NA).

hl_col

A character string specifying the highlight color for specific elements (default is "orange").

compile

Boolean (TRUE/FALSE). Does the 'LaTeX' document should be compiled into a PDF document ? (default to TRUE)

Details

This function first calls print_header to write the beginning of the 'LaTeX' document. Then, it iterates over each row of ind_list, calling print_line to generate labels according to the provided print_info. After all labels are printed, it appends the 'LaTeX' document footer using print_bottom. Finally, it compiles the 'LaTeX' document into a PDF using pdflatex.

Value

The function creates a 'LaTeX' file, compiles it into a PDF, and saves the outputs to the specified location. It does not return any value in R.

Examples

outfile <- file.path(tempdir(), "labels.tex")

# This example only generates the LaTeX file (no pdflatex required)
create_pdf(
  file_out = outfile,
  ind_list = mosquito_collection,
  print_info = print_parameters,
  compile = FALSE
)

## Not run: 
# Full PDF generation requires pdflatex installed
create_pdf(
  file_out = outfile,
  ind_list = mosquito_collection,
  print_info = print_parameters
)

## End(Not run)

Launch the InsectLabelR 'shiny' application

Description

This function launches an interactive 'shiny' application allowing users to use InsectLabelR with either example datasets included in the package or user-provided data. It provides a graphical interface for generating labels without requiring programming expertise.

The application is available online at https://nicolas-moiroux.shinyapps.io/InsectLabelR/.

Usage

InsectLabelR_App()

Value

A 'shiny' application object.

Examples

if(interactive()){
InsectLabelR_App()
}

Example mosquito collection dataset for label generation

Description

A toy dataset representing mosquito specimens collected in southern France and intended for pinning and label printing with create_pdf().

Format

A data frame with 24 rows and 12 variables:

rec_date

Collection date (character). Example: "06/2024".

rec_place

Locality name, optionally including administrative unit.

rec_cntry

Country of collection.

Y

Latitude in degrees-minutes-seconds (DMS) format (character).

X

Longitude in degrees-minutes-seconds (DMS) format (character).

rec_name

Collector name.

id_name

Identifier (person who identified the specimen).

sex

Biological sex of the specimen (e.g., "Male", "Female").

genus

Genus name (e.g., Culiseta, Culex).

subgenus

Subgenus name (may be empty).

species

Species epithet.

N

Number of specimens sharing identical metadata.

id

Unique specimen identifier (integer).

Details

The dataset follows the standard input structure expected by InsectLabelR, with one row per specimen (or per group of identical specimens when N > 1). It includes collection metadata, taxonomic identification, sex, geographic coordinates (in DMS format), and a unique specimen identifier.

This dataset can be used to test label layout, formatting, and PDF generation without requiring external files.

The dataset contains specimens of Culiseta (Cal.) longiareolata and Culex pipiens.

Source

Simulated dataset for demonstration purposes.


Convert Sex Data to 'LaTeX' Format

Description

This function converts a string representing sex data into the appropriate 'LaTeX' code for displaying male or female symbols in small font.

Usage

sex_to_latex(sex_data)

Arguments

sex_data

A character string representing the sex of an individual. It can start with "f" or "F" for female, "m" or "M" for male, or it can be NA.

Details

The function checks the first letter of the input string. If it starts with "f" or "F", it returns the 'LaTeX' code for the female symbol. If it starts with "m" or "M", it returns the 'LaTeX' code for the male symbol. If the input is NA or unrecognized, the function returns NA.

Value

A character string containing the corresponding 'LaTeX' code: "\smallfemale" for female, "\smallmale" for male, or NA if the input is not recognized or is NA.