Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
    
@UlrikeFischer Thanks. I want to reduce only the top margin. –  krnk Feb 15 at 12:09
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
This worked fine. Thanks! –  krnk Feb 16 at 1:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.