# adjustbox and includegraphics page selection

I want to use yhe adjustbox package to include graphics in beamer presentations. I prefer it over graphicx because it has max size option which only scales the figure when its size is larger than a certain size.

But I've found a problem when I need to select a page from a multipage figure (usually made with \documentclass[tikz]{standalone}). When using \includegraphics it's possible to use page=x (defined in pdftex.def) option to select which page to be included but this option is not available in adjustbox. Therefore the best command I could do to include certain page from a multipage pdf file with fixed maximum size in beamer is:

\newcommand{\mygraphic}[2][]{%
\par\centering
{\includegraphics[#1]{#2}}\par}


where #1 is an optional parameter used to fix page selection when needed and #2 is the mandatory filename.

My questions are:

1. Is it possible to avoid using includegraphics inside adjustbox if I want to use page=x option?
2. Is it possible to fix max size with a general adjustboxset command? (I think it isn't with export class option but I'm not sure)
• Ignasi, @UlrikeFischer: adjustbox v1.1 2018/04/08 now passes the page key (and others) correctly. For images use \adjustimage{key=value,...}{imagefilename}. – Martin Scharrer Apr 9 '18 at 7:14

This works for me:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\centering % just to avoid overfull box
\includegraphics[page=2,max size={\textwidth}{0.9\textheight}]{l3fp}

\end{document}


• Thanks! Once you know the solution it's easier to find it in documentation, I've read export class option several times but with your example I've finally understood it. – Ignasi Apr 23 '14 at 14:35

The adjustbox v1.1 from 2018/04/08 now correctly supports the page key. Instead of using the export option you can just use the macro \adjustimage{<options>}{<filename>}. Instead of using \centering just use the center key at the end.

\usepackage{adjustbox}[2018/04/08]

\newcommand{\mygraphic}[2][]{%
\par\noindent
\par
}


After bouncing back between this and this other question, I decided I wanted to both set global keys for adjustbox (part 2 of your question) and sometimes also use page=… (part 1).1 So I did this—note the use of capitalized Export:

\documentclass{article}
\makeatletter

% Load graphicx first and save its original \includegraphics
\usepackage{graphicx}
\let\orig@includegraphics\includegraphics

% Using the capitalized 'Export' option replaces \includegraphics with

% Set some global adjustbox keys

% Define a new three-argument command:
\newcommand{\includegraphicspage}[3][]{%
\makeatother


This allows me to do all of the following and have my \adjustboxset options apply in every case:

\begin{document}

% This is actually \adjincludegraphics; 'page' won't work
\includegraphics{singlepage.pdf}

% Pass an argument for graphicx
\includegraphicspage{page=3}{multipage.pdf}

% Also pass arguments for adjustbox
\includegraphicspage[width=\textwidth]{page=3}{multipage.pdf}

\end{document}


1 Why? Mainly because I already had a long document with many \includegraphics. It was easier to modify the few appearances of multi-page images.