3

I have various \vspace commands spread in a large document. Can I make them all visible by re-defining it somehow in the preamble?

I have positive and negative arguments to it. I imagine negative vspaces might be shown as a red vertical bar of some length (say 3cm, in the page background?) and positve ones as a green bar.

The actual space the command or the text uses should not be changed.

This could be an excerpt:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

\vspace{-0.5pc}

Nunc in ultrices ante, sit amet aliquam enim. 
Mauris auctor ornare nulla, ac elementum nibh dapibus vitae.

\vspace{1pc}

Aliquam accumsan, metus vitae lobortis maximus, ligula 
tellus vehicula ipsum, eu posuere augue dolor nec est.
\vspace{-0.2pc}

Aenean id felis sit amet odio pulvinar suscipit quis sed nulla. 
Donec sit amet sapien iaculis purus ultricies ornare. 

Sometimes the \vspace is between paragraphs, sometimes it is attached to its end or beginning.

I played around with \rule TikZ and overlays but could not at all get it to work.

Update:

I replaced all \vspace in the doc with \tvspace and defined that as:

\newcommand{\tvspace}[1]{%
\vbox to0pt{\rlap{%
  {\color{red}\rule{1pt}{\dimexpr#1*-1}}%
  {\color{green}\rule{1pt}{#1}}}%
}\vspace{#1}%
}

That seems to solve the horizontal box problem (\rlap), but the vertically the overlap seems not to work at all. I do not understand enough of how the boxes work.

With my color bars: https://imgur.com/a/38p2X

Without my color bars: https://imgur.com/a/QrZs8

Alas, not non-intrusive at all.

The tvspace in question is here:

\tvspace{-0.5pc}In diesem Kapitel...
  • Have a look at Lua-visual-debug package – Michael Fraiman Nov 23 '17 at 19:34
  • Thanks, I will, out of curiosity. But LuaTeX is not an option. I have to use pdftex. – towi Nov 23 '17 at 19:36
  • 1
    Normally a large document with a lot of manual \vspace has a 'bigger' problem. Why do you have to use the command so often? – Dr. Manuel Kuehner Nov 23 '17 at 20:12
  • @Dr.ManuelKuehner Quite sure the "bigger problem" is only the strict wished of the customer. I don't have "so many", like its on every page. But on some pages (say, 1/10th) I squeezed a tiny little bit, for example to get the last line of the listing onto the page. After I finished the whole document a central property changed (margin before second level heading). And I hope I don't have to start over from scratch but see where my old \vspaces are useless because the page break shifted. – towi Nov 23 '17 at 20:24
4

This is enough?

mwe

\documentclass{article}
\usepackage{xcolor}
\def\vspace#1{%
{\color{red}\rule{1pt}{\dimexpr#1*-1}}%
{\color{green}\rule{1pt}{#1}}}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

\vspace{-0.5pc}

Nunc in ultrices ante, sit amet aliquam enim. 
Mauris auctor ornare nulla, ac elementum nibh dapibus vitae.

\vspace{1pc}

Aliquam accumsan, metus vitae lobortis maximus, ligula 
tellus vehicula ipsum, eu posuere augue dolor nec est.

\vspace{-0.2pc}

Aenean id felis sit amet odio pulvinar suscipit quis sed nulla. 
Donec sit amet sapien iaculis purus ultricies ornare. 

\end{document}
| improve this answer | |
  • Almost, but not quite. If the vspace is heading or trailing the paragraph it seems to create a horizontal box. See imgur.com/a/XZGgP And if I am not mistaken, no \vspace is applied, either, in that case... I think? – towi Nov 23 '17 at 20:30
  • (1) If it seem sometimes a horizontal box is just because the vertical space is small and it appear just were \vspace was inserted but it is always a vertical line. (2) \vspace is always applied except on top of page, but within a paragraph have no effect until the line break. Try lorem \vspace{10em} ipsum .... with/without the macro a you will see clearly. ` – Fran Nov 24 '17 at 2:17

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.