| 1 |
\documentclass[pagesize=auto]{scrartcl} |
| 2 |
|
| 3 |
\usepackage{fixltx2e} |
| 4 |
\usepackage{etex} |
| 5 |
\usepackage{lmodern} |
| 6 |
\usepackage[T1]{fontenc} |
| 7 |
\usepackage{textcomp} |
| 8 |
\usepackage{microtype} |
| 9 |
\usepackage{hyperref} |
| 10 |
|
| 11 |
\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} |
| 12 |
\newcommand*{\pkg}[1]{\textsf{#1}} |
| 13 |
\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} |
| 14 |
\makeatletter |
| 15 |
\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} |
| 16 |
\makeatother |
| 17 |
|
| 18 |
\addtokomafont{title}{\rmfamily} |
| 19 |
|
| 20 |
\title{The \pkg{sphack} package\thanks{This manual corresponds to \pkg{sphack.sty}~v1.0, dated~22 May 1998.}} |
| 21 |
\author{Oliver Pretzel\thanks{\mail{[email protected]}}} |
| 22 |
\date{22 May 1998} |
| 23 |
|
| 24 |
|
| 25 |
\begin{document} |
| 26 |
|
| 27 |
\maketitle |
| 28 |
|
| 29 |
\noindent |
| 30 |
Standard \LaTeX\ uses the macros \cmd{\@bsphack}, \cmd{\@esphack}, and \cmd{\@Esphack}, for |
| 31 |
inserts into the text that should be invisible. So, for instance a space |
| 32 |
before and after a \cmd{\label} command should not result in two spaces in the |
| 33 |
output. |
| 34 |
|
| 35 |
\LaTeX\ deals with this as follows |
| 36 |
% |
| 37 |
\begin{itemize} |
| 38 |
\item in maths mode do nothing, |
| 39 |
\item in horizontal mode restore the space factor, |
| 40 |
\item if the last thing on the list was a space |
| 41 |
add \cmd{\ignorespaces} (and (\cmd{\global})\cmd{\ignore\-true} at the end of an environment), |
| 42 |
\item in vertical mode do nothing. |
| 43 |
\end{itemize} |
| 44 |
|
| 45 |
Doing nothing in maths mode is (nearly) harmless because maths mode does its |
| 46 |
own spacing (and anyway hidden commands will usually appear only at the start |
| 47 |
or end of maths). |
| 48 |
|
| 49 |
Doing nothing in vertical mode is not harmless. Many invisible commands such |
| 50 |
as \cmd{\index} may insert delayed write commands into \TeX's output (so that page |
| 51 |
numbers are correctly calculated). These commands can cause vertical space to |
| 52 |
accumulate, and may cause a page break; \cmd{\index} is a particular problem in |
| 53 |
\LaTeX2.09 since it inserts a delayed write if an index is actually being built |
| 54 |
(\cmd{\makeindex} in preamble) but does nothing otherwise. That can change the page |
| 55 |
breaks in a document. |
| 56 |
|
| 57 |
It is not possible to solve this problem completely in \LaTeX\ because \TeX\ does |
| 58 |
not remove things from the main vertical list once they have been |
| 59 |
contributed. So \LaTeXe\ makes \cmd{\index} insert something into the vertical |
| 60 |
list whether the index is being written or not. That has the virtue of |
| 61 |
consistancy, but is far from ideal. For instance, an \cmd{\index} immediately after |
| 62 |
an \cmd{\item} can cause the page to break between the item label and content. |
| 63 |
|
| 64 |
\pagebreak[2] |
| 65 |
|
| 66 |
The code in the \pkg{sphack} package remedies this fault and other common anomalies so that commands |
| 67 |
are nearly always invisible in vertical mode as well. It works as follows: |
| 68 |
% |
| 69 |
\begin{itemize} |
| 70 |
\item Rename \LaTeX's dimension \cmd{\@savsk} to \cmd{\@savdim} set a new skip \cmd{\@savsk} |
| 71 |
(because we need a true skip and a dimension in vertical mode) |
| 72 |
|
| 73 |
\item \cmd{\@bsphack} (at start of invisible command) |
| 74 |
\begin{itemize} |
| 75 |
\item in hmode (non-math) |
| 76 |
\begin{enumerate} |
| 77 |
\item store spacefactor in \cmd{\@savsf} |
| 78 |
\item store lastskip in \cmd{\@savsk} (used to test whether space already present) |
| 79 |
\end{enumerate} |
| 80 |
|
| 81 |
\item in vmode |
| 82 |
\begin{enumerate} |
| 83 |
\item store lastpenalty in \cmd{\@savsf} |
| 84 |
\item store lastskip in \cmd{\@savsk} (used for movement) |
| 85 |
\item store previous depth in \cmd{\@savdim} |
| 86 |
\item skip back \cmd{\lastskip} |
| 87 |
\end{enumerate} |
| 88 |
\end{itemize} |
| 89 |
|
| 90 |
\item \cmd{\@esphack} (at end of invisible command) |
| 91 |
\begin{itemize} |
| 92 |
\item in hmode (non-math) |
| 93 |
\begin{enumerate} |
| 94 |
\item set spacefactor = \cmd{\@savsf} |
| 95 |
\item if \cmd{\@savsk} > \cmd{\z@} \cmd{\ignorespaces} |
| 96 |
\end{enumerate} |
| 97 |
|
| 98 |
\item in vmode |
| 99 |
\begin{enumerate} |
| 100 |
\item if in a label, or just after section heading, or if \cmd{\@nobreak}\\ |
| 101 |
insert infinite penalty, (to prevent a page break)\\ |
| 102 |
else insert penalty \cmd{\@savsf}\\ |
| 103 |
endif |
| 104 |
\item set previous depth = \cmd{\@savdim} |
| 105 |
\item skip \cmd{\@savsk} |
| 106 |
\end{enumerate} |
| 107 |
\end{itemize} |
| 108 |
\end{itemize} |
| 109 |
% |
| 110 |
Just as in standard \LaTeX, \cmd{\@Esphack} is \cmd{\@esphack} + (\cmd{\global})\cmd{\@ignoretrue}. |
| 111 |
|
| 112 |
It is not necessary to change any of the label or index macros to fit with |
| 113 |
this code. |
| 114 |
|
| 115 |
\end{document} |