write.murl: Write a .tex file of recipient information to be processed by...

View source: R/write.murl.R

write.murlR Documentation

Write a .tex file of recipient information to be processed by LaTeX

Description

Reads an R dataframe of letter recipient- and position-specific data, such as the output of read.murl. Creates a .tex file of the relevant data and LaTeX code, which can then be processed directly by pdflatex, for example.

Usage

write.murl(object, file.name = "mailmerge.tex", salutation = "Dear", 
sal.punct = ":", address.string = "123 Venus Flytrap Way\\\\Cincinnati, 
OH 45201\\\\ \\texttt{jfever@wkrp.edu}\\\\ 
\\texttt{http://www.wkrp.edu/jfever}\\\\513-555-5664", 
pad_if_zip4 = TRUE,
date = "\\today", letter.file = NULL, letter.text = NULL, valediction = "Sincerely,", 
signature = "Johnny Fever", opening = "", include.opening = FALSE, 
closing = "", include.closing = FALSE, contact_me = TRUE,
margin_geometry = NULL,
verbose = TRUE)

Arguments

object

a dataframe of mailmerge data, such as an output from read.murl().

file.name

a character string specifying the file name (and optionally, path) for the output .tex file. See Details below for more.

salutation

a character string specifying the salutation to be used in the letters.

sal.punct

a character string specifying the punctuation to be used at the end of the salutation.

address.string

a character string specifying the return address to be used in the letters. Note that two slashes (\\) should be used for every one usual LaTeX slash.

pad_if_zip4

a logical indicating whether to add a leading 0 (zero) to any ZIP code with 4 or 9 characters. Defaults to TRUE and warns the user.

date

an optional character string specifying the date. Defaults to the current date.

letter.file

an optional character string specifying a file containing the body text of the letters. See Details below for more.

letter.text

an optional character string containing the body text of the letters. See Details below for more.

valediction

a character string specifying the valediction to be used in the letters.

signature

a character string specifying the signature to be used in the letters.

opening

a character string specifying the opening line to be used in the letters. See Details below for more.

include.opening

a logical indicating whether an opening, customized line is to be used in the letters. See Details below for more.

closing

a character string specifying the closing line to be used in the letters. See Details below for more.

include.closing

a logical indicating whether a closing, letter-customized line is to be used in the letters. See Details below for more.

contact_me

a logical indicating whether a 'contact me' sentence is added to the closing. See Details below for more.

margin_geometry

an optional numeric vector of length 4 containing the number of inches of margin for the top, bottom, left, and right of the letter. See Details below for more.

verbose

a logical indicating whether the file.name and the current working directory should be printed after the file has been created.

Details

The dataframe used by write.murl should include columns for recipients' titles, first names, last names, addresses, cities, states, and ZIP codes, as well as information specific to the position for which the letter is in application. write.murl is intended to operate on the output of read.murl, and thus requires that the column names for the fields above be “title”, “fname”, “lname”, “address1” (and “address2”, etc.), “city”, “state”, “zip”, “position”, “subfield”, “dept”, and “institution”. These field names are automatically created by read.murl.

The user may define the main body text of the letter in at least three ways. First, write.murl includes some sample text by default. The user could simply edit this text in the .tex file created by write.murl. Second, the user could write the body text in a separate file (such as a .txt file) and specify that file's name using the letter.file argument. Third, the user could define the entire body text as a string passed to the letter.text argument.

If both letter.file and letter.text are specified, write.murl appends the value of letter.string below the contents of the file specified by letter.file.

The opening line specified by argument opening should be of a grammatical form consistent with “I write to apply for the position in”. This phrase will then be followed by customized input, using the fields “position”, “subfield”, “dept”, and “institution”, as in the example in Value below. To omit such a customized opening line, use the default include.opening = FALSE. The example in Value below, and thus each letter, will include only the content defined in the LaTeX-defined “body”.

The closing line specified by argument closing should be of a grammatical form consistent with “I will be an asset to the”. This phrase will then be followed by letter-customized input, using the fields “position”, “subfield”, and “instShort”. To omit such a customized closing line, use the default include.closing = FALSE. If contact_me is TRUE (the default), then the phrase “Please don't hesitate to contact me if more information would be helpful.” is included.

If the margin_geometry argument is specified, the LaTeX package geometry will be used, and the four components of margin_geometry provide the margins for the top, bottom, left, and right of the letters. If it is not specified, the default margins of documentclass{letter} are used.

Value

A .tex file of LaTeX code and recipient-specific content, to be processed directly by LaTeX. Using the included murljobs.csv sample data, the .tex file created by write.murl includes for each position one code snippet that looks like the following:

\begin{letter}
{Dr. Richard Sanders\\Graduate Admissions Committee\\123 Hello Way\\Frederick MD 21701}
\opening{Dear Dr. Sanders:}
 \body 
\closing{Sincerely,} 
\end{letter}

Author(s)

Ryan T. Moore rtm@american.edu and Andrew Reeves reeves@wustl.edu

See Also

read.murl

Examples

data(murljobs)

## Create mailmerge.tex required for LaTeX import
# write.murl(murljobs)

## Specify a file containing the letters' body text
## write.murl(murljobs, letter.file = "mybodytext.txt")

## Specify a string containing the letters' body text
# write.murl(murljobs, letter.text = "This is the whole body of my letters.")

## Specify salutation, valediction options (overwrites previous mailmerge.tex)
# write.murl(murljobs, file.name = "mailmerge.tex", salutation = "Greetings", 
#		     sal.punct = ",", valediction = "Truly Yours,", include.opening = FALSE)

## Specify opening line also (overwrites previous mailmerge.tex)
# write.murl(murljobs, file.name = "mailmerge.tex", salutation = "Greetings", 
#		     sal.punct = ",", valediction = "Truly Yours,", 
#		     opening = "I am applying for the job in", include.opening = TRUE)

muRL documentation built on Aug. 22, 2023, 9:11 a.m.