adjustbox and includegraphics page selection












4














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]{%
parcentering
adjustbox{max size={textwidth}{.9textheight}}%
{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)










share|improve this question
























  • 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
















4














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]{%
parcentering
adjustbox{max size={textwidth}{.9textheight}}%
{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)










share|improve this question
























  • 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














4












4








4


1





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]{%
parcentering
adjustbox{max size={textwidth}{.9textheight}}%
{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)










share|improve this question















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]{%
parcentering
adjustbox{max size={textwidth}{.9textheight}}%
{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)







graphics adjustbox page






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 15:57









Martin Scharrer

199k45632815




199k45632815










asked Apr 23 '14 at 9:53









Ignasi

91.7k4166305




91.7k4166305












  • 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


















  • 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
















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




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










3 Answers
3






active

oldest

votes


















3














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.9textheight}]{l3fp}

end{document}


enter image description here






share|improve this answer





















  • 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



















1














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]{%
parnoindent
adjustimage{#1,max size={textwidth}{.9textheight},center}{#2}%
par
}





share|improve this answer





























    0














    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}
    letorig@includegraphicsincludegraphics

    % Using the capitalized 'Export' option replaces includegraphics with
    % adjincludegraphics
    usepackage[Export]{adjustbox}

    % Set some global adjustbox keys
    adjustboxset{trim=0.5in 0in}

    % Define a new three-argument command:
    % includegraphicspage{adjbox args}{graphicx args}{filename}
    newcommand{includegraphicspage}[3]{%
    adjustbox{#1}{orig@includegraphics[#2]{#3}par}}
    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.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f172996%2fadjustbox-and-includegraphics-page-selection%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      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.9textheight}]{l3fp}

      end{document}


      enter image description here






      share|improve this answer





















      • 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
















      3














      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.9textheight}]{l3fp}

      end{document}


      enter image description here






      share|improve this answer





















      • 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














      3












      3








      3






      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.9textheight}]{l3fp}

      end{document}


      enter image description here






      share|improve this 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.9textheight}]{l3fp}

      end{document}


      enter image description here







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Apr 23 '14 at 14:17









      egreg

      710k8618853170




      710k8618853170












      • 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


















      • 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
















      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




      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











      1














      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]{%
      parnoindent
      adjustimage{#1,max size={textwidth}{.9textheight},center}{#2}%
      par
      }





      share|improve this answer


























        1














        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]{%
        parnoindent
        adjustimage{#1,max size={textwidth}{.9textheight},center}{#2}%
        par
        }





        share|improve this answer
























          1












          1








          1






          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]{%
          parnoindent
          adjustimage{#1,max size={textwidth}{.9textheight},center}{#2}%
          par
          }





          share|improve this answer












          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]{%
          parnoindent
          adjustimage{#1,max size={textwidth}{.9textheight},center}{#2}%
          par
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 28 '18 at 15:56









          Martin Scharrer

          199k45632815




          199k45632815























              0














              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}
              letorig@includegraphicsincludegraphics

              % Using the capitalized 'Export' option replaces includegraphics with
              % adjincludegraphics
              usepackage[Export]{adjustbox}

              % Set some global adjustbox keys
              adjustboxset{trim=0.5in 0in}

              % Define a new three-argument command:
              % includegraphicspage{adjbox args}{graphicx args}{filename}
              newcommand{includegraphicspage}[3]{%
              adjustbox{#1}{orig@includegraphics[#2]{#3}par}}
              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.






              share|improve this answer




























                0














                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}
                letorig@includegraphicsincludegraphics

                % Using the capitalized 'Export' option replaces includegraphics with
                % adjincludegraphics
                usepackage[Export]{adjustbox}

                % Set some global adjustbox keys
                adjustboxset{trim=0.5in 0in}

                % Define a new three-argument command:
                % includegraphicspage{adjbox args}{graphicx args}{filename}
                newcommand{includegraphicspage}[3]{%
                adjustbox{#1}{orig@includegraphics[#2]{#3}par}}
                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.






                share|improve this answer


























                  0












                  0








                  0






                  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}
                  letorig@includegraphicsincludegraphics

                  % Using the capitalized 'Export' option replaces includegraphics with
                  % adjincludegraphics
                  usepackage[Export]{adjustbox}

                  % Set some global adjustbox keys
                  adjustboxset{trim=0.5in 0in}

                  % Define a new three-argument command:
                  % includegraphicspage{adjbox args}{graphicx args}{filename}
                  newcommand{includegraphicspage}[3]{%
                  adjustbox{#1}{orig@includegraphics[#2]{#3}par}}
                  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.






                  share|improve this answer














                  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}
                  letorig@includegraphicsincludegraphics

                  % Using the capitalized 'Export' option replaces includegraphics with
                  % adjincludegraphics
                  usepackage[Export]{adjustbox}

                  % Set some global adjustbox keys
                  adjustboxset{trim=0.5in 0in}

                  % Define a new three-argument command:
                  % includegraphicspage{adjbox args}{graphicx args}{filename}
                  newcommand{includegraphicspage}[3]{%
                  adjustbox{#1}{orig@includegraphics[#2]{#3}par}}
                  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.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 5 '18 at 3:55









                  Stefan Pinnow

                  19.4k83175




                  19.4k83175










                  answered Apr 5 '18 at 0:07









                  khaeru

                  12




                  12






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f172996%2fadjustbox-and-includegraphics-page-selection%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                      How to change which sound is reproduced for terminal bell?

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?