[Tex/LaTex] How to reduce top margin of wrapfigure

wrapfigure

I'm writing a document with a wrapfigure and its part looks like this:

~~~~~~~~~~~~~~~~~~~~~~
~~~~~~   
  ~~~~~~~~   ________
~~~~~~~~~~  |        |
~~~~~~~~~~  | Figure |
~~~~~~~~~~  |________| 
~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~

How can I reduce the margin at the top of the figure by \baselineskip so that it looks like this:

~~~~~~~~~~~~~~~~~~~~~~
~~~~~~       ________
  ~~~~~~~~  |        | 
~~~~~~~~~~  | Figure |
~~~~~~~~~~  |________|
~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~

Here is a MWE with a simplified figure:

\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
\lipsum[1]

\begin{wrapfigure}{r}{0pt}
  \begin{tikzpicture}[inner sep=0pt, outer sep=0pt]
    \node (A) {A};
    \node[above right] (B) at (A.north east) {B};
    \draw (A.south west)--(B.north east);
  \end{tikzpicture}
\end{wrapfigure}
\lipsum[2]
\end{document}

Best Answer

Another simple solution would consist in making LaTeX believe the figure height is smaller than it really is, thanks to the optional arguments of the \raiseboxcommand. Here is a code:

        \documentclass[11pt, a4paper]{article}
        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{lmodern}

        \usepackage{kantlipsum, wrapfig,graphicx}

        \begin{document}

        Here is some text to fill up the first line and give some typing practice to me.

        \begin{wrapfigure}{r}{0pt}
        \raisebox{0pt}[\dimexpr\height-0.6\baselineskip\relax]{\includegraphics{airepara}}%
        \end{wrapfigure}
        \kant[1]

        \begin{wrapfigure}{r}{0pt}%
        \raisebox{0pt}[\dimexpr\height-0.6\baselineskip\relax]{\includegraphics[width=3cm]{airepara}}%
        \end{wrapfigure}
        \kant[2]

        \end{document}

enter image description here

Related Question