| 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.3 |
| Built: | 2026-03-19 16:10:23 UTC |
| Source: | https://github.com/Nmoiroux/InsectLabelR |
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).
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" )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" )
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"). |
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.
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.
# create_pdf( # file_out = "output.pdf", # Name of pdf file # ind_list = mosquito_collection , # Table of data # print_info = print_parameters, # Table of printing parameter # lab_width = 15, # Width of the labels in mm # lab_height = 9, # Height of the labels in mm # font_size = 4, # Font size # n_col = 8, # Number of label per row on page # col_N_name = "N", # Column with Number of specimens sharing identical metadata. # hl_col = "orange" # Color for highlighted text # )# create_pdf( # file_out = "output.pdf", # Name of pdf file # ind_list = mosquito_collection , # Table of data # print_info = print_parameters, # Table of printing parameter # lab_width = 15, # Width of the labels in mm # lab_height = 9, # Height of the labels in mm # font_size = 4, # Font size # n_col = 8, # Number of label per row on page # col_N_name = "N", # Column with Number of specimens sharing identical metadata. # hl_col = "orange" # Color for highlighted text # )
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.
InsectLabelR_App()InsectLabelR_App()
A Shiny application object.
A toy dataset representing mosquito specimens collected in southern France
and intended for pinning and label printing with create_pdf().
A data frame with 24 rows and 12 variables:
Collection date (character). Example: "06/2024".
Locality name, optionally including administrative unit.
Country of collection.
Latitude in degrees-minutes-seconds (DMS) format (character).
Longitude in degrees-minutes-seconds (DMS) format (character).
Collector name.
Identifier (person who identified the specimen).
Biological sex of the specimen (e.g., "Male", "Female").
Genus name (e.g., Culiseta, Culex).
Subgenus name (may be empty).
Species epithet.
Number of specimens sharing identical metadata.
Unique specimen identifier (integer).
The dataset follows the standard input structure expected by
EtiquetteR, 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.
Simulated dataset for demonstration purposes.
data(mosquito_collection) head(mosquito_collection) # Example: generate labels directly from the dataset # create_pdf( # data = mosquito_example, # file_output = "mosquito_labels.pdf" # )data(mosquito_collection) head(mosquito_collection) # Example: generate labels directly from the dataset # create_pdf( # data = mosquito_example, # file_output = "mosquito_labels.pdf" # )
This function writes the closing commands to a LaTeX document. Specifically,
it appends the end of a multicols* environment and the document environment.
print_bottom(file_out)print_bottom(file_out)
file_out |
A character string specifying the path to the output file where the LaTeX closing commands will be appended. |
The function appends LaTeX commands for ending a multiple-column layout
(using the multicols* environment) and the document. It ensures the proper
closure of a LaTeX document that was generated by the preceding steps.
This function appends LaTeX code to the file specified in file_out.
It does not return any output in R.
# Example usage: # print_bottom("output.tex")# Example usage: # print_bottom("output.tex")
This function generates a LaTeX document header for mosquito labels and writes it to the specified output file. The header includes various LaTeX packages, document settings, metadata, and the front cover of the 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).
print_header( file_out, lab_width = 15, lab_height = 9, font_size = 4, n_col = 8 )print_header( file_out, lab_width = 15, lab_height = 9, font_size = 4, n_col = 8 )
file_out |
A character string specifying the name of the output file to write the LaTeX header to. |
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 columns in the LaTeX document (default is 8 columns). |
This function is primarily used for creating labels in LaTeX for mosquito specimen identification. It sets the document's layout and font sizes, allowing customization of label size and number of columns on the page.
## Not run: print_header("output.tex", lab_width = 20,lab_height = 10, font_size = 5, n_col = 7) ## End(Not run)## Not run: print_header("output.tex", lab_width = 20,lab_height = 10, font_size = 5, n_col = 7) ## End(Not run)
This function prints LaTeX labels for each line of a data table based on specified information and user-defined printing parameters. It formats each label according to the provided field names, data, and formatting options. The function generates LaTeX code for printing the labels into an external file. The latex code is based on the 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 )
print_line( file_out, ind_list, print_info, line_n, col_N_name = NA, hl_col = "orange" )print_line( file_out, ind_list, print_info, line_n, col_N_name = NA, hl_col = "orange" )
file_out |
A character string specifying the path to the output file where LaTeX code will be appended. |
ind_list |
A data frame containing the data for individuals. Each row corresponds to a specific individual. |
print_info |
A data frame specifying the printing parameters, including which fields to print, formatting options, and field names. |
line_n |
An integer indicating the row number in |
col_N_name |
A character string specifying the name of the column in |
hl_col |
A character string specifying the color to be used for text highlighting |
The function retrieves data from a specified row in ind_list and matches it with the corresponding print parameters
in print_info. It formats each label using the LaTeX code according to the user-defined options in print_info,
such as whether to italicize or bracket certain fields, and whether to include field names before the information.
The function generates LaTeX code for individual labels and appends it to the specified output file.
The function appends LaTeX code to the file specified in file_out.
It does not return anything in R.
# Example usage: # print_line("output.tex", ind_list, print_info, line_n = 1)# Example usage: # print_line("output.tex", ind_list, print_info, line_n = 1)
A toy parameter table defining how specimen data fields are arranged,
formatted, and distributed across labels when using create_pdf().
A data frame with 13 rows and 10 variables:
Name of the field in the mosquito_collection data table.
Logical (0/1). Whether the field is printed on labels.
Numeric. Label number on which the field is printed (e.g., 1 = identification label, 2 = locality/date label, 3 = collector/identifier label).
Numeric. Order of appearance within the label.
Character string added before the field value
(e.g., "leg.", "det.", "no.").
Logical (0/1). Whether the field should be printed in italics (typically for taxonomic names).
Logical (0/1). Whether the field should be printed in parentheses (commonly used for subgenus).
Logical (0/1). Whether a line break follows the field.
Logical (0/1). Whether the field should be highlighted.
Logical (0/1). Whether to print a sex symbol instead of the full sex text.
This dataset illustrates the structure expected by EtiquetteR to control label composition (field selection, ordering, formatting options, line breaks, highlighting, and symbol printing).
Each row corresponds to a field present in the specimen data table and specifies whether and how it should be printed.
This example configuration produces three labels per specimen:
Taxonomic label (genus, subgenus, species, sex).
Collection label (date and locality).
Collector/identifier label (collector, determiner, specimen number).
Taxonomic names are printed in italics, the subgenus is enclosed in parentheses, and sex can optionally be rendered as a biological symbol.
Simulated parameter table for demonstration purposes.
data(print_parameters) print(print_parameters) # Example usage with create_pdf(): # create_pdf( # data = mosquito_collection, # print_parameters = print_parameters, # file_output = "mosquito_labels.pdf" # )data(print_parameters) print(print_parameters) # Example usage with create_pdf(): # create_pdf( # data = mosquito_collection, # print_parameters = print_parameters, # file_output = "mosquito_labels.pdf" # )
This function converts a string representing sex data into the appropriate LaTeX code for displaying male or female symbols in small font.
sex_to_latex(sex_data)sex_to_latex(sex_data)
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 |
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.
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.
# Example usage: # sex_to_latex("female") # Returns "\smallfemale" # sex_to_latex("male") # Returns "\smallmale" # sex_to_latex(NA) # Returns NA# Example usage: # sex_to_latex("female") # Returns "\smallfemale" # sex_to_latex("male") # Returns "\smallmale" # sex_to_latex(NA) # Returns NA