0

I am trying to inset a single small image over the top of two larger figures separately on the same page, within a floatrow \ffigbox environment, but it seems as though floatrow has a problem with doing this kind of thing (overpic, which was a bit easier to use, had the same issue - most people seem to use tikz though?).

I was able to add my inset image within the floatrow environment ok, the problem is that the figure on the following page is now being replaced by the smaller inset figure.

I did find this answer to another question which seems like it is probably related, but the answer there looks pretty complicated.

tikz externalisation floatrow

I would avoid using floatrow, but it is included inside another package I am using elsewhere in the document. Commenting out the auto-pst-pdf package also fixes the problem, but this is also something I want to use. Is there a way I can make all of these things work together?

MWE:

\documentclass[11 pt]{report}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage{graphicx} 
\usepackage{floatrow}
\usepackage{tikz}

\begin{document}

\begin{figure}[htbp]
\centering

\begin{floatrow}
\ffigbox[\FBwidth]{%
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0)     {\includegraphics[width=0.9\textwidth]{images/bigimage1}};
     \begin{scope}[x={(image.south east)},y={(image.north west)}]
                    \node[anchor=south west,inner sep=0] (image) at (0.05,0.65){\includegraphics[scale=0.8]{images/smallinset1}};
             \end{scope}
\end{tikzpicture}
}%
    {\caption{caption1}}
 \end{floatrow}

 \begin{floatrow}
\ffigbox[\FBwidth]{%

\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0)     {\includegraphics[width=0.9\textwidth]{images/bigimage2}};
         \begin{scope}[x={(image.south east)},y={(image.north west)}]
                   \node[anchor=south west,inner sep=0] (image) at (0.05,0.65)    {\includegraphics[scale=0.8]    {images/smallinset1}};
             \end{scope}
    \end{tikzpicture}
    }%
    {\caption{caption2}}
\end{floatrow}

\end{figure}

\clearpage
\begin{figure}[ht]
\centering
\includegraphics[scale=0.8]{second large figure}
\caption{wrong image appears here}
\end{figure}

\end{document}

This is what I am getting currently:

enter image description here

The first page is fine, the images have overlaid correctly, but for some reason figure 3 is being replaced by the first inset figure.

edit: When compiling I get this error -

Package pst-pdf Warning: `untitled-2-pics.pdf' contains 7 pages but 3 pages are requested: File `untitled-2-pics.pdf' is no more valid! Recreate it .

Looking at this file, the first inset figure (small inset) appears 6 times, and the figure that I want to be in figure 3 is on the last page. so I think it is something to do with floatrow calling that image too many times?

  • (i) your images are to big that can be fit on the page, (ii) small image is over big one, but not on the top, they partly overlap, (iii) floatrow doesn't has anything with images positions. can you provide a sketch which show what you like to obtain? – Zarko Jan 15 '18 at 5:52
  • I have updated my post to show what I am trying to achieve, and what the problem is. Figure 3 should be a different image to the one that is shown. Disabling auto-pst-pdf and recompiling will force it to revert to the proper image - but as I said, I need this in other parts of the document. – Dylan Jan 16 '18 at 1:00
0
  • sorry, but your question is not clear, so here i only show my guessing what is your problem. hopefully with this you will be able more clear explain (by editing your question), what is the your problem
  • i assume, that image are stored in subfolder and that they are in pdf format
  • if the image 3 is not desired one, than the path and image name has a some error
  • since i haven't your images i replace it with demo images from graphicx package

enter image description here

enter image description here

  • for placement of images i simplified code for tikzpicture
  • as you can see, i change appearing small image on the big one. if my change not gives what you like to have, than you can simple change this
  • code for image positioning is simplified, floatrow in the first figure is omitted since it only the size of image (because it reduce \FBwidth) and hasn't other effect on images.

\documentclass[11 pt]{report}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}[htbp]
\centering
\tikzset{every node/.style = {inner sep=0pt, outer sep=0pt},
         node distance = 3pt and 3pt% set distance according your needs
         }
%\begin{floatrow}
\ffigbox[\FBwidth]{%
    \begin{tikzpicture}
\node (image) {\includegraphics[width=0.9\linewidth]{example-image-a}};%big image
\node[below right=of image.north west] {\includegraphics[scale=0.4]{example-image-b}};% small image
\end{tikzpicture}
                }{\caption{caption1}}

\bigskip
\ffigbox[\FBwidth]{%
    \begin{tikzpicture}
\node (image) {\includegraphics[width=0.9\linewidth]{example-image-a}};%big image
\node[below right=of image.north west] {\includegraphics[scale=0.4]{example-image-b}};% small image
\end{tikzpicture}
                }{\caption{caption2}}
%\end{floatrow}
\end{figure}

\begin{figure}[ht]
\centering
\includegraphics[scale=0.8]{example-image}%big image
\caption{wrong image appears here (this i cant check because you not provide path and name of this image. my replacement for it work as expected)}
\end{figure}

\end{document}
  • I tried to implement your answer into my document, but I still get the image being reproduced error. Placing your entire answer into a new document does give the same output as you received. Maybe it is an issue with my image files then? The large image is pdf, but the small ones are eps - I am using pdflatex in miktex if that would have any effect? – Dylan Jan 16 '18 at 4:43
  • Ok. Had another look through the files for my MWE. One of the packages (tikz I guess?) is automatically converting my eps file to a pdf and naming it: file-eps-converted-to.pdf ...directing my document to use this file instead gets it to work correctly. I didn't realise tikz didn't like eps files? – Dylan Jan 16 '18 at 4:55
  • it is not tikz but pdf. i emphasize, that this work, if all images are in pdf format. the simplest way is convert all eps images to pdf with some external tool or gives names of converted images. maybe will help if you add to preamble \usepackage{epstopdf} – Zarko Jan 16 '18 at 5:00

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.