0

I am working on an enormous project that will be completed in several stages.

The first step is to compile many screenshots or other images into a single document, where there would be one image per page, and the name of each image is specified.

For reasons not relevant to this question, it would be ideal if the page height (or both height and width) were determined by the dimensions of the image to be included. Having a fixed standard width (like 8.5in) would be absolutely fine, but having the page height adjust to the height of the image (+ some standard margin) would be very helpful.

This PDF is a hacked version of the output that I'd like (hacked MWE below; fake images attached, below). The hack is viable for one or two docs with just a few images; however, I will have to create upwards of a hundred such documents, each with anywhere from 20-100 images, so it would not be worthwhile.

A few points about the desired output:

  • As you'll see in the hacked MWE, for files whose width exceeded the 8.5in page, I scaled the image size by width=0.9\textwidth. This was part of the additional complication that has made this challenge beyond my ability.

  • The itemize environment is desirable not for the current project, but for a future application. These documents will be fed through a script that will extract each item between %START OF ITEM MARKER and %END OF ITEM MARKER, and that command is very important in those future applications, so it preferable to keep it; however, a work-around could be found if the page-dimensions issue required one to drop the itemize environment.

  • Ideally, each individual page would have a common margin area around the image. I believe this would require the top margin to be slightly larger, to account for the text to be included.

  • Ideally, images would be centred.


Hacked MWE

I used a combination of \eject \pdfpagewidth=XXin \pdfpageheight=XXin and width=X\textwidth to get the desired output, but this is obviously not ideal. I have spent several hours trying different options, including options from the geometry package, but this is just beyond my ability, at this time. The sample images are attached, below.

\documentclass{article}
\usepackage[paperheight=6in,paperwidth=8.5in, margin=0.5in,tmargin=0.5in, heightrounded]{geometry} %option: showframe
\usepackage{amsmath, amsthm, amssymb, graphicx, enumerate, enumitem,xcolor,graphicx}

\newcommand{\qtxt}[1]{\textbf{\boldmath#1}}


\begin{document}


$~$\vspace{1.8in}
\begin{center}
    \huge{\textbf{Title of Doc - Date - \emph{\&} Source of Images}}
\end{center}





% % Start of "Commands for rescaling page dimensions and seperately itemizing ITEMS"
\eject \pdfpagewidth=8.5in \pdfpageheight=5.5in


\begin{itemize}
            %START OF ITEM MARKER
            % ------- TeX.se Ignore this Line: Image Source Information 
            %
                % Added 18.4W
                \item \qtxt{%
                            Source-A-\color{blue}{Image-1}
                            \begin{center}
                            \includegraphics[width=0.9\textwidth]{Source-A-Image-1.png}             
                            \end{center}
                            }\newpage%
            %
            % ======= End
            %END OF ITEM MARKER

                        \eject \pdfpagewidth=8.5in \pdfpageheight=2.4in
                        %START OF ITEM MARKER
                        % ------- TeX.se Ignore this Line: Image Source Information 
                        %
                            % Added 18.4W
                            \item \qtxt{%
                                        Source-A-\color{red}{Image-1 part 1 Soln }
                                        \begin{center}
                                        \includegraphics[width=0.9\textwidth]{Source-A-Image-1part-1Soln.png}               
                                        \end{center}
                                        }\newpage%
                        %
                        % ======= End


                        %START OF ITEM MARKER
                        % ------- TeX.se Ignore this Line: Image Source Information 
                        %
                            % Added 18.4W
                            \item \qtxt{%
                                        Source-A-\color{red}{Image-1 part 2 Soln }
                                        \begin{center}
                                        \includegraphics[width=0.9\textwidth]{Source-A-Image-1part-2Soln.png}               
                                        \end{center}
                                        }\newpage%
                        %
                        % ======= End
                        %END OF ITEM MARKER





            %START OF ITEM MARKER
            % ------- TeX.se Ignore this Line: Image Source Information 
            %
                % Added 18.4W
                \item \qtxt{%
                            Source-A-\color{blue}{Image 2}.
                            \begin{center}
                            \includegraphics[width=0.9\textwidth]{Source-A-Image-2.png}             
                            \end{center}
                            }\newpage%
            %
            % ======= End
            %END OF ITEM MARKER

                            \eject \pdfpagewidth=8.5in \pdfpageheight=1.8in
                            %START OF ITEM MARKER
                            % ------- TeX.se Ignore this Line: Image Source Information 
                            %
                                % Added 18.4W
                                \item \qtxt{%
                                            Source-A-\color{red}{Image-2 part 1 Soln }
                                            \begin{center}
                                            \includegraphics[]{Source-A-Image-2part-1Soln.png}              
                                            \end{center}
                                            }\newpage%
                            %
                            % ======= End
                            %END OF ITEM MARKER

                            %START OF ITEM MARKER
                            % ------- TeX.se Ignore this Line: Image Source Information 
                            %
                                % Added 18.4W
                                \item \qtxt{%
                                            Source-A-\color{red}{Image-2 part 2 Soln }
                                            \begin{center}
                                            \includegraphics[]{Source-A-Image-2part-2Soln.png}              
                                            \end{center}
                                            }\newpage%
                            %
                            % ======= End
                            %END OF ITEM MARKER



                            %START OF ITEM MARKER
                            % ------- TeX.se Ignore this Line: Image Source Information 
                            %
                                % Added 18.4W
                                \item \qtxt{%
                                            Source-A-\color{red}{Image-2 part 3 Soln }
                                            \begin{center}
                                            \includegraphics[]{Source-A-Image-2part-3Soln.png}              
                                            \end{center}
                                            }\newpage%
                            %
                            % ======= End
                            %END OF ITEM MARKER


            \eject \pdfpagewidth=8.5in \pdfpageheight=2.5in     
            %START OF ITEM MARKER
            % ------- TeX.se Ignore this Line: Image Source Information 
            %
                % Added 18.4W
                \item \qtxt{%
                            Source-A-\color{blue}{Image-3 }
                            \begin{center}
                            \includegraphics[width=0.9\textwidth]{Source-A-Image-3.png}             
                            \end{center}
                            }\newpage%
            %
            % ======= End
            %END OF ITEM MARKER
\end{itemize}

\end{document}

Sample Images Used for MWE Image 1 enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

  • Have you considered the standalone documentclass? – A.Ellett Oct 4 '18 at 21:10
  • @A.Ellett No, not for this, I haven't. I'm not really familiar with the documentclass. I used a template involving it for one project, but it was very limited and I didn't get much of a feel for it. If you think it'd be simple solution using standalone I'll get my hands on the documentation and see if it's within my grasp. Thank you for the reply! – Rax Adaam Oct 5 '18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.