Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG NODE_VERSION=20
# Stage 1: Install pandoc
FROM public.ecr.aws/lambda/nodejs:${NODE_VERSION} as pandoc

ARG PANDOC_VERSION=3.1.13
ARG PANDOC_VERSION=3.6.4

# Install tar and gzip
RUN dnf install -y tar gzip
Expand Down
46 changes: 17 additions & 29 deletions src/template.latex
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,23 @@ $endif$
$if(graphics)$
\usepackage{graphicx,grffile}
\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}

% Updating our template following changes to Pandoc
% https://github.com/jgm/pandoc/pull/9666/files

\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%
}

% End update

$endif$
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
Expand Down Expand Up @@ -220,28 +230,6 @@ $endif$
\usepackage{float}
\floatplacement{figure}{H}

% Centre images
\usepackage{etoolbox} % For toggle functionality

\newtoggle{infigure} % Create toggle to track if we're inside a figure environment
\togglefalse{infigure} % Initialize as false

\pretocmd{\figure}{\toggletrue{infigure}}{}{} % Set toggle when entering/exiting figure environments
\apptocmd{\endfigure}{\togglefalse{infigure}}{}{}

\let\oldincludegraphics\includegraphics % Save the original includegraphics command

\renewcommand{\includegraphics}[2][]{ % Redefine includegraphics to check if it's already in a figure
\iftoggle{infigure}{%
\oldincludegraphics[#1]{#2}%
}{%
\begin{figure}
\centering
\oldincludegraphics[#1]{#2}
\end{figure}%
}%
}

% Remove "Figure X." prefix from captions
\usepackage{caption}
\captionsetup[figure]{labelformat=empty}
Expand Down