2

I would like to align the picture to the top of the text, specifically the line where the text starts (ascender). As you can see, there's still a small gap. How can I remove this space?

enter image description here

MWE:

\documentclass[a4paper,DIV=15,oneside,12pt]{scrartcl}
\usepackage[english]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{wrapfig}

\parskip 0pt
\parindent 0pt

\begin{document}
\onehalfspacing
\begin{wrapfigure}{r}{4cm}
\centering\rule{3cm}{2cm}
\end{wrapfigure}
\blindtext
\end{document}
1
  • 1
    You have to remember that \rule aligns the top \lineskip below the bottom of the previous line, while text aligns the baseline (about \topskip below the top} to be \baselineskip below the previous baseline. So even setting \intextskip=0pt will still leave a \lineskip gap. \intextskip=-\lineskip will fix that. Jun 29, 2017 at 1:43

1 Answer 1

1

The difference seems to be about 2pt. You can use the first optional argument of \raisebox{0pt} to fool LaTeX and make it believe the figure is 2pt less high than it is really:

\documentclass[a4paper,DIV=15,oneside,12pt]{scrartcl}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{wrapfig}

\parskip 0pt
\parindent 0pt

\begin{document}

\onehalfspacing
\begin{wrapfigure}{r}{4cm}
  \centering\raisebox{0pt}{\raisebox{0pt}[\dimexpr\height-2pt]{\rule{3cm}{2cm}}}
\end{wrapfigure}
\blindtext

\end{document} 

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .