[Tex/LaTex] adjustbox and includegraphics page selection

adjustboxgraphicspagesize;

I want to use the 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}). While 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
     \adjustbox{max size={\textwidth}{.9\textheight}}%
        {\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)

Best Answer

This works for me:

\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\begin{document}

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

\end{document}

enter image description here