Skip to content

Commit 4698108

Browse files
RLumSKcderv
andauthored
Copernicus template update - fixes syntax highlight problem (#391)
* Update template for follow guidelines from Copernicus: no additional packages can be used from those in the cls file. This requires to deactivate Pandoc highlighting for typesetting. algorithms packages can't be loaded in template too * Adapt the skeleton and document all this. Add command to install packages in the skeleton. Co-authored-by: Christophe Dervieux <[email protected]>
1 parent 4aa0a44 commit 4698108

File tree

6 files changed

+68
-29
lines changed

6 files changed

+68
-29
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rticles
22
Type: Package
33
Title: Article Formats for R Markdown
4-
Version: 0.19.2
4+
Version: 0.19.3
55
Authors@R: c(
66
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
77
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
rticles 0.20
22
---------------------------------------------------------------------
33

4+
- Update Copernicus Publications template to comply with editor's guidelines following a manuscript bounce back during the typesetting step. Copernicus does not allow to add any `\usepackage` command as they all are included in `copernicus.cls` for supported LaTeX packages. **This is leading to breaking changes with existing template - please follow the advice below**.
5+
- `algorithms: true` cannot be used anymore and as no more effect. `\usepackage{algorithmic}` and `\usepackage{algorithm}` has been removed from the template as the command are already done in `copernicus.cls`. Please, make sure `algorithms` and `algorithmcx` are installed.
6+
- Additionally, the template gained support for the `highlight` parameter of `rmarkdown::pdf_document` to enable or disable syntax highlighting with Pandoc. To comply with the above guideline by Copernicus, it is disabled by default (`highlight: NULL`) to prevent Pandoc adding any more packages required for its highlighting. Syntax highlighting can be reactivating by using `highlight: "default"` in the YAML header as this can be desirable before submitting for typesetting. (thanks, @RLumSK, @nuest, #391).
7+
48
- Fix issue with Pandoc's citation processing by updating all templates with last relevant changes from Pandoc's default template (thanks, @BlackEdder, @dahrens, #390)
59

610
- remove warning in `joss_article()` about `citation_package` (thanks, @llrs, #389).
@@ -9,6 +13,7 @@ rticles 0.20
913

1014
rticles 0.19
1115
---------------------------------------------------------------------
16+
1217
- Update Copernicus Publications template to version 6.2 from 2021-01-15 (thanks, @RLumSK, #366).
1318

1419
- Add article template `pihph_article()` for the *Papers in Historical Phonology* (PiHPh) (thanks, @stefanocoretta, #362).

R/copernicus_article.R

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#' Format for creating submissions to Copernicus journals.
44
#'
55
#' @inheritParams rmarkdown::pdf_document
6-
#' @param ... Additional arguments to \code{rmarkdown::pdf_document()}.
6+
#' @param ... Additional arguments to \code{rmarkdown::pdf_document()}. \bold{Note}: \code{extra_dependencies} are not
7+
#' allowed as Copernicus does not support additional packages included via \code{\\usepackage{}}.
78
#' @param journal_name A regular expression to filter the by the journal name, see \code{pattern} in \code{\link[base]{grep}}; defaults to \code{*}.
89
#'
910
#' @return An R Markdown output format.
@@ -12,21 +13,23 @@
1213
#'
1314
#' 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.
1415
#'
15-
#' \strong{Version:} Based on copernicus_package.zip in the version 5.3, 18 February 2019, using \code{copernicus.cls} in version 8.82.
16+
#' \strong{Version:} Based on \code{copernicus_package.zip} in the version 6.2, 15 January 2021, using \code{copernicus.cls} in version 9.25.
1617
#'
17-
#' \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.
18+
#' \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.
1819
#'
1920
#' \strong{Important note:} The online guidelines by Copernicus are the official resource.
2021
#' Copernicus is not responsible for the community contributions made to support the template in this package.
21-
#' Copenicus converts all typeset TeX files into XML, the expressions and markups have to be highly standardized.
22+
#' Copernicus converts all typeset TeX files into XML, the expressions and markups have to be highly standardized.
2223
#' Therefore, please keep the following in mind:
2324
#'
2425
#' \itemize{
2526
#' \item Please provide only one figure file for figures with several panels, and please do not use \code{\\subfloat} or similar commands.
2627
#' \item Please use only commands in which words, numbers, etc. are within braces (e.g. \code{\\textrm{TEXT}} instead of \code{{\\rm TEXT}}).
2728
#' \item For algorithms, please use the syntax given in template.tex or provide your algorithm as a figure.
2829
#' \item Please do not define new commands.
29-
#' \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.
30+
#' \item Supported packages (\code{\\usepackage{}}) are already integrated in the \code{copernicus.cls}. Please do not insert additional ones in your \code{*.tex} file.
31+
#' \item If you opt for syntax highlighting for your preprint or other reasons, please do not forget to use
32+
#' \code{highlight = NULL} for your final file upload once your manuscript was accepted for publication.
3033
#' \item Spaces in labels (\code{\\label{}}) are not allowed; please make sure that no label name is assigned more than once.
3134
#' \item Please do not use \code{\\paragraph{}}; only \code{\\subsubsection{}} is allowed.
3235
#' \item It is not possible to add tables in colour.
@@ -48,14 +51,21 @@
4851
#' }
4952
#' @export
5053
copernicus_article <- function(
51-
..., keep_tex = TRUE, citation_package = "natbib", md_extensions = c(
54+
..., keep_tex = TRUE, highlight = NULL, citation_package = "natbib", md_extensions = c(
5255
"-autolink_bare_uris", # disables automatic links, needed for plain email in \correspondence
5356
"-auto_identifiers" # disables \hypertarget commands
5457
)
5558
) {
59+
if ("extra_dependencies" %in% names(list(...)))
60+
warning(
61+
"Copernicus does not support additional LaTeX packages and options!
62+
>> Please remove 'extra_dependencies' from your YAML header!",
63+
call. = FALSE
64+
)
65+
5666
pdf_document_format(
5767
"copernicus", citation_package = citation_package,
58-
keep_tex = keep_tex, md_extensions = md_extensions, ...
68+
keep_tex = keep_tex, highlight = highlight, md_extensions = md_extensions, ...
5969
)
6070
}
6171

inst/rmarkdown/templates/copernicus/resources/template.tex

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
% Web Ecology (we)
6363
% Wind Energy Science (wes)
6464

65-
66-
%% \usepackage commands included in the copernicus.cls:
65+
%% Please DO NOT add additional packages or LaTeX commands to the template. They
66+
%% are not supported by Coperncius. LaTeX packages already
67+
%% included in the copernicus.cls are:
6768
%\usepackage[german, english]{babel}
6869
%\usepackage{tabularx}
6970
%\usepackage{cancel}
@@ -111,11 +112,6 @@
111112
%$header-includes$
112113
%$endfor$
113114

114-
$if(algorithms)$
115-
\usepackage{algorithmic}
116-
\usepackage{algorithm}
117-
$endif$
118-
119115
$if(highlighting-macros)$
120116
$highlighting-macros$
121117
$endif$

inst/rmarkdown/templates/copernicus/skeleton/skeleton.Rmd

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ running:
4646
# This section is mandatory even if you declare that no competing interests are present.
4747
competinginterests: |
4848
The authors declare no competing interests.
49-
# OPTIONAL:
50-
algorithms: true
5149
# See https://publications.copernicus.org/for_authors/licence_and_copyright.html, normally used for transferring the copyright, if needed.
5250
# Note: additional copyright statements for affiliated software or data need to be placed in the data availability section.
5351
copyrightstatement: |
@@ -87,15 +85,17 @@ appendix: |
8785
8886
Please add `\clearpage` between each table and/or figure. Further guidelines on figures and tables can be found below.
8987
output:
90-
rticles::copernicus_article: default
88+
rticles::copernicus_article:
89+
highlight: NULL
90+
keep_tex: true
9191
bookdown::pdf_book:
9292
base_format: rticles::copernicus_article # for using bookdown features like \@ref()
9393
---
9494

9595
\introduction[Introduction]
9696

9797
Introduction text goes here.
98-
You can change the name of the section if neccessary using `\introduction[modified heading]`.
98+
You can change the name of the section if necessary using `\introduction[modified heading]`.
9999

100100
The following settings can or must be configured in the header of this file and are bespoke for Copernicus manuscripts:
101101

@@ -119,8 +119,23 @@ The following settings can or must be configured in the header of this file and
119119

120120
See the defaults and examples from the skeleton and the official Copernicus documentation for details.
121121

122-
**Important**: Always double-check with the official manuscript preparation guidelines at [https://publications.copernicus.org/for_authors/manuscript_preparation.html](https://publications.copernicus.org/for_authors/manuscript_preparation.html), especially the sections "Technical instructions for LaTeX" and "Manuscript composition".
123-
Please contact Daniel Nüst, `[email protected]`, with any problems.
122+
**Please note:** Per [their
123+
guidelines](https://publications.copernicus.org/for_authors/manuscript_preparation.html),
124+
Copernicus does not support additional \LaTeX{} packages or new \LaTeX{}
125+
commands than those defined in their `.cls` file. This means that you cannot add any extra dependencies and a warning will be thrown if so.
126+
This extends to syntax highlighting of source code. Therefore this template sets
127+
the parameter `highlight` in the YAML header to `NULL` to deactivate Pandoc
128+
syntax highlighter. This prevent addition of external packages for highlighting
129+
inserted by Pandoc. However, it might be desirable to have syntax highlight
130+
available in preprints or for others reasons. Please see
131+
`?rmarkdown::pdf_document` for available options to activate highlighting.
132+
133+
**Important**: Always double-check with the official manuscript preparation
134+
guidelines at
135+
[https://publications.copernicus.org/for_authors/manuscript_preparation.html](https://publications.copernicus.org/for_authors/manuscript_preparation.html),
136+
especially the sections "Technical instructions for LaTeX" and "Manuscript
137+
composition". Please contact Daniel Nüst, `[email protected]`, with
138+
any problems.
124139

125140
# Content section one
126141

@@ -290,10 +305,15 @@ x & y & z\\
290305
\end{matrix}
291306
$$
292307

293-
## ALGORITHM
308+
## ALGORITHM/PROGRAMMING CODE
294309

295-
If you want to use algorithms, you can either enable the required packages in the header (the default, see `algorithms: true`), or make sure yourself that the \LaTeX packages `algorithms` and `algorithmicx` are installed so that `algorithm.sty` respectively `algorithmic.sty` can be loaded by the Copernicus template.
296-
Copernicus staff will remove all undesirable packages from your LaTeX source code, so please stick to using the header option, which only adds the two acceptable packages.
310+
If you want to use algorithms, you need to make sure yourself that the \LaTeX packages `algorithms` and `algorithmicx` are installed so that `algorithm.sty` respectively `algorithmic.sty` can be loaded by the Copernicus template. Both need to be available through your preferred \LaTeX{} distribution. With TinyTeX (or TeX Live), you can do so by running `tinytex::tlmgr_install(c("algorithms", "algorithmicx"))`
311+
312+
```{r, echo = FALSE, eval = tinytex::is_tinytex()}
313+
tinytex::tlmgr_install(c("algorithms", "algorithmicx"))
314+
```
315+
316+
Copernicus staff will no accept any additional packages from your LaTeX source code, so please stick to these two acceptable packages. They are needed to use the example below
297317

298318
\begin{algorithm}
299319
\caption{Algorithm Caption}

man/copernicus_article.Rd

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)