2

I have saved the summary of my neural network model as a .jpeg file. However, this image is way too large to fit into a single page. I searched through similar problems and tried to use the given answers I found here but they did not work. I attached the .jpeg file here so you can see the image. Can someone help me splitting this image over multiple pages so the boxes are clearly visible?? [![neural network summary][1]][1]

  • Can you be more specific about what you've tried and why it wasn't satisfactory? – Don Hosek Aug 6 '20 at 16:45
  • @DonHosek I want to trim my image in 3 to 4 parts (25 % of the whole image) and include each 25% on one page so all the boxes are visible and one can trace the whole network through the pages. – DSPinterested Aug 6 '20 at 17:00
  • 1
    This isn't a really good thing for latex to do. You will easiely get weird cuts like in the middle of a box and that would look wird. You should look into your editing program, which created the .jpg file and see if it can create multiple file or cut it by hand using your editor of choise. You could do it by hand in latex using the crop parameters, but that's no fun – Cube Aug 6 '20 at 17:46
  • 1
    @DSPinterested, how else do you expect to get such a huge image on several pages while it still being readable? If it is only a question of the amount of pages, you can always change 1522x1100 to 1522x2200 or anything else you prefer. – phil-elkabat Aug 7 '20 at 10:40
1

Here is a solution using only one image:

This creates a new macro with two parameters, the number of the part and the total number. It than calculates and trims away the rest of the image.

\documentclass[11pt,a4paper]{article}
\usepackage{adjustbox}
\usepackage{fp}

\newcommand{\cropImg}[2]{
    \FPeval{\top}{#1 / #2}
    \FPeval{\bot}{(#2-#1-1) / #2}
    \adjincludegraphics[
            width=\textwidth,
            trim={0 {\bot\height} 0 {\top\height}},
            clip, % needed for trim to work
        ]{Grntv.jpg}
}

\begin{document}

    \cropImg{0}{11}
    
    \cropImg{1}{11}
    
    \cropImg{2}{11}
    
\end{document}

Some more explanation:

Using the adjustbox package allows for use of the heigt and width of the current image for calculations. By this we can only show the parts of an image we want. I also use the fp package to evaluate a math-expretion to get the percantages above and below, if we want a certain part of a set. So for example, for the first(0) part we want to crop nothing above, keep 1/11 and crop 10/11 below. And so on.

You will need to experiment arround, how many parts work best for you, by changing the 2. Parameter.

Downsides:

  • I don't know if there are any downsides to using the adjustbox package this way, it might still include the howl image in the final pdf and justvnot show it(increased filesize).

  • No tweaking of the made cuts is possible, bedsides changing the number of total cuts.

  • Your answer is almost perfect (for me), thank you! some boxes and the information inside them do get cut, how can I fine-tune your answer above for a better cut? or what parameter should I tweak so it gets a perfect cut (all boxes and their info are present throughout the pages). – DSPinterested Aug 8 '20 at 20:44
  • Also, can you please tell me how I can include all the images as one figure, so all the pages show up as one figure in the list of figures section ?? It would be really nice if the last page which includes the last part of the image had a caption but the list of figures would point to that specific page where the image begins. – DSPinterested Aug 8 '20 at 21:14
  • Sorry for the late reply, I edited my answers to answers some of your questions better. – Cube Aug 9 '20 at 19:52
  • To get a continuous figure, have a look here. Putting the caption unter the last figure shoudnt be hard. Just put it there in the source code. To get the hyperlinke anchor on the first figure, experiment arround with \phantomsection and do some more research. Or just don't, nobody will notice probably XD – Cube Aug 9 '20 at 20:01
  • To get more precise cuts, you can of course use the code on every acourence separately, instead as a macro. Than you could just add to the bottom and top parameters as needed. Just replace every #1 and #2 with the numbers you would put in the curry brackets – Cube Aug 9 '20 at 20:08
2

The problem

Can someone help me splitting this image over multiple pages so the boxes are clearly visible??

One solution

I think ImageMagick can help you here:

First you determine the size of the image (in pixels) which will give you

Width: 1522 Pixel
Height: 11875 Pixel

Then you determine how many pages you want. For three pages it would be

11875 ÷ 3 = 3958.34 Pixels

So you feed convert with a crop factor of 1522x3959 (rounded).

The following will give you eleven files:

convert Grntv.jpg -crop 1522x1100 +repage paged-output.jpg

This will give you eleven files which in turn will make it possible to include the graphics. Tweak the code as you see fit, I didn't try for long, but you can see where this leads to using landscape as page orientation:

\documentclass[landscape]{scrartcl}
\usepackage{graphicx}
\usepackage[margin=2cm]{geometry}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[width=.8\textwidth]{paged-output-0.jpg}
    \caption[Some diagram of my project.]{Some diagram of my project. Continues in subsequent pages.}\label{fig:neural network model}
\end{figure}
\clearpage
\begin{center}
    \includegraphics[width=.8\textwidth]{paged-output-1.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-2.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-3.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-4.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-5.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-6.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-7.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-8.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-9.jpg}\clearpage
    \includegraphics[width=.8\textwidth]{paged-output-10.jpg}
    
\end{center}

\end{document}

It will look like this:

Diagram in many pages

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.