Skip to contents

[Experimental]

Usage

find_ref_to_word_bibliography(
  input,
  output_file = NULL,
  csl_path = NULL,
  no_layout = FALSE
)

parse_ref_to_word_bibliography(input, output_file = NULL, csl_path = NULL)

Arguments

input

The path to the document (PDF for find_ref_to_word_bibliography() and text or vector of character (with one reference per element) for parse_ref_to_word_bibliography() from which to extract or parse references.

output_file

Optional; The path where the Word document should be saved, with the path incorporating the name of the output. If provided, it must end with '.doc' or '.docx'. If not provided, the function will create a file with the same name as the input file, but with a '.docx' extension, in the user's home directory.

csl_path

Optional; the path to a CSL file that specifies the formatting for the bibliography. If not provided, the default CSL of Rmarkdown will be used.

no_layout

A logical value indicating whether to ignore the layout of the document when extracting or parsing references. This is typically more relevant for PDF documents.

Value

The path to the created Word document containing the bibliography.

Details

These functions, find_ref_to_word_bibliography() and parse_ref_to_word_bibliography(), are designed to extract or parse references from PDF or text documents respectively, and then create a formatted bibliography in a Word document using RMarkdown. The references are formatted according to the specified Citation Style Language (CSL) file, if provided.

Both functions operate by first extracting or parsing references from the specified document using the find_ref() or parse_ref() function respectively and saving the results in a temporary '.bib' file. They then construct an RMarkdown document with YAML front matter specifying the title, output format (Word), and the path to the bibliography file and optional CSL file. Finally, they render the RMarkdown document to a Word file, placing the formatted bibliography in the resulting document.

Examples

if (FALSE) {
# Assuming you have a PDF document named 'sample.pdf' in your working directory
# and you want to create a Word document named 'bibliography.docx':
find_ref_to_word_bibliography(input = "sample.pdf",
output_file = "full/path/to/bibliography.docx")

# If you also have a CSL file for formatting named 'apa.csl' (document saved in the directory file):
find_ref_to_word_bibliography(input = "sample.pdf",
output_file = "bibliography.docx", csl_path = "apa.csl")
}