copernicus_article.R 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #' Copernicus journals format.
  2. #'
  3. #' Format for creating submissions to Copernicus journals.
  4. #'
  5. #' @inheritParams rmarkdown::pdf_document
  6. #' @param ... Additional arguments to \code{base_format}
  7. #' @param base_format The function to use for the base format of the article.
  8. #' By default, this is \code{rmarkdown::pdf_document}, but to use bookdown's
  9. #' cross-referencing feature, this can be set to \code{bookdown::pdf_document2}
  10. #' @param journal_name A regular expression to filter the by the journal name, see \code{pattern} in \code{\link[base]{grep}}; defaults to \code{*}.
  11. #'
  12. #' @return R Markdown output format to pass to
  13. #' \code{\link[rmarkdown:render]{render}}
  14. #'
  15. #' @details This was adapted from
  16. #' \href{https://publications.copernicus.org/for_authors/manuscript_preparation.html}{https://publications.copernicus.org/for_authors/manuscript_preparation.html}.
  17. #'
  18. #' An number of required and optional manuscript sections, e.g. \code{acknowledgements}, \code{competinginterests}, or \code{authorcontribution}, must be declared using the respective properties of the R Markdown header - see skeleton file.
  19. #'
  20. #' \strong{Version:} Based on copernicus_package.zip in the version 5.0, 21 March 2018, using \code{copernicus.cls} in version 8.67, 30 January 2018
  21. #'
  22. #' \strong{Copernicus journal abbreviations:} You can use the function \code{copernicus_journal_abbreviations()} to get the journal abbreviation for all journals supported by the copernicus article template.
  23. #'
  24. #' \strong{Important note:} The online guidelines by Copernicus are the official resource.
  25. #' Copernicus is not responsible for the community contributions made to support the template in this package.
  26. #' Copenicus converts all typeset TeX files into XML, the expressions and markups have to be highly standardized.
  27. #' Therefore, please keep the following in mind:
  28. #'
  29. #' \itemize{
  30. #' \item Please provide only one figure file for figures with several panels, and please do not use \code{\\subfloat} or similar commands.
  31. #' \item Please use only commands in which words, numbers, etc. are within braces (e.g. \code{\\textrm{TEXT}} instead of \code{{\\rm TEXT}}).
  32. #' \item For algorithms, please use the syntax given in template.tex or provide your algorithm as a figure.
  33. #' \item Please do not define new commands.
  34. #' \item The most commonly used packages (\code{\\usepackage{}}) are integrated in the copernicus.cls. Some other packages often used by the community are defined in template.tex. Please do not insert additional ones in your *.tex file.
  35. #' \item Spaces in labels (\code{\\label{}}) are not allowed; please make sure that no label name is assigned more than once.
  36. #' \item Please do not use \code{\\paragraph{}}; only \code{\\subsubsection{}} is allowed.
  37. #' \item It is not possible to add tables in colour.
  38. #' }
  39. #'
  40. #' @note If you use \code{rmarkdown::pdf_document()}, all internal references (i.e. tables and figures) must use \code{\\ref\{\}} whereas with \code{bookdown::pdf_document2()}, you can additionally use \code{\\@@ref()}.
  41. #'
  42. #' @references
  43. #' Manuscript preparation guidelines for authors.
  44. #' \url{https://publications.copernicus.org/for_authors/manuscript_preparation.html}
  45. #'
  46. #' @examples
  47. #' names(copernicus_journal_abbreviations())
  48. #' copernicus_journal_abbreviations(journal_name = "Science Data")
  49. #' \dontrun{
  50. #' library("rmarkdown")
  51. #' draft("MyArticle.Rmd", template = "copernicus_article", package = "rticles")
  52. #' render("MyArticle/MyArticle.Rmd")
  53. #' }
  54. #'
  55. #' @export
  56. copernicus_article <- function(...,
  57. keep_tex = TRUE,
  58. citation_package = "natbib",
  59. base_format = rmarkdown::pdf_document,
  60. md_extensions = c(
  61. "-autolink_bare_uris", # disables automatic links, needed for plain email in \correspondence
  62. "-auto_identifiers" # disables \hypertarget commands
  63. )) {
  64. if (is.character(base_format)) {
  65. FMT <- eval(parse(text = base_format))
  66. } else {
  67. FMT <- match.fun(base_format)
  68. }
  69. FMT(...,
  70. citation_package = citation_package,
  71. keep_tex = keep_tex,
  72. md_extensions = md_extensions,
  73. template = find_resource("copernicus_article", "template.tex"))
  74. }
  75. # quick dev shortcut for Ubuntu: click "Install and restart" then run:
  76. # unlink("MyArticle/", recursive = TRUE); draft("MyArticle.Rmd", template = "copernicus_article", package = "rticles", edit = FALSE); render("MyArticle/MyArticle.Rmd"); system(paste0("gnome-open ", here::here("MyArticle", "MyArticle.pdf")))
  77. copernicus_journals <- list(
  78. "Advances in Geosciences" = "adgeo",
  79. "Advances in Radio Science" = "ars",
  80. "Advances in Science and Research" = "asr",
  81. "Advances in Statistical Climatology, Meteorology and Oceanography" = "ascmo",
  82. "Annales Geophysicae" = "angeo",
  83. "Archives Animal Breeding" = "aab",
  84. "ASTRA Proceedings" = "ap",
  85. "Atmospheric Chemistry and Physics" = "acp",
  86. "Atmospheric Measurement Techniques" = "amt",
  87. "Biogeosciences" = "bg",
  88. "Climate of the Past" = "cp",
  89. "Drinking Water Engineering and Science" = "dwes",
  90. "Earth Surface Dynamics" = "esurf",
  91. "Earth System Dynamics" = "esd",
  92. "Earth System Science Data" = "essd",
  93. "E&G Quaternary Science Journal" = "egqsj",
  94. "Fossil Record" = "fr",
  95. "Geographica Helvetica" = "gh",
  96. "Geoscience Communication" = "gc",
  97. "Geoscientific Instrumentation, Methods and Data Systems" = "gi",
  98. "Geoscientific Model Development" = "gmd",
  99. "History of Geo- and Space Sciences" = "hgss",
  100. "Hydrology and Earth System Sciences" = "hess",
  101. "Journal of Micropalaeontology" = "jm",
  102. "Journal of Sensors and Sensor Systems" = "jsss",
  103. "Mechanical Sciences" = "ms",
  104. "Natural Hazards and Earth System Sciences" = "nhess",
  105. "Nonlinear Processes in Geophysics" = "npg",
  106. "Ocean Science" = "os",
  107. "Primate Biology" = "pb",
  108. "Proceedings of the International Association of Hydrological Sciences" = "piahs",
  109. "Scientific Drilling" = "sd",
  110. "SOIL" = "soil",
  111. "Solid Earth" = "se",
  112. "The Cryosphere" = "tc",
  113. "Web Ecology" = "we",
  114. "Wind Energy Science" = "wes"
  115. )
  116. #' @rdname copernicus_article
  117. #' @export
  118. copernicus_journal_abbreviations <- function(journal_name = "*") {
  119. journal <- copernicus_journals[grepl(pattern = journal_name, x = names(copernicus_journals), ignore.case = TRUE)]
  120. return(unlist(journal))
  121. }