13

LaTeX offers a number of commands that can be used in macros that want to be invisible i.e., not leave any extra space when used in the middle of text. These macros include \@esphack, \@bsphack, \@Esphack, \@vbsphack and can be found in ltspace.dtx.

Amongst all these commands \@vbsphack stands alone as it is described in the source, but not implemented and commented as follows:

Another variant which is useful for invisible things which should not live in vmode (this is how some people feel about marginals). If it occurs in vmode then it enters hmode and ensures that \@savsk is nonzero so that the \ignorespaces is put in later. It is not used at present.

The macro definition is copied below:

\def \@vbsphack{ %
\relax \ifvmode
\leavevmode
\@savsk 1sp
\@savsf \spacefactor
\else
\ifhmode
\@savsk \lastskip
\@savsf \spacefactor
\fi
\fi
}

Can someone explain why should the \@savsk should be non-zero? The explanation offered in the source is not very clear.

Lastly as I am sure the name of these macros is not a lisp relic, can anyone offer the origin or history of how the family name was derived?

yannisl
  • 117,160

2 Answers2

15

I can help at least on the naming: these are 'space hacks' to try to avoid messing up spacing with commands that 'do nothing' in output terms. So you have \@bsphack = 'begin space hack', \@esphack = 'end space hack'. I think \@Esphack is intended only for floats, but on this I'm not certain.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • Thanks for clarifying it! I was going to ask a colleague about it but I was afraid he was going to swear back at me:) – yannisl Jan 04 '11 at 19:17
8

Joseph answered the naming question (I have always liked the idea of an esp hack).

The reason for making \@savsk nonzero is because it moves into horizontal mode (\leavevmode) and \@esphack checks if \@savsk is positive. If it is, then it uses \ignorespaces to gobble space tokens (as the quote says).

I'm not terribly sure I follow what this could be used for though.

TH.
  • 62,639