0

I have a feathered graphic which extends beyond its bounding box. It blends into the background, and is not supposed to interfere with main text setting. Unfortunately, text set before the graphic is occluded by it.

Feathered image occludes text set before it

Here's a MWE:

\documentclass{tufte-book}

\usepackage{graphicx} \usepackage[export]{adjustbox}

\begin{document}

Ultrices mi tempus imperdiet nulla. Mauris commodo quis imperdiet massa tincidunt nunc pulvinar. Risus viverra adipiscing at in tellus. Et sollicitudin ac orci phasellus egestas tellus rutrum. Elit eget gravida cum sociis. Ut tristique et egestas quis. A scelerisque purus semper eget duis at. Nunc aliquet bibendum enim facilisis. Consectetur lorem donec massa sapien faucibus et molestie.

\begin{figure}[h!] \includegraphics[width=6\linewidth, max width=\linewidth, trim={\linewidth\real{2.5} 11cm \linewidth\real{2.5} 10.5cm}]{image.png} \caption{Sem et tortor consequat id porta nibh} \end{figure}

Eget arcu dictum varius duis at consectetur lorem donec. Pulvinar sapien et ligula ullamcorper. Facilisis sed odio morbi quis commodo odio. Magna sit amet purus gravida quis blandit turpis. Platea dictumst quisque sagittis purus. Curabitur vitae nunc sed velit dignissim sodales ut eu. Eleifend donec pretium vulputate sapien nec.

\end{document}

I've seen similar questions (here, and here) asked with quite simple methods of addressing the actual layout obstacle, and so there doesn't seem to be a general solution yet. I also understand that LaTeX doesn't have a layered output, and so a creative approach may be required.

[h!] is set for the purpose of this demo, but context to figures is generally quite important and so I'd really prefer not forcing [t] position to circumvent the issue. I also don't want to reduce the feather, as the bounds become quite obvious below this level.

Liam
  • 3
  • 2
    You can put the figure on the page background. However, as you do not provide us with a complete code, it is a bit hard to guess how this can be done neatly in your case. –  Jul 02 '23 at 03:06
  • Welcome! It is indeed hard to guess without a minimal code example we can compile. Maybe https://www.ctan.org/pkg/background. There is also flowfram and more specialist packages for various use cases. There are general solutions but not general enough to answer your question in general! I'm guessing something like: put the image in the background and put an empty box where the image is might work. But you can't do that with a float. Don't make it a figure if you don't want it to float. – cfr Jul 02 '23 at 03:21
  • Thank you @cfr — I've added a compilable MWE! The figure is ideal for caption numbering and lists, but willing to forgo that if I need to. I will have a look at flowfram. – Liam Jul 02 '23 at 03:28
  • The capt-of package allows captions outside floats. – Cicada Jul 02 '23 at 08:15

1 Answers1

1

I do not have your graphics file example.png, and choose to base this example on a more common document class. However, I believe that you can use the macro \BackgroundPicture in your scenario, too. It puts the picture on the background.

\documentclass{article}

%\usepackage{graphicx} \usepackage{tikzpagenodes}% loads tikz which loads graphicx \usepackage{eso-pic}

\newcommand{\BackgroundPicture}[2][]{% \begingroup\tikzset{/BackgroundPicture/.cd,#1}% \setbox0\hbox{#2}% \vspace{\pgfkeysvalueof{/BackgroundPicture/before}}\par% \begin{tikzpicture}[remember picture] \nodeinner sep=0pt,outer sep=0pt,opacity=0, minimum width=\wd0,minimum height=\ht0 {}; \end{tikzpicture}\par% \vspace{\pgfkeysvalueof{/BackgroundPicture/after}}% \AddToShipoutPictureBG*{\begin{tikzpicture}[overlay,remember picture] \path (BackgroundPicture) node{#2}; \end{tikzpicture}}% \endgroup} \tikzset{/BackgroundPicture/.cd,before/.initial=0cm,after/.initial=0cm}% \begin{document}

Ultrices mi tempus imperdiet nulla. Mauris commodo quis imperdiet massa tincidunt nunc pulvinar. Risus viverra adipiscing at in tellus. Et sollicitudin ac orci phasellus egestas tellus rutrum. Elit eget gravida cum sociis. Ut tristique et egestas quis. A scelerisque purus semper eget duis at. Nunc aliquet bibendum enim facilisis. Consectetur lorem donec massa sapien faucibus et molestie.

\begin{figure}[h!] \centering \BackgroundPicture[before=-2cm,after=-1cm]{\includegraphics[width=0.9\linewidth]{example-image}} \caption{Sem et tortor consequat id porta nibh} \end{figure}

Eget arcu dictum varius duis at consectetur lorem donec. Pulvinar sapien et ligula ullamcorper. Facilisis sed odio morbi quis commodo odio. Magna sit amet purus gravida quis blandit turpis. Platea dictumst quisque sagittis purus. Curabitur vitae nunc sed velit dignissim sodales ut eu. Eleifend donec pretium vulputate sapien nec.

\end{document}

enter image description here

This is merely a proof of principle. As you can see, you can cut some vertical space after and, in particular, before the picture by feeding negative values to after and/or before, respectively.