I have a figure that is been generated by stitching many figures together. For captioning and clarity purposes, I want this figure split into its individual pieces. I have done that using subfloat and trim and clip. However, sometimes the sizes are, well, not round in value. For example, I want to split an image into 6 subfloats and thus the trim parameters need to trim between 0 and 0.1666.... the width of the image. I do that as follows:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\begin{document}
\begin{figure}
\centering
\captionsetup[subfigure]{labelformat=empty,justification=centering}
\subfloat[]{%
\centering
\begingroup
\sbox0{\includegraphics{example-image-a.png}}%
\includegraphics[trim=0 0 {.833333\wd0} 0,width=0.16\columnwidth,valign=c,clip]{exp_lsqr_diff.png}%
\endgroup
}%
\hspace{1em}
\subfloat[]{%
\centering
\begingroup
\sbox0{\includegraphics{exp_lsqr_diff.png}}%
\includegraphics[trim={.1666666\wd0} 0 {.6666666\wd0} 0,width=0.16\columnwidth,valign=c,clip]{exp_lsqr_diff.png}%
\endgroup
\captionsetup{justification=centering}%
}%
\hspace{1em}
\subfloat[]{%
\centering
\begingroup
\sbox0{\includegraphics{exp_lsqr_diff.png}}%
\includegraphics[trim={.3333333\wd0} 0 {.5\wd0} 0,width=0.16\columnwidth,valign=c,clip]{exp_lsqr_diff.png}%
\endgroup
}%
\hspace{1em}
\subfloat[]{%
\centering
\begingroup
\sbox0{\includegraphics{exp_lsqr_diff.png}}%
\includegraphics[trim={.5\wd0} 0 {.3333333\wd0} 0,width=0.16\columnwidth,valign=c,clip]{exp_lsqr_diff.png}%
\endgroup
}%
\hspace{1em}
\subfloat[]{%
\centering
\begingroup
\sbox0{\includegraphics{exp_lsqr_diff.png}}%
\includegraphics[trim={.6666666\wd0} 0 {.1666666\wd0} 0,width=0.16\columnwidth,valign=c,clip]{exp_lsqr_diff.png}%
\endgroup
}%
\hspace{1em}
\subfloat[]{%
\centering
\begingroup
\sbox0{\includegraphics{exp_lsqr_diff.png}}%
\includegraphics[trim={.8333\wd0} 0 {.0\wd0} 0,width=0.16\columnwidth,valign=c,clip]{exp_lsqr_diff.png}%
\endgroup
}%
\end{figure}
\end{document}
This works, but causes infinitesimal (yet visible) errors such as (very zoomed in):
I know they look small, but most renderers I tried (Chrome, Adobe Reader, overleaf) do in fact enhance this when looked from a zoomed out image, its quite visible under most zoom conditions. How can I solve this? Obviously I don't have enough space for all the decimals I need to be accurate, they may require (a few) monkeys with typewriters.
PD: note, that with example_image_a.png this is considerably less obvious to see. My images are 64x(64x6) and therefore the effect is more visible. With a much higher resolution image, this effect, albeit visible if you look for it, its less noticeable.




subfig, maybeadjustbox? What else? Your code does not compile. The reason you should include a working example is so that other users who want to help you don't have to guess at your preamble. It's not noise. Also, replacef.pngwithexample-image-a. – Sandy G Nov 18 '22 at 19:45\hspace*{-.9em}. At the least, you should remove that extra spacing (see https://tex.stackexchange.com/q/7453/107497). – Teepeemm Nov 18 '22 at 20:11\hspace*{-1px}. But I don't understand why you haven't done that. – Teepeemm Nov 18 '22 at 21:06\hspace: yeah, it changes the behaviour of the spacing, but it does not change the effect that I show in the image, at all. MWE added. – Ander Biguri Nov 21 '22 at 10:29}I should add}%to remove the small pixel chuncks cut? – Ander Biguri Nov 21 '22 at 10:34\wd0? – Teepeemm Nov 21 '22 at 14:37ImageMaskkey, but I'm not knowledgeable enough to be able to writepdfspecialcommands. // On the other hand, instead of cropping images by hand it's always possible to invoke an external command to crop from inside LaTeX with shell-escape, which would eliminate the amount of manual work (but some additional work is needed to avoid re-cropping the figures every time the document is compiled, which is a bit slow) – user202729 Feb 01 '23 at 01:37