I use the \twopagepicture snippet that's posted here.
How to include a picture over two pages, left part on left side, right on right (for books)?
I need a small adjustment where the figure does not meet the document's edge and is instead shifted away from the edges. It's easy enough to shift the figure vertically, but every time I try to adjust
\let\mywidth\paperwidth
to
\let\mywidth\paperwidth - <some offset>in
so the horizontal edges go inward, some parts of the figure in the middle are clipped out.
Here is an MWE without me changing it. It tends to align oddly, but it's fine for the main document I'm working on.
\documentclass[10pt,]{article}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{afterpage}
\usepackage{caption}
\setcounter{totalnumber}{1}
\setcounter{topnumber}{1}
\setcounter{bottomnumber}{1}
\renewcommand{\topfraction}{.99}
\renewcommand{\bottomfraction}{.99}
\renewcommand{\textfraction}{.01}
\makeatletter
\newcommand*{\twopagepicture}[4]{%
\checkoddpage
\ifoddpage
\expandafter\@firstofone
\else
\expandafter\afterpage
\fi
{\afterpage{%
\if #1t%
\if #2p%
\thispagestyle{empty}%
\afterpage{\thispagestyle{empty}}%
\fi
\fi
\begin{figure}[#1]
\if #2p%
\if #1t%
% Note #1: Controls vertical positioning of even page.
% Addition leads to moving the image downward..
\vspace*{-\dimexpr1in+\voffset+\topmargin+\headheight+\headsep\relax}
\fi
\fi
\if #1b%
\caption{#4}%
\fi
\makebox[\textwidth][l]{%
\if #2p\relax
% Controls horizontal positioning of the even page
\let\mywidth\paperwidth
\hskip-\dimexpr1in+\hoffset+\evensidemargin\relax
\else
\let\mywidth\linewidth
\fi
\adjustbox{trim=0 0 {\mywidth} 0,clip}{\includegraphics[width=2\mywidth]{#3}}}%
\if #1b\else
\caption{#4}%
\fi
\if #2p%
\if #1b%
\vspace*{-\dimexpr\paperheight-\textheight-1in-\voffset-\topmargin-\headheight-\headsep\relax}%
\fi
\fi
\end{figure}%
\begin{figure}[#1]
\if #2p%
\if #1t%
\vspace*{-\dimexpr1in+\voffset+\topmargin+\headheight+\headsep\relax} % Note #1.
\fi
\fi
\makebox[\textwidth][l]{%
\if #2p%
\let\mywidth\paperwidth
\hskip-\dimexpr1in+\hoffset+\oddsidemargin\relax
\else
\let\mywidth\linewidth
\fi
\adjustbox{trim={\mywidth} 0 0 0,clip}{\includegraphics[width=2\mywidth]{#3}}}%
\if #2p%
\if #1b%
\vspace*{-\dimexpr\paperheight-\textheight-1in-\voffset-\topmargin-\headheight-\headsep\relax}%
\fi
\fi
\end{figure}%
}}%
}
\makeatother
\begin{document}
The diagonal in the picture should not be broken.
\twopagepicture{t}{p}{diagonal.png}{}
And the picture continues to the next page.
\end{document}
Here is what I am trying to go for before someone thinks my question is about removing the file extension.

The temporary solution I do, is to make a PNG file with a width that spans the length of two pages, then manually rescale the image (JPG). This almost doubles the file size of the image, so ideally, I'd still like the position handled in LaTeX.


