1

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}
  • 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. – John Kormylo Jun 29 '17 at 1:43
0

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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