[Tex/LaTex] How to put a picture to the top right of a page

diagrams

I have written in TeX the following:

\section{A}
... somethingA ...

\begin{picture}(100, 100)(-250, -110)
\includegraphics[scale=1]{face.png}
\end{picture}

\section{B}
... somethingB ...

I have put specific parameters in picture (-250, -110) so that the picture is added in the top right of the created page. Although this works just fine, face.png appears where I want it, the problem is that there is a big gap between somethingA and somethingB. So I have something like this in the created document:

... somethingA ...





... somethingB ...

Any ideas how to solve this?

Best Answer

There are several possibilities:

  1. Using the eso-pic package:

    \documentclass{article}
    \usepackage[demo]{graphicx} 
    \usepackage{eso-pic} 
    \usepackage{lipsum} 
    
    \begin{document}
    \lipsum[1-3]
    \AddToShipoutPicture*
        {\put(500,700){\includegraphics[width=3cm,height=2cm]{image}}}
    \end{document}
    

enter image description here

  1. Using TikZ:

    \documentclass{article}
    \usepackage[demo]{graphicx} 
    \usepackage{tikz}
    \usepackage{lipsum} 
    
    \begin{document}
    \lipsum[1-3]
    \begin{tikzpicture}[overlay, remember picture]
      \node[xshift=-3cm,yshift=-2cm] at (current page.north east) {\includegraphics[width=3cm,height=2cm]{image}};
    \end{tikzpicture}
    
    \end{document}
    

enter image description here

Related Question