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]
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
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:
crop
parameters, but that's no fun – Cube Aug 6 '20 at 17:461522x1100
to1522x2200
or anything else you prefer. – phil-elkabat Aug 7 '20 at 10:40