Apply \intextsep at top of page

In trying to provide an answer to this question: Two column trouble - positioning of figures and text, I realized that I need to shift the wrapfigure up to account for the extra spacing that the \colorbox was adding. I adjusted the \intextsep length, which works fine, except at the top of a page. Note that the black box is not lined up with the top of the horizontal line, but the blue one is.

Apply \intextsep at top of page

I found many hackish solutions which "fix" this problem (but add a small amount of blank space at the top of the page), including: \smash{}, \llap{}, \rlap{}, \hphantom{}, \vphantom{}, \ which all get TeX to know that we are not at the top of a page so that \intextsep gets applied.


  1. What is the proper way to fix this spacing?
  2. How would I go about adding a zero height, zero width box at the top so that no space is added and that \intextsep gets applied, but makes TeX behave as if it is not at the top of page? Of course, an alternate solution to #1 may not require this, but am still interested in knowing.

Here is the code:

\documentclass{article} \usepackage[demo]{graphicx} \usepackage{wrapfig} \usepackage{xcolor}  \setlength{\parindent}{0pt} \setlength{\parskip}{\baselineskip}  \newcommand*{\WarningHead}[1]{%   \colorbox{black}{\parbox{\linewidth}{\color{white}\textbf{#1}}}\vspace{10px}% }  \newcommand*{\WrapFigure}[1]{%   \setlength{\intextsep}{-3pt}%   \begin{wrapfigure}{r}[0pt]{0.3\linewidth}%     \raggedleft% right align the figures     \includegraphics[width=0.95\linewidth]{#1}%   \end{wrapfigure} }%  \newcommand*{\lorem}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pellentesque iaculis nunc eget congue. Etiam lobortis nisi velit. Proin tristique massa a lectus ullamcorper semper. Aenean ut dignissim diam. Integer ullamcorper eros nibh. Cras molestie neque quis lectus lobortis egestas. Maecenas vel tortor in nulla sagittis venenatis. Nulla ac eros dui, eget lacinia ante. Fusce elementum nisl ac tortor hendrerit id lacinia orci malesuada. Praesent eu iaculis mi. Vestibulum sodales tempor rutrum. }  \begin{document}\ \WrapFigure{foo} \WarningHead{WARNING} \lorem  \color{blue} \WrapFigure{foo} \WarningHead{WARNING} \lorem \end{document} 


try it this way:


    \raggedleft% right align the figures

Apply \intextsep at top of page

to prevent the additional vertical space you can do


Just insert an instruction such as \phantom{a} right after \begin{document}. I wouldn't call it "hackish" at all. :-)

Category: spacing Time: 2011-11-08 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.116 (s). 12 q(s)