-
Notifications
You must be signed in to change notification settings - Fork 525
/
Copy patharticle.R
462 lines (422 loc) · 17.4 KB
/
article.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
#--- NOTE to contributors ------------------------------------------------------
# Please order these format functions alphabetically.
#-------------------------------------------------------------------------------
#' R Markdown output formats for (journal) articles
#'
#' Most article formats are based on [rmarkdown::pdf_document()], with a
#' custom Pandoc LaTeX template and different default values for other arguments
#' (e.g., `keep_tex = TRUE`).
#'
#' @param
#' ...,keep_tex,latex_engine,citation_package,highlight,fig_caption,md_extensions,template,pandoc_args
#' Arguments passed to `rmarkdown::[pdf_document]()`.
#' @section Details: You can find more details about each output format below.
#' @name acm_article
#' @rdname article
NULL
#' @section `acm_article`: Format for creating an Association for Computing
#' Machinery (ACM) articles. Adapted from
#' <https://www.acm.org/publications/proceedings-template>.
#' @return An R Markdown output format.
#' @examples \dontrun{
#' rmarkdown::draft("MyArticle.Rmd", template = "acm", package = "rticles")
#' rmarkdown::draft("MyArticle.Rmd", template = "asa", package = "rticles")}
#' @export
#' @rdname article
acm_article <- function(...) {
pdf_document_format("acm", ...)
}
#' @section `acs_article`: Format for creating an American Chemical Society
#' (ACS) Journal articles. Adapted from
#' <https://pubs.acs.org/page/4authors/submission/tex.html>.
#' @export
#' @rdname article
acs_article <- function(
..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris"), fig_caption = TRUE
) {
pdf_document_format(
"acs", keep_tex = keep_tex, md_extensions = md_extensions,
fig_caption = fig_caption, ...
)
}
#' @section `aea_article`: Format for creating submissions to the American
#' Economic Association (AER, AEJ, JEL, PP).
#' @export
#' @rdname article
aea_article <- function(..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris")) {
pdf_document_format(
"aea", keep_tex = keep_tex, md_extensions = md_extensions, ...
)
}
#' @section `agu_article`: Format for creating a American Geophysical Union
#' (AGU) article. Adapted from
#' <https://www.agu.org/Publish-with-AGU/Publish/#1>.
#' @export
#' @rdname article
agu_article <- function(
..., keep_tex = TRUE, citation_package = 'natbib',
highlight = NULL, md_extensions = c("-autolink_bare_uris", "-auto_identifiers")
) {
pdf_document_format(
"agu", keep_tex = keep_tex, highlight = highlight,
citation_package = citation_package, md_extensions = md_extensions, ...
)
}
#' @section `amq_article`: Ce format a été adapté du format du bulletin de
#' l'AMQ.
#' @export
#' @rdname article
amq_article <- function(
..., latex_engine = 'xelatex', keep_tex = TRUE, fig_caption = TRUE,
md_extensions = c("-autolink_bare_uris")
) {
pdf_document_format(
"amq", latex_engine = latex_engine, highlight = NULL, keep_tex = keep_tex,
md_extensions = md_extensions, fig_caption = fig_caption, ...
)
}
#' @section `ams_article`: Format for creating an American Meteorological
#' Society (AMS) Journal articles. Adapted from
#' <https://www.ametsoc.org/ams/index.cfm/publications/authors/journal-and-bams-authors/author-resources/latex-author-info/>.
#' @export
#' @rdname article
ams_article <- function(..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris")) {
pdf_document_format(
"ams", keep_tex = keep_tex, md_extensions = md_extensions, ...
)
}
#' @section `asa_article`: This format was adapted from The American
#' Statistican (TAS) format, but it should be fairly consistent across
#' American Statistical Association (ASA) journals.
#' @export
#' @rdname article
asa_article <- function(..., keep_tex = TRUE, citation_package = 'natbib') {
pdf_document_format(
"asa", keep_tex = keep_tex, citation_package = citation_package, ...
)
}
#' @section `arxiv_article`: Adapted from the George Kour's format for
#' arXiv and bio-arXiv preprints. So far as I'm aware, entirely
#' unofficial but still a staple.
#' @export
#' @rdname article
arxiv_article <- function(..., keep_tex = TRUE) {
pdf_document_format(
"arxiv", keep_tex = keep_tex, ...
)
}
#' @section `bioinformatics_article`: Format for creating submissions to a Bioinformatics journal. Adapted from
#' <https://academic.oup.com/bioinformatics/pages/submission_online>.
#' @export
#' @rdname article
bioinformatics_article <- function(..., keep_tex = TRUE, citation_package = 'natbib') {
pdf_document_format(
"bioinformatics", keep_tex = keep_tex, citation_package = citation_package,
md_extensions = "-auto_identifiers",...
)
}
#' @section `biometrics_article`: This format was adapted from the
#' Biometrics journal.
#' @export
#' @rdname article
biometrics_article <- function(..., keep_tex = TRUE, citation_package = 'natbib') {
pdf_document_format(
'biometrics', keep_tex = keep_tex, citation_package = citation_package, ...
)
}
#' @section `ctex_article`: A wrapper function for
#' [rmarkdown::pdf_document()] and the default value of
#' `latex_engine` is changed to \command{xelatex}, so it works better for
#' typesetting Chinese documents with the LaTeX package \pkg{ctex}. The
#' function `ctex` is an alias of `ctex_article`.
#' @export
#' @rdname article
ctex_article <- function(..., template = 'default', latex_engine = 'xelatex') {
pdf_document_format(
'ctex', latex_engine = latex_engine, template = template, ...
)
}
#' @export
#' @rdname article
ctex <- ctex_article
#' @section `elsevier_article`: Format for creating submissions to Elsevier
#' journals. Adapted from
#' <https://www.elsevier.com/authors/policies-and-guidelines/latex-instructions>.
#' @export
#' @rdname article
elsevier_article <- function(
..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris")
) {
pdf_document_format(
"elsevier", keep_tex = keep_tex, md_extensions = md_extensions, ...
)
}
#' @section `frontiers_article`: Format for creating Frontiers journal
#' articles. Adapted from
#' <https://www.frontiersin.org/about/author-guidelines>.
#' @export
#' @rdname article
frontiers_article <- function(..., keep_tex = TRUE) {
pdf_document_format("frontiers", keep_tex = keep_tex, ...)
}
#' @section `glossa_article`: Format for creating submissions to Glossa: a
#' journal of general linguistics. Author Guidelines are available on
#' [www.glossa-journal.org](https://www.glossa-journal.org/site/author-guidelines/).
#' Template is adapted from <https://github.com/guidovw/Glossalatex>.
#' @export
#' @rdname article
glossa_article <- function(..., keep_tex = TRUE, latex_engine = "xelatex") {
pdf_document_format(
"glossa", keep_tex = keep_tex, latex_engine = latex_engine, ...
)
}
#' @param journal one of `"aoas"`, `"aap"`, `"aop"`, `"aos"`, `"sts"` for `ims_article`
#' @section `ims_article`: Format for creating submissions to the Institute of Mathematical Statistics
#' [IMS](https://imstat.org/) journals and publications. Adapted from
#' <https://github.com/vtex-soft/texsupport.ims-aoas>.
#'
#' The argument `journal` accepts the acronym of any of the
#' [journals](https://www.e-publications.org/ims/support/ims-instructions.html) in IMS:
#' * `aap`: The Annals of Applied Probability
#' * `aoas`: The Annals of Applied Statistics
#' * `aop`: The Annals of Probability
#' * `aos`: The Annals of Statistics
#' * `sts`: Statistical Science
#' @export
#' @rdname article
ims_article <- function(journal = c("aoas", "aap", "aop", "aos", "sts"),
keep_tex = TRUE, citation_package = "natbib",
md_extensions = c(
"-autolink_bare_uris" # disables automatic links
), pandoc_args = NULL, ...) {
journal <- match.arg(journal)
with_kwsc <- journal %in% c("aap", "aop", "aos") # with keyword_subclass
args <- c(
"journal" = journal,
if (with_kwsc) c("with_kwsc" = with_kwsc)
)
# Convert to pandoc arguments
pandoc_arg_list <- mapply(rmarkdown::pandoc_variable_arg, names(args), args,
SIMPLIFY = FALSE, USE.NAMES = FALSE)
pandoc_arg_list <- unlist(pandoc_arg_list)
pdf_document_format(
"ims", keep_tex = keep_tex, citation_package = citation_package,
md_extensions = md_extensions, pandoc_args = c(pandoc_arg_list, pandoc_args),
...
)
}
#' @section `jasa_article`: Format for creating submissions to the
#' Journal of the Acoustical Society of America. Adapted from
#' <https://acousticalsociety.org/preparing-latex-manuscripts/>.
#' @export
#' @rdname article
jasa_article <- function(
..., keep_tex = TRUE, latex_engine = "xelatex", citation_package = "natbib"
) {
pdf_document_format(
"jasa", keep_tex = keep_tex, latex_engine = latex_engine,
citation_package = citation_package, ...
)
}
#' @section `lipics_article`: Format for creating submissions to
#' LIPIcs - Leibniz International Proceedings Informatics - articles.
#' Adapted from the official Instructions for Authors at
#' <https://submission.dagstuhl.de/documentation/authors> and the
#' template from the archive `authors-lipics-v2019.zip` downloaded
#' with version tag v2019.2. The template is provided under The LaTeX
#' Project Public License (LPPL), Version 1.3c.
#' @export
#' @rdname article
lipics_article <- function(
..., latex_engine = 'xelatex', # xelatex used for 'thin space' Unicode
# character, see YAML field 'authorrunning'
keep_tex = TRUE, citation_package = "natbib", md_extensions = c(
"-autolink_bare_uris", # disables automatic links
"-auto_identifiers" # disables \hypertarget commands
)
) {
# quick dev shortcut for Ubuntu: click "Install and restart" then run:
# unlink("MyArticle/", recursive = TRUE); rmarkdown::draft("MyArticle.Rmd", template = "lipics", package = "rticles", edit = FALSE); rmarkdown::render("MyArticle/MyArticle.Rmd"); system(paste0("xdg-open ", here::here("MyArticle", "MyArticle.pdf")))
pdf_document_format(
"lipics", latex_engine = latex_engine,
citation_package = citation_package, keep_tex = keep_tex,
md_extensions = md_extensions, ...
)
}
#' @section `jedm_article`: Format for creating Journal of Educational
#' Data Mining (JEDM) articles. Adapted from
#' <https://jedm.educationaldatamining.org/index.php/JEDM/information/authors>.
#' @export
#' @rdname article
jedm_article <- function(..., keep_tex = TRUE, citation_package = "natbib") {
pdf_document_format("jedm",
keep_tex = keep_tex,
citation_package = citation_package,
...)
}
#' @section `mdpi_article`: Format for creating submissions to
#' Multidisciplinary Digital Publishing Institute (MDPI) journals. Adapted
#' from <https://www.mdpi.com/authors/latex>.
#' @export
#' @rdname article
mdpi_article <- function(..., keep_tex = TRUE) {
pdf_document_format(
"mdpi", keep_tex = keep_tex, citation_package = "natbib", ...
)
}
#' @section `mnras_article`: Format for creating an Monthly Notices of
#' Royal Astronomical Society (MNRAS) Journal articles. Adapted from
#' <https://ras.ac.uk>.
#' @export
#' @rdname article
mnras_article <- function(..., keep_tex = TRUE, fig_caption = TRUE) {
pdf_document_format(
"mnras", keep_tex = keep_tex, fig_caption = fig_caption, ...
)
}
#' @section `opmi_article`: Format for creating Open Mind articles. Adapted from
#' \url{https://www.mitpressjournals.org/journals/opmi/sub}.
#' @export
#' @rdname article
opmi_article <- function(..., keep_tex = TRUE) {
pdf_document_format("opmi", keep_tex = keep_tex, ...)
}
#' @section `oup_article`: Format for creating submissions to many Oxford University Press
#' journals. Adapted from
#' <https://academic.oup.com/journals/pages/authors/preparing_your_manuscript>
#' and <https://academic.oup.com/icesjms/pages/General_Instructions>.
#' @export
#' @rdname article
oup_article <- function(
..., keep_tex = TRUE,
md_extensions = c("-autolink_bare_uris")
) {
pdf_document_format(
"oup",
keep_tex = keep_tex, md_extensions = md_extensions, ...
)
}
#' @section `peerj_article`: Format for creating submissions to The PeerJ
#' Journal. This was adapted from the
#' [PeerJ
#' Overleaf Template](https://www.overleaf.com/latex/templates/latex-template-for-peerj-journal-and-pre-print-submissions/ptdwfrqxqzbn).
#' @export
#' @rdname article
peerj_article <- function(..., keep_tex = TRUE) {
pdf_document_format("peerj", keep_tex = keep_tex, ...)
}
#' @section `pihph_article`: Format for creating submissions to the Papers
#' in Historical Phonology
#' (<http://journals.ed.ac.uk/pihph/about/submissions>). Adapted from
#' <https://github.com/pihph/templates>. This format works well with
#' `latex_engine = "xelatex"` and `citation_package="biblatex"`,
#' which are the default. It may not work correctly if you change these value.
#' In that case, please open an issue and, a PR to contribute a change in the
#' template.
#' @export
#' @rdname article
pihph_article <- function(
..., keep_tex = TRUE, latex_engine = "xelatex",
citation_package = "biblatex"
) {
pdf_document_format(
"pihph", keep_tex = keep_tex, latex_engine = latex_engine,
citation_package = citation_package, ...)
}
#' @section `plos_article`: Format for creating submissions to PLOS
#' journals. Adapted from <https://journals.plos.org/ploscompbiol/s/latex>.
#' @export
#' @rdname article
plos_article <- function(
..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris")
) {
pdf_document_format(
"plos", keep_tex = keep_tex, md_extensions = md_extensions, ...
)
}
#' @section `pnas_article`: Format for creating submissions to PNAS
#' journals.
#' @export
#' @rdname article
pnas_article <- function(..., keep_tex = TRUE) {
pdf_document_format("pnas", keep_tex = keep_tex, ...)
}
#' @section `sage_article`: Format for creating submissions to Sage
#' Journals. Based on the official Sage Journals
#' \verb{https://uk.sagepub.com/sites/default/files/sage_latex_template_4.zip}{class}.
#'
#' Possible arguments for the YAML header are:
#' * `title` title of the manuscript
#' * `runninghead` short author list for header
#' * `author` list of authors, containing `name` and `num`
#' * `address` list containing `num` and `org` for defining `author` affiliations
#' * `corrauth` corresponding author name and address
#' * `email` correspondence email
#' * `abstract` abstract, limited to 200 words
#' * `keywords` keywords for the article
#' * `bibliography` BibTeX `.bib` file name
#' * `classoption` options of the `sagej` class
#' * `header-includes`: custom additions to the header, before the `\begin{document}` statement
#' * `include-after`: for including additional LaTeX code before the `\end\{document}` statement
#' @export
#' @rdname article
sage_article <- function(..., highlight = NULL, citation_package = "natbib") {
pdf_document_format(
"sage", highlight = highlight, citation_package = citation_package, ...
)
}
#' @section `sim_article`: Format for creating submissions to Statistics in
#' Medicine. Based on the official Statistics in Medicine
#' [class](http://onlinelibrary.wiley.com/journal/10.1002/(ISSN)1097-0258/homepage/la_tex_class_file.htm).
#'
#' Possible arguments for the YAML header are:
#' * `title` title of the manuscript
#' * `author` list of authors, containing `name` and `num`
#' * `address` list containing `num` and `org` for defining `author` affiliations
#' * `presentaddress` not sure what they mean with this
#' * `corres` author and address for correspondence
#' * `authormark` short author list for header
#' * `received`, `revised`, `accepted` dates of submission, revision, and acceptance of the manuscript
#' * `abstract` abstract, limited to 250 words
#' * `keywords` up to 6 keywords
#' * `bibliography` BibTeX `.bib` file
#' * `classoption` options of the `WileyNJD-v2` class
#' * `longtable` set to `true` to include the `longtable` package, used by default from `pandoc` to convert markdown to LaTeX code
#' * `header-includes`: custom additions to the header, before the `\begin{document}` statement
#' * `include-after`: for including additional LaTeX code before the `\end{document}` statement
#' @export
#' @rdname article
sim_article <- function(..., highlight = NULL, citation_package = "natbib") {
pdf_document_format(
"sim", highlight = highlight, citation_package = citation_package, ...
)
}
#' @section `springer_article`: This format was adapted from the Springer
#' Macro package for Springer Journals.
#' @export
#' @rdname article
springer_article <- function(..., keep_tex = TRUE, citation_package = 'default'){
pdf_document_format(
"springer", keep_tex = keep_tex, citation_package = citation_package, ...
)
}
#' @section `tf_article`: Format for creating submissions to a Taylor & Francis journal. Adapted from
#' \samp{https://www.tandf.co.uk/journals/authors/InteractCADLaTeX.zip}.
#' @export
#' @rdname article
tf_article <- function(..., keep_tex = TRUE, citation_package = 'natbib') {
pdf_document_format(
"tf", keep_tex = keep_tex, citation_package = citation_package, ...
)
}
#' @section \code{trb_article}: Format for creating submissions to the Transportation
#' Research Board Annual Meeting. Adapted from
#' \samp{https://www.overleaf.com/latex/templates/transportation-research-board-trb-latex-template/jkfndnnkkksw},
#' which in turn is hosted at \samp{https://github.com/chiehrosswang/TRB_LaTeX_tex}
#' @export
#' @rdname article
trb_article <- function(..., keep_tex = TRUE, citation_package = 'natbib') {
pdf_document_format(
"trb", keep_tex = keep_tex, citation_package = citation_package, ...
)
}