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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my document I need to show some labels in draft mode. But they should have zero height and depth (the purpose is not to affect on resulting text: all exept labels should be the same in both draft and release modes). But if my label used to be before section title, latex don't omit leading \vspace. This is an MWE:

\documentclass[12pt]{report}
\usepackage[english]{babel}
\begin{document}
\vspace{3cm}
Here we see that \verb'\vspace' omits.\pagebreak

\vbox to 0pt{\raisebox{0pt}[\height][0pt]{some text}}
\vspace{3cm}
But here it presents!

\end{document}

Even trick with \raisebox didn't help me.

The only variant I see is to make \newif like \ifomitvspace and to say \omitvspacetrue in macro, that creates comment, then \title should make a check and don't do \vspace if \ifomitvspace. To turn off this I should do \everypar{\omitvspacefalse}. But I think, this is ugly.

UPD Unfortunately, I didn't find a way to struggle within vertical spaces in paracol environment. As it redefines \everypar, answer of David Carlisle don't work. My guess to use some flag and redefine \@vspace also don't work (because it omits all spaces instead of only top). It is sad.

share|improve this question
1  
The macro \smash{} sets its argument height and depth to zero. – Steven B. Segletes Feb 29 at 13:13
    
@StevenB.Segletes If you really believe that it's this simple, go ahead and answer the question. – yo' Feb 29 at 13:39
    
@StevenB.Segletes, anyway, it won't remove \vspace – Eddy_Em Feb 29 at 13:40
    
\begin{picture}(0,0)\put(0,0){some text}\end{picture}, though this removes the width too. \vspace is removed as requested. – AlexG Feb 29 at 13:51
1  
@alexis no the main problem is that discardable items are discarded at the top of a page but by placing a box there even zero sized the skip is not at the top of the page and not discarded, using picture mode (unlike the example in the question) does have the additional disadvantage of starting h mode. – David Carlisle Feb 29 at 14:15
up vote 5 down vote accepted

It's tricky in general, you could look how color or showkeys packages try to avoid affecting position of the original text (without total success).

The expl3 l3galley code tackles this by taking full control of vertical mode, which works if everything obeys the rules, but in latex2e with unconstrained access to latex and tex primitives adding to the vertical list that isn't really an option.

I would delay any vertical mode use until the next paragraph starts, where things are easier to control:

enter image description here

\documentclass[12pt]{report}
\usepackage[english]{babel}
\let\oldeverypar\everypar
\oldeverypar{\the\everypar\the\mynotes\global\mynotes{}}
\newtoks\mynotes
\protected\long\def\mynote#1{%
\ifvmode
\global\mynotes\expandafter{\the\mynotes\smash{\raise\baselineskip\rlap{#1}}}%
\else
\smash{\raise\baselineskip\rlap{#1}}%
\fi}

\newtoks\everypar
\begin{document}
\vspace{3cm}
Here we see that \verb'\vspace' omits.\pagebreak

\mynote{some text}
\vspace{3cm}
But here it presents!

\end{document}
share|improve this answer
    
This isn't a solution: you just put note after \vspace. Try to add after 'but here it presents' this: \vspace{4cm} \mynote{another note} \vspace{4cm} Text. You will see, that second \vspace don't suppressed. – Eddy_Em Feb 29 at 14:20
    
My mistake, subsequent \vspaces are summing, so your answer is right! – Eddy_Em Feb 29 at 14:37
    
@Eddy_Em naturally:-) – David Carlisle Feb 29 at 14:37
    
But I think, I should make my own answer: your variant don't work with paracol enwironment. – Eddy_Em Feb 29 at 14:51

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.