Skip to content

Commit

Permalink
Adapt to pandoc 3.2.1 change regarding pandocbounded new command (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Nov 27, 2024
1 parent 2c58336 commit e1e64d0
Show file tree
Hide file tree
Showing 48 changed files with 817 additions and 43 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
matrix:
config:
# testing R release with last shipped pandoc version in RStudio IDE and new pandoc
- {os: windows-latest, pandoc: '3.1.9', r: 'release'}
- {os: macOS-latest, pandoc: '3.1.9', r: 'release'}
- {os: windows-latest, pandoc: '3.5', r: 'release'}
- {os: macOS-latest, pandoc: '3.5', r: 'release'}
- {os: ubuntu-latest, pandoc: 'devel', r: 'release'}
# testing older pandoc versions
- {os: ubuntu-latest, pandoc: '3.2.1', r: 'release'} # special \pandocbounded change
- {os: ubuntu-latest, pandoc: '3.1.7', r: 'release'} # special citeproc change
- {os: ubuntu-latest, pandoc: '2.19.2', r: 'release'}
- {os: ubuntu-latest, pandoc: '2.18', r: 'release'}
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: rticles
Title: Article Formats for R Markdown
Version: 0.27.3
Version: 0.27.4
Authors@R: c(
person("JJ", "Allaire", , "[email protected]", role = "aut"),
person("Yihui", "Xie", , "[email protected]", role = "aut",
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# rticles (development version)

- Fix `springer_article()` skeleton: It now uses `equal_contribution` in author field (thanks, @nielsbock, #568).
- Updaye `springer_aticle()` template to version 3 (December 2023):
- Update `springer_aticle()` template to version 3 (December 2023):
- BREAKING CHANGE: sn-mathphys.bst has been split into Numbered and Author year style namely `sn-mathphys-num.bst` and `sn-mathphys-ay.bst` respectively. Skeleton has been updated.
If you have existing article, you need to use `sn-mathphys-num` or `sn-mathphys-ay` option now, instead of `sn-mathphys`.
- Update all templates to work with Pandoc 3.2.1 by adding the definition of new `\pandocbounded` command used by Pandoc's LaTeX writers (see more at https://github.com/jgm/pandoc/releases/tag/3.2.1 and https://github.com/jgm/pandoc/issues/9660) (#571, #576).

# rticles 0.27

Expand Down
3 changes: 2 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ pdf_document_format <- function(format,
args <- list_to_pandoc_variable_args(list(
pandoc3 = rmarkdown::pandoc_available("3"),
pandoc317 = rmarkdown::pandoc_available("3.1.7"), # new citeproc command
pandoc318 = rmarkdown::pandoc_available("3.1.8") # revised citeproc command
pandoc318 = rmarkdown::pandoc_available("3.1.8"), # revised citeproc command
pandoc321 = rmarkdown::pandoc_available("3.2.1") # new pandocbounded comment required
))
fmt$pandoc$args <- c(fmt$pandoc$args, args)
fmt
Expand Down
37 changes: 22 additions & 15 deletions inst/rmarkdown/templates/acm/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,31 @@
% Add imagehandling
$if(graphics)$
\usepackage{graphicx}
% Redefine \includegraphics so that, unless explicit options are
% given, the image width will not exceed the width of the page.
% Images get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
$if(pandoc321)$
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\def\ScaleIfNeeded{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
\let\Oldincludegraphics\includegraphics
{%
\catcode`\@=11\relax%
\gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
}%
$else$
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
$endif$
$endif$
$if(svg)$
\usepackage{svg}
Expand Down
19 changes: 19 additions & 0 deletions inst/rmarkdown/templates/acs/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@
\makesavenoteenv{longtable}
$endif$
% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$

$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
19 changes: 19 additions & 0 deletions inst/rmarkdown/templates/aea/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
19 changes: 19 additions & 0 deletions inst/rmarkdown/templates/agu/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
18 changes: 18 additions & 0 deletions inst/rmarkdown/templates/amq/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
19 changes: 19 additions & 0 deletions inst/rmarkdown/templates/ams/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
18 changes: 18 additions & 0 deletions inst/rmarkdown/templates/arxiv/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
18 changes: 18 additions & 0 deletions inst/rmarkdown/templates/asa/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
19 changes: 19 additions & 0 deletions inst/rmarkdown/templates/bioinformatics/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
18 changes: 18 additions & 0 deletions inst/rmarkdown/templates/biometrics/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
19 changes: 19 additions & 0 deletions inst/rmarkdown/templates/copernicus/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@
% Web Ecology (we)
% Wind Energy Science (wes)

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
% Pandoc citation processing
$if(csl-refs)$
% Pandoc citation processing
Expand Down
20 changes: 17 additions & 3 deletions inst/rmarkdown/templates/elsevier/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,23 @@
% For Pandoc feature verbatim_in_note
\usepackage{fancyvrb}
$endif$
$if(graphics)$
\usepackage{graphicx}
$endif$
% Add imagehandling
$if(graphics)$$if(pandoc321)$
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(svg)$
\usepackage{svg}
$endif$
Expand Down
18 changes: 18 additions & 0 deletions inst/rmarkdown/templates/frontiers/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@
\makesavenoteenv{longtable}
$endif$

% Add imagehandling
$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command.
$if(graphics)$$if(pandoc321)$
% Custom command from Pandoc 3.2.1 to scale images if necessary
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
\makeatother
$endif$$endif$
$if(csl-refs)$
% Pandoc citation processing
$if(pandoc318)$
Expand Down
Loading

0 comments on commit e1e64d0

Please sign in to comment.