Search code examples
latextikz

Ignore margins and wrap text when adding pictures in Latex


I would like to add images in the top left/right or bottom left/right in a two-column page while ignoring the margins and having the text wrap around the picture. How can I also extend the solution to include half page images while ignoring the margins and with text wrapping.

I tried tikz package, but the text doesn't wrap around even when I use the wrapfig package.

For example, this is the code I used to insert image on the top left side of the page:

\documentclass[twocolumn, 12pt]{book}

\usepackage{lipsum}
\usepackage{tikz}

\begin{document}

    \lipsum[1-3]

    \begin{tikzpicture} [remember picture, overlay]
        \node[anchor=north west,yshift=-1.5pt,xshift=1pt]%
            at (current page.north west)
        {\includegraphics[width=0.5\paperwidth,height=0.5\paperheight]{example.jpg}};
    \end{tikzpicture}

    \lipsum[1-3]

\end{document}

This results in the picture at the desired position, but the text is obscured behind the image. Thank you!


Solution

  • Not very pretty, but does the job I think (using geometry package only to get the correct values for top margin):

    \documentclass[twocolumn, 12pt]{book}
    
    \usepackage{lipsum}
    \usepackage{tikz}
    \usepackage{geometry}
    
    \begin{document}
    
        \begin{tikzpicture} [remember picture, overlay]
            \node[anchor=north west]%
                at (current page.north west)
                {\includegraphics[width=0.46\paperwidth,height=0.5\paperheight]{example.png}};
        \end{tikzpicture}
        \vspace*{\dimexpr(0.5\paperheight-\voffset-1in-\headsep-\headheight)}
        
        \lipsum[1-3]
        \lipsum[1-3]
    
    \end{document}
    

    text correctly wrapping around the image