├── Images ├── badheader.png ├── goodheader.png └── goodheaderlatex.png ├── Output ├── Template_LaTeX.pdf └── Template_Word.docx ├── Extras ├── Reference_Document.docx ├── clinical-mass-spectrometry.csl ├── scholarly-metadata.lua ├── author-info-blocks.lua ├── mybibfile.bib └── mytemplate.tex ├── README.md ├── Template_LaTeX.Rmd └── Template_Word.Rmd /Images/badheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drdanholmes/Affiliations/HEAD/Images/badheader.png -------------------------------------------------------------------------------- /Images/goodheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drdanholmes/Affiliations/HEAD/Images/goodheader.png -------------------------------------------------------------------------------- /Images/goodheaderlatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drdanholmes/Affiliations/HEAD/Images/goodheaderlatex.png -------------------------------------------------------------------------------- /Output/Template_LaTeX.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drdanholmes/Affiliations/HEAD/Output/Template_LaTeX.pdf -------------------------------------------------------------------------------- /Output/Template_Word.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drdanholmes/Affiliations/HEAD/Output/Template_Word.docx -------------------------------------------------------------------------------- /Extras/Reference_Document.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drdanholmes/Affiliations/HEAD/Extras/Reference_Document.docx -------------------------------------------------------------------------------- /Extras/clinical-mass-spectrometry.csl: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Affiliations 2 | RMarkdown Templates for Managing Academic Affiliations for MS-Word and LaTeX 3 | 4 | ## Background 5 | The repository provides an RMardown template for MS-Word or PDF output that allows for multiple authors with disparate affiliations. The problem and solution are discussed [here](http://labrtorian.com/2019/08/26/rmarkdown-template-that-manages-academic-affiliations/). The template handles authors, affiliations, emails, cross referencing of figures/tables, references and reference abbrebations. 6 | 7 | The output for MS-Word looks like this: 8 | 9 | ![multiple authors with affiliations](https://raw.githubusercontent.com/drdanholmes/Affiliations/master/Images/goodheader.png "Word Output") 10 | 11 | ## Requirements 12 | 13 | + RMarkdown and all the associated knitr goodies 14 | + [bookdown package](https://bookdown.org/) 15 | + [pandoc](https://pandoc.org/) 16 | + [pandoc-citeproc](https://github.com/jgm/pandoc-citeproc) 17 | + [pandoc-crossref](https://github.com/lierdakil/pandoc-crossref) 18 | + [lua language](https://www.lua.org/) 19 | + [lua scholarly metadata filter](https://github.com/pandoc/lua-filters/tree/master/scholarly-metadata) 20 | + [lua author info blocks filter](https://github.com/pandoc/lua-filters/tree/master/author-info-blocks) 21 | + [LaTeX](https://www.latex-project.org/get/) and the [authblk](https://www.ctan.org/pkg/authblk) package if you want PDF output 22 | 23 | ## Use 24 | 25 | Download .Rmd templates and folders, put them in a directory, open either the Word or LaTeX template and knit. Files must have the same relative paths as in the repository. All of the necessary filters and files are in the Extras folder. 26 | 27 | ## Contact 28 | 29 | dtholmes@mail.ubc.ca 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Extras/scholarly-metadata.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | ScholarlyMeta – normalize author/affiliation meta variables 3 | 4 | Copyright (c) 2017-2019 Albert Krewinkel, Robert Winkler 5 | 6 | Permission to use, copy, modify, and/or distribute this software for any purpose 7 | with or without fee is hereby granted, provided that the above copyright notice 8 | and this permission notice appear in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 12 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 14 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 16 | THIS SOFTWARE. 17 | ]] 18 | local List = require 'pandoc.List' 19 | 20 | -- Split a string at commas. 21 | local function comma_separated_values(str) 22 | local acc = List:new{} 23 | for substr in str:gmatch('([^,]*)') do 24 | acc[#acc + 1] = substr:gsub('^%s*', ''):gsub('%s*$', '') -- trim 25 | end 26 | return acc 27 | end 28 | 29 | --- Ensure the return value is a list. 30 | local function ensure_list (val) 31 | if type(val) ~= 'table' then 32 | -- create singleton list (or empty list if val == nil). 33 | return List:new{val} 34 | elseif val.t == 'MetaInlines' then 35 | -- check if this is really a comma-separated list 36 | local csv = comma_separated_values(pandoc.utils.stringify(val)) 37 | if #csv >= 2 then 38 | return csv 39 | end 40 | return List:new{val} 41 | elseif val.t == 'MetaList' then 42 | return List:new(val) 43 | else 44 | -- MetaBlocks or MetaMap, use as a singleton 45 | return List:new{val} 46 | end 47 | end 48 | 49 | --- Returns a function which checks whether an object has the given ID. 50 | local function has_id (id) 51 | return function(x) return x.id == id end 52 | end 53 | 54 | --- Copy all key-value pairs of the first table into the second iff there is no 55 | -- such key yet in the second table. 56 | -- @returns the second argument 57 | function add_missing_entries(a, b) 58 | for k, v in pairs(a) do 59 | b[k] = b[k] or v 60 | end 61 | return b 62 | end 63 | 64 | --- Create an object with a name. The name is either taken directly from the 65 | -- `name` field, or from the *only* field name (i.e., key) if the object is a 66 | -- dictionary with just one entry. If neither exists, the name is left unset 67 | -- (`nil`). 68 | function to_named_object (obj) 69 | local named = {} 70 | if type(obj) ~= 'table' then 71 | -- if the object isn't a table, just use its value as a name. 72 | named.name = pandoc.MetaInlines{pandoc.Str(tostring(obj))} 73 | named.id = tostring(obj) 74 | elseif obj.t == 'MetaInlines' then 75 | -- Treat inlines as the name 76 | named.name = obj 77 | named.id = pandoc.utils.stringify(obj) 78 | elseif obj.name ~= nil then 79 | -- object has name attribute → just create a copy of the object 80 | add_missing_entries(obj, named) 81 | named.id = pandoc.utils.stringify(named.id or named.name) 82 | elseif next(obj) and next(obj, next(obj)) == nil then 83 | -- the entry's key is taken as the name, the value contains the 84 | -- attributes. 85 | key, attribs = next(obj) 86 | if type(attribs) == "string" or attribs.t == 'MetaInlines' then 87 | named.name = attribs 88 | else 89 | add_missing_entries(attribs, named) 90 | named.name = named.name or pandoc.MetaInlines{pandoc.Str(tostring(key))} 91 | end 92 | named.id = named.id and pandoc.utils.stringify(named.id) or key 93 | else 94 | -- this is not a named object adhering to the usual conventions. 95 | error('not a named object: ' .. tostring(obj)) 96 | end 97 | return named 98 | end 99 | 100 | --- Resolve institute placeholders to full named objects 101 | local function resolve_institutes (institute, known_institutes) 102 | local unresolved_institutes 103 | if institute == nil then 104 | unresolved_institutes = {} 105 | elseif type(institute) == "string" or type(institute) == "number" then 106 | unresolved_institutes = {institute} 107 | else 108 | unresolved_institutes = institute 109 | end 110 | 111 | local result = List:new{} 112 | for i, inst in ipairs(unresolved_institutes) do 113 | result[i] = 114 | known_institutes[tonumber(inst)] or 115 | known_institutes:find_if(has_id(pandoc.utils.stringify(inst))) or 116 | to_named_object(inst) 117 | end 118 | return result 119 | end 120 | 121 | --- Insert a named object into a list; if an object of the same name exists 122 | -- already, add all properties only present in the new object to the existing 123 | -- item. 124 | function merge_on_id (list, namedObj) 125 | local elem, idx = list:find_if(has_id(namedObj.id)) 126 | local res = elem and add_missing_entries(namedObj, elem) or namedObj 127 | local obj_idx = idx or (#list + 1) 128 | -- return res, obj_idx 129 | list[obj_idx] = res 130 | return res, #list 131 | end 132 | 133 | --- Flatten a list of lists. 134 | local function flatten (lists) 135 | local result = List:new{} 136 | for _, lst in ipairs(lists) do 137 | result:extend(lst) 138 | end 139 | return result 140 | end 141 | 142 | --- Canonicalize authors and institutes 143 | local function canonicalize(raw_author, raw_institute) 144 | local institutes = ensure_list(raw_institute):map(to_named_object) 145 | local authors = ensure_list(raw_author):map(to_named_object) 146 | 147 | for _, author in ipairs(authors) do 148 | author.institute = resolve_institutes( 149 | ensure_list(author.institute), 150 | institutes 151 | ) 152 | end 153 | 154 | -- Merge institutes defined in author objects with those defined in the 155 | -- top-level list. 156 | local author_insts = flatten(authors:map(function(x) return x.institute end)) 157 | for _, inst in ipairs(author_insts) do 158 | merge_on_id(institutes, inst) 159 | end 160 | 161 | -- replace institutes with their indices 162 | local to_index = function (inst) 163 | return tostring(select(2, institutes:find_if(has_id(inst.id)))) 164 | end 165 | for _, author in ipairs(authors) do 166 | author.institute = pandoc.MetaList(author.institute:map(to_index)) 167 | end 168 | 169 | return authors, institutes 170 | end 171 | 172 | 173 | return { 174 | { 175 | Meta = function(meta) 176 | meta.author, meta.institute = canonicalize(meta.author, meta.institute) 177 | return meta 178 | end 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /Extras/author-info-blocks.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | affiliation-blocks – generate title components 3 | 4 | Copyright © 2017–2019 Albert Krewinkel 5 | 6 | Permission to use, copy, modify, and/or distribute this software for any purpose 7 | with or without fee is hereby granted, provided that the above copyright notice 8 | and this permission notice appear in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 12 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 14 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 16 | THIS SOFTWARE. 17 | ]] 18 | local List = require 'pandoc.List' 19 | local utils = require 'pandoc.utils' 20 | local stringify = utils.stringify 21 | 22 | local default_marks 23 | local default_marks = { 24 | corresponding_author = FORMAT == 'latex' 25 | and {pandoc.RawInline('latex', '*')} 26 | or {pandoc.Str '✉'}, 27 | equal_contributor = FORMAT == 'latex' 28 | and {pandoc.RawInline('latex', '$\\dagger{}$')} 29 | or {pandoc.Str '*'}, 30 | } 31 | 32 | local function intercalate(lists, elem) 33 | local result = List:new{} 34 | for i = 1, (#lists - 1) do 35 | result:extend(lists[i]) 36 | result:extend(elem) 37 | end 38 | if #lists > 0 then 39 | result:extend(lists[#lists]) 40 | end 41 | return result 42 | end 43 | 44 | --- Check whether the given author is a corresponding author 45 | local function is_corresponding_author(author) 46 | return author.correspondence and author.email 47 | end 48 | 49 | --- Create inlines for a single author (includes all author notes) 50 | local function author_inline_generator (get_mark) 51 | return function (author) 52 | local author_marks = List:new{} 53 | if author.equal_contributor then 54 | author_marks[#author_marks + 1] = get_mark 'equal_contributor' 55 | end 56 | local idx_str 57 | for _, idx in ipairs(author.institute) do 58 | if type(idx) ~= 'table' then 59 | idx_str = tostring(idx) 60 | else 61 | idx_str = stringify(idx) 62 | end 63 | author_marks[#author_marks + 1] = {pandoc.Str(idx_str)} 64 | end 65 | if is_corresponding_author(author) then 66 | author_marks[#author_marks + 1] = get_mark 'corresponding_author' 67 | end 68 | local res = List.clone(author.name) 69 | res[#res + 1] = pandoc.Superscript(intercalate(author_marks, {pandoc.Str ','})) 70 | return res 71 | end 72 | end 73 | 74 | local function is_equal_contributor (author) 75 | return author.equal_contributor 76 | end 77 | 78 | --- Create equal contributors note. 79 | local function create_equal_contributors_block(authors, mark) 80 | local has_equal_contribs = List:new(authors):find_if(is_equal_contributor) 81 | if not has_equal_contribs then 82 | return nil 83 | end 84 | local contributors = { 85 | pandoc.Superscript(mark'equal_contributor'), 86 | pandoc.Space(), 87 | pandoc.Str 'These authors contributed equally to this work.' 88 | } 89 | return List:new{pandoc.Para(contributors)} 90 | end 91 | 92 | --- Generate a block list all affiliations, marked with arabic numbers. 93 | local function create_affiliations_blocks(affiliations) 94 | local affil_lines = List:new(affiliations):map( 95 | function (affil, i) 96 | local num_inlines = List:new{ 97 | pandoc.Superscript{pandoc.Str(tostring(i))}, 98 | pandoc.Space() 99 | } 100 | return num_inlines .. affil.name 101 | end 102 | ) 103 | return {pandoc.Para(intercalate(affil_lines, {pandoc.LineBreak()}))} 104 | end 105 | 106 | --- Generate a block element containing the correspondence information 107 | local function create_correspondence_blocks(authors, mark) 108 | local corresponding_authors = List:new{} 109 | for _, author in ipairs(authors) do 110 | if is_corresponding_author(author) then 111 | local mailto = 'mailto:' .. pandoc.utils.stringify(author.email) 112 | local author_with_mail = List:new( 113 | author.name .. List:new{pandoc.Space(), pandoc.Str '<'} .. 114 | author.email .. List:new{pandoc.Str '>'} 115 | ) 116 | local link = pandoc.Link(author_with_mail, mailto) 117 | table.insert(corresponding_authors, {link}) 118 | end 119 | end 120 | if #corresponding_authors == 0 then 121 | return nil 122 | end 123 | local correspondence = List:new{ 124 | pandoc.Superscript(mark'corresponding_author'), 125 | pandoc.Space(), 126 | pandoc.Str'Correspondence:', 127 | pandoc.Space() 128 | } 129 | local sep = List:new{pandoc.Str',', pandoc.Space()} 130 | return { 131 | pandoc.Para(correspondence .. intercalate(corresponding_authors, sep)) 132 | } 133 | end 134 | 135 | --- Generate a list of inlines containing all authors. 136 | local function create_authors_inlines(authors, mark) 137 | local inlines_generator = author_inline_generator(mark) 138 | local inlines = List:new(authors):map(inlines_generator) 139 | local and_str = List:new{pandoc.Space(), pandoc.Str'and', pandoc.Space()} 140 | 141 | local last_author = inlines[#inlines] 142 | inlines[#inlines] = nil 143 | local result = intercalate(inlines, {pandoc.Str ',', pandoc.Space()}) 144 | if #authors > 1 then 145 | result:extend(List:new{pandoc.Str ","} .. and_str) 146 | end 147 | result:extend(last_author) 148 | return result 149 | end 150 | 151 | return { 152 | { 153 | Pandoc = function (doc) 154 | local meta = doc.meta 155 | local body = List:new{} 156 | 157 | local mark = function (mark_name) return default_marks[mark_name] end 158 | 159 | body:extend(create_equal_contributors_block(doc.meta.author, mark) or {}) 160 | body:extend(create_affiliations_blocks(doc.meta.institute) or {}) 161 | body:extend(create_correspondence_blocks(doc.meta.author, mark) or {}) 162 | body:extend(doc.blocks) 163 | 164 | -- Overwrite authors with formatted values. We use a single, formatted 165 | -- string for most formats. LaTeX output, however, looks nicer if we 166 | -- provide a authors as a list. 167 | meta.author = FORMAT:match 'latex' 168 | and pandoc.MetaList(doc.meta.author):map(author_inline_generator(mark)) 169 | or pandoc.MetaInlines(create_authors_inlines(doc.meta.author, mark)) 170 | -- Institute info is now baked into the affiliations block. 171 | meta.institute = nil 172 | 173 | return pandoc.Pandoc(body, meta) 174 | end 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /Extras/mybibfile.bib: -------------------------------------------------------------------------------- 1 | @article{EISENHOFER201940, 2 | title = "Steroid metabolomics: machine learning and multidimensional diagnostics for adrenal cortical tumors, hyperplasias, and related disorders", 3 | journal = "Current Opinion in Endocrine and Metabolic Research", 4 | volume = "8", 5 | pages = "40 - 49", 6 | year = "2019", 7 | issn = "2451-9650", 8 | doi = "https://doi.org/10.1016/j.coemr.2019.07.002", 9 | url = "http://www.sciencedirect.com/science/article/pii/S2451965019300341", 10 | author = "Graeme Eisenhofer and Claudio Durán and Triantafyllos Chavakis and Carlo Vittorio Cannistraci", 11 | keywords = "Steroids, Steroidomics, Machine learning, Mass spectrometry, LC-MS/MS, Adrenal, Primary aldosteronism, Cushing syndrome, Adrenal cortical carcinoma", 12 | abstract = "Steroid profiling applications have a long history primarily directed toward diagnosis of endocrine disorders of childhood. Technological advances in mass spectrometry enabling rapid, sensitive, and specific measurements of multiple steroids in biological fluids are now paving the way for numerous other applications, including diagnosis of adrenocortical carcinoma, primary aldosteronism, and different forms of hypercortisolism. Such analytical procedures that target combinations of steroids in a single biological sample have potential for efficient one-shot methods for diagnosis of multiple disorders of steroidogenesis. Moreover, within a specific disorder, such methods can facilitate subtyping for more rapid therapeutic stratification than allowed by current methods that rely on single measurements per sample at sequential time points in a diagnostic process. Combined with advances in computational mathematics, such as machine learning, it is now possible to move from traditional unidimensional approaches for interpreting diagnostic data to methods that can interpret patterns in data. Mass spectrometry–based steroidomics provides an ideal platform for advancing such multidimensional approaches for disease diagnosis and stratification. Bottlenecks that must be overcome to move forward include needs for laboratory harmonization and method certification combined with ingrained reliance on outmoded, but well-accepted, diagnostic methods and general inertia to take advantage of new technologies." 13 | } 14 | 15 | @article{VICENTE201984, 16 | title = "Automation of chromatographic peak review and order to result data transfer in a clinical mass spectrometry laboratory", 17 | journal = "Clinica Chimica Acta", 18 | volume = "498", 19 | pages = "84 - 89", 20 | year = "2019", 21 | issn = "0009-8981", 22 | doi = "https://doi.org/10.1016/j.cca.2019.08.004", 23 | url = "http://www.sciencedirect.com/science/article/pii/S0009898119319928", 24 | author = "Faye B. Vicente and David C. Lin and Shannon Haymond", 25 | keywords = "Mass spectrometry, Informatics, Quality", 26 | abstract = "Introduction 27 | Mass spectrometry-based assays have increasingly been implemented in clinical laboratories for their multiplexing capacity and high specificity and sensitivity. However, these methods are often associated with labor-intensive and error-prone data-related workflows, due to the volume of data generated that is often manually reviewed and resulted. We aimed to establish a system within our clinical mass spectrometry laboratory to facilitate data ‘flow’ from electronic medical record order to result and to automate processes for chromatogram peak review. The processes and validation are described for a 25-hydroxyvitamin D assay. 28 | Methods 29 | Automating chromatogram review and order to result data transfer required flat file interfacing, file transfers of standardized data formats, barcode scanning, and software for peak processing and review. Validation of the automated workflow involved (1) correlation of quantified results generated by two chromatogram analysis methods: Waters TargetLynx and Indigo Bioautomation ASCENT, (2) manual verification of quality assurance flags applied in ASCENT, and (3) testing data flow and integrity across all the systems from order to result. Efficiency and quality improvements were assessed through calculation of batch review times and rates for autoverification and manual manipulations. 30 | Results 31 | The correlation of TargetLynx and ASCENT quantitation methods for 25-hydroxyvitamin D2 in patient samples yielded slope of 0.99 (95% CI: 0.989 to 0.996), intercept of 0.46 (95% CI: 0.363 to 0.565), with r = 0.999. The correlation for the D3 fraction showed Deming regression slope of 0.98 (95% CI: 0.969 to 0.989), intercept of 0.06 (95% CI: −0.115 to 0.313), and r = 0.995. Results from both quantitation approaches were also compared to the assigned value in CDC reference samples. The mean bias relative to the CDC was 4.6% for ASCENT and 2.5% for TargetLynx. The median time for chromatogram review of a full 96-well plate of vitamin D results is reduced from approximately 2 h to 14 min and 80% of batches were reviewed within 30 min. Instead of 100% peak review, technologists review only the peaks that have been flagged by the system based on applied rules. Analysis of full plate batches showed that 2–20% of peaks per batch were flagged for manual review. Manipulations made by technologists during chromatogram review were reduced by 75% when using the automated versus manual system. 32 | Conclusions 33 | We describe a system to facilitate data ‘flow’ from electronic order to result and to automate chromatogram peak review in a clinical liquid chromatography mass spectrometry assay for 25-hydroxyvitamin D. This eliminated manual result entry, repetitive transcription, and unnecessary review of high quality data while enabling systematic evaluation of data quality indicators. The new processes were accurate, improved the data review and processing times, and helped to reduce manual manipulations during chromatogram review." 34 | } 35 | 36 | @article{10.1371/journal.pcbi.1003285, 37 | author = {Sandve, Geir Kjetil AND Nekrutenko, Anton AND Taylor, James AND Hovig, Eivind}, 38 | journal = {PLOS Computational Biology}, 39 | publisher = {Public Library of Science}, 40 | title = {Ten Simple Rules for Reproducible Computational Research}, 41 | year = {2013}, 42 | month = {10}, 43 | volume = {9}, 44 | url = {https://doi.org/10.1371/journal.pcbi.1003285}, 45 | pages = {1-4}, 46 | abstract = {}, 47 | number = {10}, 48 | doi = {10.1371/journal.pcbi.1003285} 49 | } 50 | 51 | @article{peng2011reproducible, 52 | title={Reproducible research in computational science}, 53 | author={Peng, Roger D}, 54 | journal={Science}, 55 | volume={334}, 56 | number={6060}, 57 | pages={1226--1227}, 58 | year={2011}, 59 | publisher={American Association for the Advancement of Science} 60 | } 61 | 62 | @book{xie2018r, 63 | title={R markdown: The definitive guide}, 64 | author={Xie, Yihui and Allaire, Joseph J and Grolemund, Garrett}, 65 | year={2018}, 66 | publisher={Chapman and Hall/CRC}, 67 | url={https://bookdown.org/yihui/bookdown} 68 | } -------------------------------------------------------------------------------- /Template_LaTeX.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: | 3 | RMarkdown Template for Managing 4 | Academic Affiliations 5 | subtitle: | 6 | Also Deals with Cross References and 7 | Reference Abbreviations for PDF Output 8 | author: 9 | - name: Duke A Caboom, MD 10 | affiliation: University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada 11 | email: dtholmes@mail.ubc.ca 12 | number: 1 13 | - name: Justin d'Ottawa, PhD 14 | affiliation: University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 15 | email: justin@uottawa.ca 16 | number: 2 17 | abstract: | 18 | **Introduction**: There's a big scientific problem out there. I know how to fix it. 19 | 20 | **Methods**: My experiments are pure genius. 21 | 22 | **Results**: Now you have your proof. 23 | 24 | **Conclusion**: Give me more grant money. 25 | toc: false 26 | output: 27 | bookdown::pdf_document2: 28 | pandoc_args: 29 | - --filter=pandoc-crossref 30 | - --csl=Extras/clinical-mass-spectrometry.csl 31 | - --citation-abbreviations=Extras/abbreviations.json 32 | - --template=Extras/mytemplate.tex 33 | keep_tex: true 34 | bibliography: "Extras/mybibfile.bib" 35 | --- 36 | 37 | ```{r setup, include=FALSE} 38 | knitr::opts_chunk$set(echo = TRUE, fig.align = "center", out.width = "5in", out.height = "4in") 39 | ``` 40 | 41 | # Background 42 | 43 | I like writing my academic papers in RMarkdown because it allows reproducible research. The cleanest way to submit a manuscript made in RMarkdown is using the LaTeX code that it generates using the YAML switch `keep_tex = true`. A minimalist YAML header would look like so: 44 | 45 | ``` 46 | --- 47 | title: The document title 48 | author: 49 | - Duke A Caboom, MD 50 | - Justin d'Ottawa, PhD: 51 | output: 52 | pdf_document: 53 | keep_tex: true 54 | --- 55 | ``` 56 | # Introduction 57 | 58 | However, when you want mutliple authors affiliations you discover that you can't do as you would in LaTeX because [Pandoc]() does not know what to do with the affiliations and you end out a dishearting PDF that looks like the output shown in figure \@ref(fig:sosad) below: 59 | 60 | ```{r sosad, echo=FALSE, fig.cap="This is so sad.", fig.align="center"} 61 | knitr::include_graphics("Images/badheader.png") 62 | library(png) 63 | ``` 64 | 65 | The situation worsens if you want MS-Word output. As those of us in medical fields know, most journals, with some notable exceptions like the [Clinical Mass Spectrometry Journal](https://www.journals.elsevier.com/clinical-mass-spectrometry) and other Elsevier journals like [Clinical Biochemistry](https://www.journals.elsevier.com/clinical-biochemistry) and [Clinica Chimica Acta](https://www.journals.elsevier.com/clinica-chimica-acta), require submission of a document in MS-Word format which goes against all that Data Science and Reprodicible Research stands for. Parenthetically, it is my hope that since [AACC](www.aacc.org) has indicated to make Data Science a strategic priority for Lab Medicine, that they will soon accept submissons to [Clinical Chemistry](http://clinchem.aaccjnls.org/) and [Journal of Applied Laboratory Medicine](http://jalm.aaccjnls.org/) written reproducibly in RMardown or LaTeX. 66 | 67 | In the mean time, here are the workarounds for getting the affiliations to display correctly along with all the other stuff we want, namely, cross referencing of figures and tables and correct reference formatting and abbreviation of journal names. This allows you to avoid the horror of manually fixing your Word document after it generated from RMarkdown. In any case, let's start with MS-Word. 68 | 69 | # Dependencies for MS-Word and the Associated YAML 70 | 71 | It goes without saying that you need to install LaTeX. LaTeX markup language is available here: [Mac](http://www.tug.org/mactex/), [Windows](https://miktex.org/download). For Linux, just install from the command line with your package manager. Do a full install with all the glorious bloat of all LaTeX packages. This saves many headaches in the future. 72 | 73 | You will also need to install [Pandoc](https://pandoc.org/) which is the Swiss Army Knife of document conversion. It's going to turn LaTeX code into a .docx file for you. Mac users can do this with Homebrew on the terminal command line: 74 | 75 | ``` 76 | brew install pandoc 77 | brew install pandoc-citeproc 78 | brew install pandoc-crossref 79 | ``` 80 | 81 | There are some extra installs required to help Pandoc do its job. Install the prebuilt binaries if you can. 82 | 83 | + [pandoc-citeproc](http://hackage.haskell.org/package/pandoc-citeproc) 84 | + [pandoc-crossref](https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.3.4.1a) 85 | 86 | Finally, you need to use some scripts written in the Lua scripting language which means you will need the language itself: 87 | + [lua language](https://www.lua.org/download.html) 88 | 89 | And you will need two Lua scripts: 90 | 91 | These are in Pandoc github repository: 92 | 93 | + [scholarly-metadata.lua](https://github.com/pandoc/lua-filters/tree/master/scholarly-metadata) 94 | + [author-info-blocks.lua](https://github.com/pandoc/lua-filters/tree/master/author-info-blocks) 95 | 96 | You want the files named [scholarly-metadata.lua](https://raw.githubusercontent.com/pandoc/lua-filters/master/scholarly-metadata/scholarly-metadata.lua) and [author-info-blocks.lua](https://raw.githubusercontent.com/pandoc/lua-filters/master/author-info-blocks/author-info-blocks.lua). 97 | 98 | You will need to choose a .csl file for your journal. This will tell Pandoc how to format the references. You can download the correct .csl file [here](https://www.zotero.org/styles). You will also need a journal abbreviations database. I have made one for you from the [Web of Science list](https://images.webofknowledge.com/images/help/WOS/A_abrvjt.html) and you can download it [here](https://github.com/drdanholmes/Affiliations/blob/master/Extras/abbreviations.json). 99 | 100 | You will need to creat a .bibtex database which is just your list of references. This can be exported from various reference managers or built by hand. Name the file `mybibfile.bib`. 101 | 102 | Now follow the bouncing ball: 103 | 104 | 1. Go to the directory containing your .Rmd file. 105 | 2. Create a directory in it called "Extras" 106 | 3. Put the two Lua scripts, the Bibtex database, the abbreviations database and the .csl file into the "Extras" folder. 107 | 4. If you want to avoid Pandoc's goofy default .docx formatting, then put [this word document](https://github.com/drdanholmes/Affiliations/blob/master/Extras/Reference_Document.docx) in the same folder. 108 | 109 | OR 110 | 111 | Download [the contents of this folder](https://github.com/drdanholmes/Affiliations) from my github folder that has everything set up as I describe above. 112 | 113 | For two authors, your YAML will need to look like this: 114 | 115 | ``` 116 | title: | 117 | RMarkdown Template for Managing 118 | Academic Affiliations 119 | subtitle: | 120 | Also Deals with Cross References and 121 | Reference Abbreviations for MS-Word Output 122 | author: 123 | - Duke A Caboom, MD: 124 | email: duke.a.caboom@utuktoyaktuk.edu 125 | institute: [UofT] 126 | correspondence: true 127 | - Justin d'Ottawa, PhD: 128 | email: justin@neverready.ca 129 | institute: [UofO] 130 | correspondence: false 131 | institute: 132 | - UofT: University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada 133 | - UofO: University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 134 | abstract: | 135 | **Introduction**: There's a big scientific problem out there. I know how to fix it. 136 | **Methods**: My experiments are pure genius. 137 | **Results**: Now you have your proof. 138 | **Conclusion**: Give me more grant money. 139 | journal: "An awesome journal" 140 | date: "" 141 | toc: false 142 | output: 143 | bookdown::word_document2: 144 | pandoc_args: 145 | - --csl=Extras/clinical-biochemistry.csl 146 | - --citation-abbreviations=Extras/abbreviations.json 147 | - --filter=pandoc-crossref 148 | - --lua-filter=Extras/scholarly-metadata.lua 149 | - --lua-filter=Extras/author-info-blocks.lua 150 | - --reference-doc=Extras/Reference_Document.docx 151 | bibliography: "Extras/mybibfile.bib" 152 | keywords: "CRAN, R, RMarkdown, RStudio, YAML" 153 | ``` 154 | 155 | Et voila! Figure \@ref(fig:sohappy) shows that we have something reasonable. 156 | 157 | ```{r sohappy, echo=FALSE, fig.cap="This is so great", fig.align="center"} 158 | knitr::include_graphics("Images/goodheader.png") 159 | ``` 160 | 161 | # Dependencies for LaTeX and the Associated YAML 162 | 163 | You don't need the lua scripts for LaTeX although you *can* use them. The issue with LaTeX is that the .tex template that Pandoc uses for generating LaTeX files does not support author affiliations as descibed [in the Pandoc documentation](https://pandoc.org/MANUAL.html). So what you need to do is modify the Pandoc LaTeX template. To get your current working copy of the Pandoc LaTeX template open up a terminal (Mac/Linux) and type: 164 | 165 | ``` 166 | pandoc -D latex > mytemplate.tex 167 | ``` 168 | 169 | This will push the contents to a file. Move the file to the "Extras" folder discussed above. If that seems difficult, you can also download it [here](https://github.com/jgm/pandoc-templates/blob/master/default.latex). Now you have to edit it. Open it up in a text editor and find the section that reads: 170 | 171 | ``` 172 | $if(author)$ 173 | \author{$for(author)$$author$$sep$ \and $endfor$} 174 | $endif$ 175 | ``` 176 | Replace this with this code that will invoke the LaTeX [authblk](https://www.ctan.org/pkg/authblk) package. 177 | 178 | ``` 179 | $if(author)$ 180 | \usepackage{authblk} 181 | $for(author)$ 182 | $if(author.name)$ 183 | $if(author.number)$ 184 | \author[$author.number$]{$author.name$} 185 | $else$ 186 | \author[]{$author.name$} 187 | $endif$ 188 | $if(author.affiliation)$ 189 | $if(author.email)$ 190 | \affil{$author.affiliation$ \thanks{$author.email$}} 191 | $else$ 192 | \affil{$author.affiliation$} 193 | $endif$ 194 | $endif$ 195 | $else$ 196 | \author{$author$} 197 | $endif$ 198 | $endfor$ 199 | $endif$ 200 | ``` 201 | 202 | Then make your YAML header look like this: 203 | 204 | ``` 205 | --- 206 | title: | 207 | RMarkdown Template for Managing 208 | Academic Affiliations 209 | subtitle: | 210 | Also Deals with Cross References and 211 | Reference Abbreviations for PDF Output 212 | author: 213 | - name: Duke A Caboom, MD 214 | affiliation: University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada 215 | email: dtholmes@mail.ubc.ca 216 | number: 1 217 | - name: Justin d'Ottawa, PhD 218 | affiliation: University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 219 | email: justin@neverready.ca 220 | number: 2 221 | abstract: | 222 | **Introduction**: There's a big scientific problem out there. I know how to fix it. 223 | 224 | **Methods**: My experiments are pure genius. 225 | 226 | **Results**: Now you have your proof. 227 | 228 | **Conclusion**: Give me more grant money. 229 | toc: false 230 | output: 231 | bookdown::pdf_document2: 232 | pandoc_args: 233 | - --filter=pandoc-crossref 234 | - --csl=Extras/clinical-biochemistry.csl 235 | - --citation-abbreviations=Extras/abbreviations.json 236 | - --template=Extras/mytemplate.tex 237 | bibliography: "Extras/mybibfile.bib" 238 | keep-latex: true 239 | ``` 240 | 241 | And as you can see in \@ref(fig:sohappylatex) you get a correctly list of authors. 242 | 243 | ```{r sohappylatex, echo=FALSE, fig.cap="This is also great.", fig.align="center"} 244 | knitr::include_graphics("Images/goodheaderlatex.png") 245 | ``` 246 | 247 | ## Cross Reference of a Table 248 | 249 | Of course, tables can be cross referenced in the same manner as figures. Here is a cross reference to table \@ref(tab:mytable) using the code `\@ref(tab:mytable)` . 250 | 251 | ```{r mytable, echo = FALSE} 252 | library(broom) 253 | mod <- lm(mpg ~ hp + cyl, data = mtcars) 254 | knitr::kable(tidy(mod), digits = 3, booktabs = TRUE, caption = "A short table") 255 | ``` 256 | 257 | ## This Template also Takes Care of Reference Abbreviation. 258 | 259 | As usual, you can make a citation with the code `[@bibtexname]`, where `bibtexname` is the articles's abbreviated handle in your bibtex database. Here is a great resource on the bookdown package [@xie2018r] and reproducible research [@peng2011reproducible] and here are references where the journal title is longer [@EISENHOFER201940; @VICENTE201984]. The references in your documnent (and shown below) will have appropriate abbreviations based on the .json abbreviations database I have provided. In this case, I have chosen the .csl file for Clinical Mass Spectrometry--'cause [MSACL](https://www.msacl.org/). 260 | 261 | 262 | 263 | # Other Ways to Skin the YAML Cat 264 | 265 | I came across some other ways to deal with this that I did not like as much but they are simpler. Here is one using a footnote. 266 | 267 | ``` 268 | title: The document title 269 | author: 270 | - [Duke A Caboom, MD]^(University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada) 271 | - [Justin d'Ottawa, PhD]^(University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada) 272 | output: pdf_document 273 | ``` 274 | 275 | And you can also misuse the `date` variable: 276 | 277 | ``` 278 | title: The document title 279 | author: 280 | - Duke A Caboom, MD [1] 281 | - Justin d'Ottawa, PhD [2] 282 | date: 1. University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada \newline 2. University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 283 | output: pdf_document 284 | ``` 285 | 286 | # Conclusion 287 | 288 | This concludes my long personal struggle to get a completely reproducible .docx manusript genereated by RMardown and Pandoc. 289 | 290 | ## Parting Thought 291 | 292 | **Let us not become weary in doing good, for at the proper time we will reap a harvest if we do not give up.** 293 | 294 | **Galations 6:9** 295 | 296 | # References 297 | -------------------------------------------------------------------------------- /Template_Word.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: | 3 | RMarkdown Template for Managing 4 | Academic Affiliations 5 | subtitle: | 6 | Also Deals with Cross References and 7 | Reference Abbreviations for MS-Word Output 8 | author: 9 | - Duke A Caboom, MD: 10 | email: duke.a.caboom@utuktoyaktuk.edu 11 | institute: [UofT] 12 | correspondence: true 13 | - Justin d'Ottawa, PhD: 14 | email: justin@uottawa.ca 15 | institute: [UofO] 16 | correspondence: false 17 | institute: 18 | - UofT: University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada 19 | - UofO: University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 20 | abstract: | 21 | **Introduction**: There's a big scientific problem out there. I know how to fix it. 22 | 23 | **Methods**: My experiments are pure genius. 24 | 25 | **Results**: Now you have your proof. 26 | 27 | **Conclusion**: Give me more grant money. 28 | journal: "An awesome journal" 29 | date: "" 30 | toc: false 31 | output: 32 | bookdown::word_document2: 33 | pandoc_args: 34 | - --csl=Extras/clinical-mass-spectrometry.csl 35 | - --citation-abbreviations=Extras/abbreviations.json 36 | - --filter=pandoc-crossref 37 | - --lua-filter=Extras/scholarly-metadata.lua 38 | - --lua-filter=Extras/author-info-blocks.lua 39 | - --reference-doc=Extras/Reference_Document.docx 40 | bookdown::pdf_document2: 41 | pandoc_args: 42 | - --csl=Extras/clinical-mass-spectrometry.csl 43 | - --citation-abbreviations=Extras/abbreviations.json 44 | - --filter=pandoc-crossref 45 | - --lua-filter=Extras/scholarly-metadata.lua 46 | - --lua-filter=Extras/author-info-blocks.lua 47 | bibliography: "Extras/mybibfile.bib" 48 | keywords: "CRAN, R, RMarkdown, RStudio, YAML" 49 | --- 50 | # Background 51 | 52 | I like writing my academic papers in RMarkdown because it allows reproducible research. The cleanest way to submit a manuscript made in RMarkdown is using the LaTeX code that it generates using the YAML switch `keep_tex = true`. A minimalist YAML header would look like so: 53 | 54 | ``` 55 | --- 56 | title: The document title 57 | author: 58 | - Duke A Caboom, MD 59 | - Justin d'Ottawa, PhD: 60 | output: 61 | pdf_document: 62 | keep_tex: true 63 | --- 64 | ``` 65 | # Introduction 66 | 67 | However, when you want mutliple authors affiliations you discover that you can't do as you would in LaTeX because [Pandoc]() does not know what to do with the affiliations and you end out a dishearting PDF that looks like the output shown in figure \@ref(fig:sosad) below: 68 | 69 | ```{r sosad, echo=FALSE, fig.cap="This is so sad.", fig.align="center"} 70 | knitr::include_graphics("Images/badheader.png") 71 | library(png) 72 | ``` 73 | 74 | The situation worsens if you want MS-Word output. As those of us in medical fields know, most journals, with some notable exceptions like the [Clinical Mass Spectrometry Journal](https://www.journals.elsevier.com/clinical-mass-spectrometry) and other Elsevier journals like [Clinical Biochemistry](https://www.journals.elsevier.com/clinical-biochemistry) and [Clinica Chimica Acta](https://www.journals.elsevier.com/clinica-chimica-acta), require submission of a document in MS-Word format which goes against all that Data Science and Reprodicible Research stands for. Parenthetically, it is my hope that since [AACC](www.aacc.org) has indicated to make Data Science a strategic priority for Lab Medicine, that they will soon accept submissons to [Clinical Chemistry](http://clinchem.aaccjnls.org/) and [Journal of Applied Laboratory Medicine](http://jalm.aaccjnls.org/) written reproducibly in RMardown or LaTeX. 75 | 76 | In the mean time, here are the workarounds for getting the affiliations to display correctly along with all the other stuff we want, namely, cross referencing of figures and tables and correct reference formatting and abbreviation of journal names. This allows you to avoid the horror of manually fixing your Word document after it generated from RMarkdown. In any case, let's start with MS-Word. 77 | 78 | # Dependencies for MS-Word and the Associated YAML 79 | 80 | It goes without saying that you need to install LaTeX. LaTeX markup language is available here: [Mac](http://www.tug.org/mactex/), [Windows](https://miktex.org/download). For Linux, just install from the command line with your package manager. Do a full install with all the glorious bloat of all LaTeX packages. This saves many headaches in the future. 81 | 82 | You will also need to install [Pandoc](https://pandoc.org/) which is the Swiss Army Knife of document conversion. It's going to turn LaTeX code into a .docx file for you. Mac users can do this with Homebrew on the terminal command line: 83 | 84 | ``` 85 | brew install pandoc 86 | brew install pandoc-citeproc 87 | brew install pandoc-crossref 88 | ``` 89 | 90 | There are some extra installs required to help Pandoc do its job. Install the prebuilt binaries if you can. 91 | 92 | + [pandoc-citeproc](http://hackage.haskell.org/package/pandoc-citeproc) 93 | + [pandoc-crossref](https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.3.4.1a) 94 | 95 | Finally, you need to use some scripts written in the Lua scripting language which means you will need the language itself: 96 | + [lua language](https://www.lua.org/download.html) 97 | 98 | And you will need two Lua scripts: 99 | 100 | These are in Pandoc github repository: 101 | 102 | + [scholarly-metadata.lua](https://github.com/pandoc/lua-filters/tree/master/scholarly-metadata) 103 | + [author-info-blocks.lua](https://github.com/pandoc/lua-filters/tree/master/author-info-blocks) 104 | 105 | You want the files named [scholarly-metadata.lua](https://raw.githubusercontent.com/pandoc/lua-filters/master/scholarly-metadata/scholarly-metadata.lua) and [author-info-blocks.lua](https://raw.githubusercontent.com/pandoc/lua-filters/master/author-info-blocks/author-info-blocks.lua). 106 | 107 | You will need to choose a .csl file for your journal. This will tell Pandoc how to format the references. You can download the correct .csl file [here](https://www.zotero.org/styles). You will also need a journal abbreviations database. I have made one for you from the [Web of Science list](https://images.webofknowledge.com/images/help/WOS/A_abrvjt.html) and you can download it [here](https://github.com/drdanholmes/Affiliations/blob/master/Extras/abbreviations.json). 108 | 109 | You will need to creat a .bibtex database which is just your list of references. This can be exported from various reference managers or built by hand. Name the file `mybibfile.bib`. 110 | 111 | Now follow the bouncing ball: 112 | 113 | 1. Go to the directory containing your .Rmd file. 114 | 2. Create a directory in it called "Extras" 115 | 3. Put the two Lua scripts, the Bibtex database, the abbreviations database and the .csl file into the "Extras" folder. 116 | 4. If you want to avoid Pandoc's goofy default .docx formatting, then put [this word document](https://github.com/drdanholmes/Affiliations/blob/master/Extras/Reference_Document.docx) in the same folder. 117 | 118 | OR 119 | 120 | Download [the contents of this folder](https://github.com/drdanholmes/Affiliations) from my github folder that has everything set up as I describe above. 121 | 122 | For two authors, your YAML will need to look like this: 123 | 124 | ``` 125 | title: | 126 | RMarkdown Template for Managing 127 | Academic Affiliations 128 | subtitle: | 129 | Also Deals with Cross References and 130 | Reference Abbreviations for MS-Word Output 131 | author: 132 | - Duke A Caboom, MD: 133 | email: duke.a.caboom@utuktoyaktuk.edu 134 | institute: [UofT] 135 | correspondence: true 136 | - Justin d'Ottawa, PhD: 137 | email: justin@neverready.ca 138 | institute: [UofO] 139 | correspondence: false 140 | institute: 141 | - UofT: University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada 142 | - UofO: University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 143 | abstract: | 144 | **Introduction**: There's a big scientific problem out there. I know how to fix it. 145 | **Methods**: My experiments are pure genius. 146 | **Results**: Now you have your proof. 147 | **Conclusion**: Give me more grant money. 148 | journal: "An awesome journal" 149 | date: "" 150 | toc: false 151 | output: 152 | bookdown::word_document2: 153 | pandoc_args: 154 | - --csl=Extras/clinical-biochemistry.csl 155 | - --citation-abbreviations=Extras/abbreviations.json 156 | - --filter=pandoc-crossref 157 | - --lua-filter=Extras/scholarly-metadata.lua 158 | - --lua-filter=Extras/author-info-blocks.lua 159 | - --reference-doc=Extras/Reference_Document.docx 160 | bibliography: "Extras/mybibfile.bib" 161 | keywords: "CRAN, R, RMarkdown, RStudio, YAML" 162 | ``` 163 | 164 | Et voila! Figure \@ref(fig:sohappy) shows that we have something reasonable. 165 | 166 | ```{r sohappy, echo=FALSE, fig.cap="This is so great", fig.align="center"} 167 | knitr::include_graphics("Images/goodheader.png") 168 | ``` 169 | 170 | # Dependencies for LaTeX and the Associated YAML 171 | 172 | You don't need the lua scripts for LaTeX although you *can* use them. The issue with LaTeX is that the .tex template that Pandoc uses for generating LaTeX files does not support author affiliations as descibed [in the Pandoc documentation](https://pandoc.org/MANUAL.html). So what you need to do is modify the Pandoc LaTeX template. To get your current working copy of the Pandoc LaTeX template open up a terminal (Mac/Linux) and type: 173 | 174 | ``` 175 | pandoc -D latex > mytemplate.tex 176 | ``` 177 | 178 | This will push the contents to a file. Move the file to the "Extras" folder discussed above. If that seems difficult, you can also download it [here](https://github.com/jgm/pandoc-templates/blob/master/default.latex). Now you have to edit it. Open it up in a text editor and find the section that reads: 179 | 180 | ``` 181 | $if(author)$ 182 | \author{$for(author)$$author$$sep$ \and $endfor$} 183 | $endif$ 184 | ``` 185 | Replace this with this code that will invoke the LaTeX [authblk](https://www.ctan.org/pkg/authblk) package. 186 | 187 | ``` 188 | $if(author)$ 189 | \usepackage{authblk} 190 | $for(author)$ 191 | $if(author.name)$ 192 | $if(author.number)$ 193 | \author[$author.number$]{$author.name$} 194 | $else$ 195 | \author[]{$author.name$} 196 | $endif$ 197 | $if(author.affiliation)$ 198 | $if(author.email)$ 199 | \affil{$author.affiliation$ \thanks{$author.email$}} 200 | $else$ 201 | \affil{$author.affiliation$} 202 | $endif$ 203 | $endif$ 204 | $else$ 205 | \author{$author$} 206 | $endif$ 207 | $endfor$ 208 | $endif$ 209 | ``` 210 | 211 | Then make your YAML header look like this: 212 | 213 | ``` 214 | --- 215 | title: | 216 | RMarkdown Template for Managing 217 | Academic Affiliations 218 | subtitle: | 219 | Also Deals with Cross References and 220 | Reference Abbreviations for PDF Output 221 | author: 222 | - name: Duke A Caboom, MD 223 | affiliation: University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada 224 | email: dtholmes@mail.ubc.ca 225 | number: 1 226 | - name: Justin d'Ottawa, PhD 227 | affiliation: University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 228 | email: justin@neverready.ca 229 | number: 2 230 | abstract: | 231 | **Introduction**: There's a big scientific problem out there. I know how to fix it. 232 | 233 | **Methods**: My experiments are pure genius. 234 | 235 | **Results**: Now you have your proof. 236 | 237 | **Conclusion**: Give me more grant money. 238 | toc: false 239 | output: 240 | bookdown::pdf_document2: 241 | pandoc_args: 242 | - --filter=pandoc-crossref 243 | - --csl=Extras/clinical-biochemistry.csl 244 | - --citation-abbreviations=Extras/abbreviations.json 245 | - --template=Extras/mytemplate.tex 246 | bibliography: "Extras/mybibfile.bib" 247 | keep-latex: true 248 | ``` 249 | 250 | And as you can see in \@ref(fig:sohappylatex) you get a correctly list of authors. 251 | 252 | ```{r sohappylatex, echo=FALSE, fig.cap="This is also great.", fig.align="center"} 253 | knitr::include_graphics("Images/goodheaderlatex.png") 254 | ``` 255 | 256 | ## Cross Reference of a Table 257 | 258 | Of course, tables can be cross referenced in the same manner as figures. Here is a cross reference to table \@ref(tab:mytable) using the code `\@ref(tab:mytable)` . 259 | 260 | ```{r mytable, echo = FALSE} 261 | library(broom) 262 | mod <- lm(mpg ~ hp + cyl, data = mtcars) 263 | knitr::kable(tidy(mod), digits = 3, booktabs = TRUE, caption = "A short table") 264 | ``` 265 | 266 | ## This Template also Takes Care of Reference Abbreviation. 267 | 268 | As usual, you can make a citation with the code `[@bibtexname]`, where `bibtexname` is the articles's abbreviated handle in your bibtex database. Here is a great resource on the bookdown package [@xie2018r] and reproducible research [@peng2011reproducible] and here are references where the journal title is longer [@EISENHOFER201940; @VICENTE201984]. The references in your documnent (and shown below) will have appropriate abbreviations based on the .json abbreviations database I have provided. In this case, I have chosen the .csl file for Clinical Mass Spectrometry--'cause [MSACL](https://www.msacl.org/). 269 | 270 | 271 | 272 | # Other Ways to Skin the YAML Cat 273 | 274 | I came across some other ways to deal with this that I did not like as much but they are simpler. Here is one using a footnote. 275 | 276 | ``` 277 | title: The document title 278 | author: 279 | - [Duke A Caboom, MD]^(University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada) 280 | - [Justin d'Ottawa, PhD]^(University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada) 281 | output: pdf_document 282 | ``` 283 | 284 | And you can also misuse the `date` variable: 285 | 286 | ``` 287 | title: The document title 288 | author: 289 | - Duke A Caboom, MD [1] 290 | - Justin d'Ottawa, PhD [2] 291 | date: 1. University of Tuktoyaktuk, CXVG+62 Tuktoyaktuk, Inuvik, Unorganized, NT Canada \newline 2. University of Ottawa, 75 Laurier Ave E, Ottawa, ON K1N 6N5, Canada 292 | output: pdf_document 293 | ``` 294 | 295 | # Conclusion 296 | 297 | This concludes my long personal struggle to get a completely reproducible .docx manusript genereated by RMardown and Pandoc. 298 | 299 | ## Parting Thought 300 | 301 | **Let us not become weary in doing good, for at the proper time we will reap a harvest if we do not give up.** 302 | 303 | **Galations 6:9** 304 | 305 | # References 306 | -------------------------------------------------------------------------------- /Extras/mytemplate.tex: -------------------------------------------------------------------------------- 1 | % Options for packages loaded elsewhere 2 | \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} 3 | \PassOptionsToPackage{hyphens}{url} 4 | $if(colorlinks)$ 5 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} 6 | $endif$ 7 | $if(dir)$ 8 | $if(latex-dir-rtl)$ 9 | \PassOptionsToPackage{RTLdocument}{bidi} 10 | $endif$ 11 | $endif$ 12 | % 13 | \documentclass[ 14 | $if(fontsize)$ 15 | $fontsize$, 16 | $endif$ 17 | $if(lang)$ 18 | $babel-lang$, 19 | $endif$ 20 | $if(papersize)$ 21 | $papersize$paper, 22 | $endif$ 23 | $if(beamer)$ 24 | ignorenonframetext, 25 | $if(handout)$ 26 | handout, 27 | $endif$ 28 | $if(aspectratio)$ 29 | aspectratio=$aspectratio$, 30 | $endif$ 31 | $endif$ 32 | $for(classoption)$ 33 | $classoption$$sep$, 34 | $endfor$ 35 | ]{$documentclass$} 36 | $if(beamer)$ 37 | $if(background-image)$ 38 | \usebackgroundtemplate{% 39 | \includegraphics[width=\paperwidth]{$background-image$}% 40 | } 41 | $endif$ 42 | \usepackage{pgfpages} 43 | \setbeamertemplate{caption}[numbered] 44 | \setbeamertemplate{caption label separator}{: } 45 | \setbeamercolor{caption name}{fg=normal text.fg} 46 | \beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ 47 | $for(beameroption)$ 48 | \setbeameroption{$beameroption$} 49 | $endfor$ 50 | % Prevent slide breaks in the middle of a paragraph 51 | \widowpenalties 1 10000 52 | \raggedbottom 53 | $if(section-titles)$ 54 | \setbeamertemplate{part page}{ 55 | \centering 56 | \begin{beamercolorbox}[sep=16pt,center]{part title} 57 | \usebeamerfont{part title}\insertpart\par 58 | \end{beamercolorbox} 59 | } 60 | \setbeamertemplate{section page}{ 61 | \centering 62 | \begin{beamercolorbox}[sep=12pt,center]{part title} 63 | \usebeamerfont{section title}\insertsection\par 64 | \end{beamercolorbox} 65 | } 66 | \setbeamertemplate{subsection page}{ 67 | \centering 68 | \begin{beamercolorbox}[sep=8pt,center]{part title} 69 | \usebeamerfont{subsection title}\insertsubsection\par 70 | \end{beamercolorbox} 71 | } 72 | \AtBeginPart{ 73 | \frame{\partpage} 74 | } 75 | \AtBeginSection{ 76 | \ifbibliography 77 | \else 78 | \frame{\sectionpage} 79 | \fi 80 | } 81 | \AtBeginSubsection{ 82 | \frame{\subsectionpage} 83 | } 84 | $endif$ 85 | $endif$ 86 | $if(beamerarticle)$ 87 | \usepackage{beamerarticle} % needs to be loaded first 88 | $endif$ 89 | $if(fontfamily)$ 90 | \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} 91 | $else$ 92 | \usepackage{lmodern} 93 | $endif$ 94 | $if(linestretch)$ 95 | \usepackage{setspace} 96 | $endif$ 97 | \usepackage{amssymb,amsmath} 98 | \usepackage{ifxetex,ifluatex} 99 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 100 | \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} 101 | \usepackage[utf8]{inputenc} 102 | \usepackage{textcomp} % provide euro and other symbols 103 | \else % if luatex or xetex 104 | $if(mathspec)$ 105 | \ifxetex 106 | \usepackage{mathspec} 107 | \else 108 | \usepackage{unicode-math} 109 | \fi 110 | $else$ 111 | \usepackage{unicode-math} 112 | $endif$ 113 | \defaultfontfeatures{Scale=MatchLowercase} 114 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 115 | $if(mainfont)$ 116 | \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} 117 | $endif$ 118 | $if(sansfont)$ 119 | \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} 120 | $endif$ 121 | $if(monofont)$ 122 | \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} 123 | $endif$ 124 | $for(fontfamilies)$ 125 | \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} 126 | $endfor$ 127 | $if(mathfont)$ 128 | $if(mathspec)$ 129 | \ifxetex 130 | \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 131 | \else 132 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 133 | \fi 134 | $else$ 135 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 136 | $endif$ 137 | $endif$ 138 | $if(CJKmainfont)$ 139 | \ifxetex 140 | \usepackage{xeCJK} 141 | \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 142 | \fi 143 | $endif$ 144 | $if(luatexjapresetoptions)$ 145 | \ifluatex 146 | \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} 147 | \fi 148 | $endif$ 149 | $if(CJKmainfont)$ 150 | \ifluatex 151 | \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} 152 | \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 153 | \fi 154 | $endif$ 155 | \fi 156 | $if(beamer)$ 157 | $if(theme)$ 158 | \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} 159 | $endif$ 160 | $if(colortheme)$ 161 | \usecolortheme{$colortheme$} 162 | $endif$ 163 | $if(fonttheme)$ 164 | \usefonttheme{$fonttheme$} 165 | $endif$ 166 | $if(mainfont)$ 167 | \usefonttheme{serif} % use mainfont rather than sansfont for slide text 168 | $endif$ 169 | $if(innertheme)$ 170 | \useinnertheme{$innertheme$} 171 | $endif$ 172 | $if(outertheme)$ 173 | \useoutertheme{$outertheme$} 174 | $endif$ 175 | $endif$ 176 | % Use upquote if available, for straight quotes in verbatim environments 177 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 178 | \IfFileExists{microtype.sty}{% use microtype if available 179 | \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} 180 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 181 | }{} 182 | $if(indent)$ 183 | $else$ 184 | \makeatletter 185 | \@ifundefined{KOMAClassName}{% if non-KOMA class 186 | \IfFileExists{parskip.sty}{% 187 | \usepackage{parskip} 188 | }{% else 189 | \setlength{\parindent}{0pt} 190 | \setlength{\parskip}{6pt plus 2pt minus 1pt}} 191 | }{% if KOMA class 192 | \KOMAoptions{parskip=half}} 193 | \makeatother 194 | $endif$ 195 | $if(verbatim-in-note)$ 196 | \usepackage{fancyvrb} 197 | $endif$ 198 | \usepackage{xcolor} 199 | \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available 200 | \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} 201 | \hypersetup{ 202 | $if(title-meta)$ 203 | pdftitle={$title-meta$}, 204 | $endif$ 205 | $if(author-meta)$ 206 | pdfauthor={$author-meta$}, 207 | $endif$ 208 | $if(lang)$ 209 | pdflang={$lang$}, 210 | $endif$ 211 | $if(subject)$ 212 | pdfsubject={$subject$}, 213 | $endif$ 214 | $if(keywords)$ 215 | pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, 216 | $endif$ 217 | $if(colorlinks)$ 218 | colorlinks=true, 219 | linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, 220 | filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, 221 | citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, 222 | urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, 223 | $else$ 224 | hidelinks, 225 | $endif$ 226 | pdfcreator={LaTeX via pandoc}} 227 | \urlstyle{same} % disable monospaced font for URLs 228 | $if(verbatim-in-note)$ 229 | \VerbatimFootnotes % allow verbatim text in footnotes 230 | $endif$ 231 | $if(geometry)$ 232 | $if(beamer)$ 233 | \geometry{$for(geometry)$$geometry$$sep$,$endfor$} 234 | $else$ 235 | \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} 236 | $endif$ 237 | $endif$ 238 | $if(beamer)$ 239 | \newif\ifbibliography 240 | $endif$ 241 | $if(listings)$ 242 | \usepackage{listings} 243 | \newcommand{\passthrough}[1]{#1} 244 | \lstset{defaultdialect=[5.3]Lua} 245 | \lstset{defaultdialect=[x86masm]Assembler} 246 | $endif$ 247 | $if(lhs)$ 248 | \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} 249 | $endif$ 250 | $if(highlighting-macros)$ 251 | $highlighting-macros$ 252 | $endif$ 253 | $if(tables)$ 254 | \usepackage{longtable,booktabs} 255 | $if(beamer)$ 256 | \usepackage{caption} 257 | % Make caption package work with longtable 258 | \makeatletter 259 | \def\fnum@table{\tablename~\thetable} 260 | \makeatother 261 | $else$ 262 | % Correct order of tables after \paragraph or \subparagraph 263 | \usepackage{etoolbox} 264 | \makeatletter 265 | \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} 266 | \makeatother 267 | % Allow footnotes in longtable head/foot 268 | \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} 269 | \makesavenoteenv{longtable} 270 | $endif$ 271 | $endif$ 272 | $if(graphics)$ 273 | \usepackage{graphicx,grffile} 274 | \makeatletter 275 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 276 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 277 | \makeatother 278 | % Scale images if necessary, so that they will not overflow the page 279 | % margins by default, and it is still possible to overwrite the defaults 280 | % using explicit options in \includegraphics[width, height, ...]{} 281 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 282 | % Set default figure placement to htbp 283 | \makeatletter 284 | \def\fps@figure{htbp} 285 | \makeatother 286 | $endif$ 287 | $if(links-as-notes)$ 288 | % Make links footnotes instead of hotlinks: 289 | \DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} 290 | $endif$ 291 | $if(strikeout)$ 292 | \usepackage[normalem]{ulem} 293 | % Avoid problems with \sout in headers with hyperref 294 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 295 | $endif$ 296 | \setlength{\emergencystretch}{3em} % prevent overfull lines 297 | \providecommand{\tightlist}{% 298 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 299 | $if(numbersections)$ 300 | \setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} 301 | $else$ 302 | \setcounter{secnumdepth}{-\maxdimen} % remove section numbering 303 | $endif$ 304 | $if(beamer)$ 305 | $else$ 306 | $if(block-headings)$ 307 | % Make \paragraph and \subparagraph free-standing 308 | \ifx\paragraph\undefined\else 309 | \let\oldparagraph\paragraph 310 | \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} 311 | \fi 312 | \ifx\subparagraph\undefined\else 313 | \let\oldsubparagraph\subparagraph 314 | \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} 315 | \fi 316 | $endif$ 317 | $endif$ 318 | $if(pagestyle)$ 319 | \pagestyle{$pagestyle$} 320 | $endif$ 321 | $for(header-includes)$ 322 | $header-includes$ 323 | $endfor$ 324 | $if(lang)$ 325 | \ifxetex 326 | % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) 327 | \usepackage{polyglossia} 328 | \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$} 329 | $for(polyglossia-otherlangs)$ 330 | \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} 331 | $endfor$ 332 | \else 333 | \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} 334 | $if(babel-newcommands)$ 335 | $babel-newcommands$ 336 | $endif$ 337 | \fi 338 | $endif$ 339 | $if(dir)$ 340 | \ifxetex 341 | % Load bidi as late as possible as it modifies e.g. graphicx 342 | \usepackage{bidi} 343 | \fi 344 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 345 | \TeXXeTstate=1 346 | \newcommand{\RL}[1]{\beginR #1\endR} 347 | \newcommand{\LR}[1]{\beginL #1\endL} 348 | \newenvironment{RTL}{\beginR}{\endR} 349 | \newenvironment{LTR}{\beginL}{\endL} 350 | \fi 351 | $endif$ 352 | $if(natbib)$ 353 | \usepackage[$natbiboptions$]{natbib} 354 | \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} 355 | $endif$ 356 | $if(biblatex)$ 357 | \usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} 358 | $for(bibliography)$ 359 | \addbibresource{$bibliography$} 360 | $endfor$ 361 | $endif$ 362 | 363 | $if(title)$ 364 | \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} 365 | $endif$ 366 | $if(subtitle)$ 367 | $if(beamer)$ 368 | $else$ 369 | \usepackage{etoolbox} 370 | \makeatletter 371 | \providecommand{\subtitle}[1]{% add subtitle to \maketitle 372 | \apptocmd{\@title}{\par {\large #1 \par}}{}{} 373 | } 374 | \makeatother 375 | $endif$ 376 | \subtitle{$subtitle$} 377 | $endif$ 378 | 379 | %$if(author)$ 380 | %\author{$for(author)$$author$$sep$ \and $endfor$} 381 | %$endif$ 382 | 383 | $if(author)$ 384 | \usepackage{authblk} 385 | $for(author)$ 386 | $if(author.name)$ 387 | $if(author.number)$ 388 | \author[$author.number$]{$author.name$} 389 | $else$ 390 | \author[]{$author.name$} 391 | $endif$ 392 | $if(author.affiliation)$ 393 | $if(author.email)$ 394 | \affil{$author.affiliation$ \thanks{$author.email$}} 395 | $else$ 396 | \affil{$author.affiliation$} 397 | $endif$ 398 | $endif$ 399 | $else$ 400 | \author{$author$} 401 | $endif$ 402 | $endfor$ 403 | $endif$ 404 | 405 | \date{$date$} 406 | $if(beamer)$ 407 | $if(institute)$ 408 | \institute{$for(institute)$$institute$$sep$ \and $endfor$} 409 | $endif$ 410 | $if(titlegraphic)$ 411 | \titlegraphic{\includegraphics{$titlegraphic$}} 412 | $endif$ 413 | $if(logo)$ 414 | \logo{\includegraphics{$logo$}} 415 | $endif$ 416 | $endif$ 417 | 418 | \begin{document} 419 | $if(has-frontmatter)$ 420 | \frontmatter 421 | $endif$ 422 | $if(title)$ 423 | $if(beamer)$ 424 | \frame{\titlepage} 425 | $else$ 426 | \maketitle 427 | $endif$ 428 | $if(abstract)$ 429 | \begin{abstract} 430 | $abstract$ 431 | \end{abstract} 432 | $endif$ 433 | $endif$ 434 | 435 | $for(include-before)$ 436 | $include-before$ 437 | 438 | $endfor$ 439 | $if(toc)$ 440 | $if(toc-title)$ 441 | \renewcommand*\contentsname{$toc-title$} 442 | $endif$ 443 | $if(beamer)$ 444 | \begin{frame} 445 | $if(toc-title)$ 446 | \frametitle{$toc-title$} 447 | $endif$ 448 | \tableofcontents[hideallsubsections] 449 | \end{frame} 450 | $else$ 451 | { 452 | $if(colorlinks)$ 453 | \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} 454 | $endif$ 455 | \setcounter{tocdepth}{$toc-depth$} 456 | \tableofcontents 457 | } 458 | $endif$ 459 | $endif$ 460 | $if(lot)$ 461 | \listoftables 462 | $endif$ 463 | $if(lof)$ 464 | \listoffigures 465 | $endif$ 466 | $if(linestretch)$ 467 | \setstretch{$linestretch$} 468 | $endif$ 469 | $if(has-frontmatter)$ 470 | \mainmatter 471 | $endif$ 472 | $body$ 473 | 474 | $if(has-frontmatter)$ 475 | \backmatter 476 | $endif$ 477 | $if(natbib)$ 478 | $if(bibliography)$ 479 | $if(biblio-title)$ 480 | $if(has-chapters)$ 481 | \renewcommand\bibname{$biblio-title$} 482 | $else$ 483 | \renewcommand\refname{$biblio-title$} 484 | $endif$ 485 | $endif$ 486 | $if(beamer)$ 487 | \begin{frame}[allowframebreaks]{$biblio-title$} 488 | \bibliographytrue 489 | $endif$ 490 | \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} 491 | $if(beamer)$ 492 | \end{frame} 493 | $endif$ 494 | 495 | $endif$ 496 | $endif$ 497 | $if(biblatex)$ 498 | $if(beamer)$ 499 | \begin{frame}[allowframebreaks]{$biblio-title$} 500 | \bibliographytrue 501 | \printbibliography[heading=none] 502 | \end{frame} 503 | $else$ 504 | \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ 505 | $endif$ 506 | 507 | $endif$ 508 | $for(include-after)$ 509 | $include-after$ 510 | 511 | $endfor$ 512 | \end{document} 513 | --------------------------------------------------------------------------------