“Hey — it works!”

Jeremy Gibbons University of Auckland

                                            jeremy@cs.aukuni.ac.nz

Hello, and welcome once again to “Hey — it works!”. This column is devoted to elegant solutions to little TEX or L^{A}TEX problems. Last time I cited Jon Bentley’s “Programming Pearls” (in Communications of the Association for Computing Machinery) and Richard Bird’s “Functional Pearls” (in the Journal of Functional Programming) as influences. For those of you not in my field, I paraphrase Bentley: “just as natural pearls grow from grains of sand that have irritated real oysters, these TEXnical pearls have grown from real problems that have irritated real TEXnicians”. If you have any such pearls, please send them in to me at the above address; my collection of material is running rather low!

In this issue we have four items: a rather neat idea from David Salomon on allowing any two consecutive pages to be visible at the same time, a piece of my own on the headings in this column, one from Gerree Pecht on a ‘double summation’ sign, and one from Kees van der Laan on producing ‘matrix icons’ using L^{A}TEX’s picture environment.

A page-numbering scheme _{David Salomon California State University, Northridge dxs@ms.secs.csun.edu}

In standard English texts the right-hand pages are odd numbered and the lefthand ones, even numbered. This has the disadvantage that the reader cannot always see two consecutive pages at the same time. The document can be opened, e.g., to pages 2 & 3, but not to pages 3 & 4.

The page numbering scheme proposed here makes it possible to see any pair of consecutive pages simultaneously. The rules are:

1. The first right-hand page should not be used for text (but it can be used for other things, such as a dedication or a trademark declaration).

2. Page 1 should be the second right-hand page, and page 2, the first left-hand one. Page 3 should be the third right-hand page, and page 4, the one on its left.

It is thus easy to see pages 1 & 2 simultaneously, and also 3 & 4. To see pages 2 & 3, just hold the second sheet of the document (the one with pages 1 & 4) vertically.

This scheme may be useful for technical documents. The output routine can easily be modified to eject pages in the order 2,1,3,4. . .. The first time it is executed, the output routine should save \box255 in a box register. The second execution should shipout that register, then shipout \box255. A boolean variable can be used to switch between even and odd executions.

Addresses in headings Jeremy Gibbons

The headings for individual pieces in this column each have the author’s name and address flushright beside the flushleft title. When I inherited this column, this was achieved by some negative spacing—for example, in the source for TTN 2,1:10, we have

\subsection*{DC fonts --- questions and answers (II)}
\vspace{-1.5pc}
\begin{flushright}
   Yannis Haralambous \\
   \tt yannis@gat.citilille.fr
\end{flushright}

This hard-wired -1.5pc is contrary to good logical markup principles: it is hard to get right (indeed, I think Yannis’ name came out a little too low), and depends invisibly on the choice of font and typesize, the spacing inserted by flushright, etc. To avoid this problem, I wrote the macro \squashedsubsection; with

\squashedsubsection{DC fonts --- questions and answers (II)}
                   {Yannis Haralambous \\
                    \tt yannis@gat.citilille.fr}

you get the same effect without having to guess the -1.5pc.

\def\squashedsubsection#1#2{%
   \subsection*{%
      \hbox to \linewidth{%       make a box as wide as the page
         #1%                      subsection title
         \hfil%                   stretchy space
         \llap{\normalsize%       ignore width of tabular
            \begin{tabular}[t]{r@{}}
                #2%               author's name and address
            \end{tabular}}}}}

Note: no attempt is made to avoid a collision between the title and the author’s name!

A double summation sign _{Gerree Pecht Princeton University gerree@math.princeton.edu}

Recently, I had to solve the problem of producing a ‘double summation sign’, requiring fine spacing between the summation signs and the precise centering of the mathematical subscript beneath them.

The documentation available was not applicable to my needs. Therefore, with judicious use of horizontal spacing and experimenting with numbers, I solved my problem as illustrated below; the L^{A}TEX source

\[
   S ({\cal A}, {\cal B})
      \, = \,
   \sum \hspace{-.4em} \sum_{\hspace{-.98em}(a,b)=1}
   \hspace{.8em}
   \sum_{d | b} \:
   \mu^2\,(d) \, \left( \frac{ar}{d} \right)
\]

yields the equation

S(A, B) = ∑ ∑_{(a,b)=1} ∑_{d|b} μ^{2} (d) (\frac{ar}{d} )

This solution may not be the perfect solution to those with a similar problem for the following reasons:

• the need to experiment to get the numbers right;

• the need to repeat the experiment if the font or type size is changed, or for a different subscript to the double sum.

As an alternative, it was suggested that a more elegant approach to solving this problem might involve constructing an explicit ‘operator’ consisting of two summation signs:

\def\doublesum{\mathop{\sum\sum}}

or, with a little less space between the summation signs,

\def\doublesum{\mathop{\sum\!\sum}}
With the latter, \doublesum_{(a,b)=1} yields

∑∑_{(a,b)=1}

Matrix icons via L^{A}TEX _{Kees van der Laan Garnwerd, The Netherlands cgl@rc.service.rug.nl}

In my “Math into BLUes” I used matrix icons for formatting the schematic flow of matrix decompositions, to mimic Wilkinson’s diagrams as supplied in his The Algebraic Eigenvalue Problem (Oxford University Press, 1965). The crucial element is the creation of diagonal lines. I tried using Amy Hendrickson’s \diagline, which is flexible and powerful, but suffers from non-uniformness over the line orientation, and also suffers from the difference in line thickness of the horizontal and vertical lines, in comparison with the diagonal lines.

In this note I used the line fonts which come with L^{A}TEX via the \line macro, as part of the picture environment. Given the context of matrix icons the limited availability of line orientations does not hinder.

From literature I distilled that the following special matrix icons are useful:

rectangular matrix

[figure: lower left triangular matrix]
[figure: upper right triangular matrix]
[figure: upper Hessenberg form]

The above forms can be drawn easily in the picture environment. The macros in this note hide that environment, and provide the pictures in a \vbox, for use at any place where a \vbox can be used, without having to worry about ‘coordinates.’ The pictures are parameterized on L^{A}TEX’s \unitlength dimension.

Here are some matrix icons, after Wilkinson:

[figure] = [figure] [figure] AL = LH

= [figure] A = QR

via

\setlength{\unitlength}{1ex}
$$\icmat44\kern\unitlength\icllt44=\icllt44\icuh413 \qquad AL=LH$$
$$\icmat63=\icmat63\kern\unitlength\icurt63\qquad A=QR$$

The macros are as follows:

\def\icmat#1#2{%ICon MATrix(rectangular)

%#1 is ht of icon matrix, eg 4; #2 is wd of icon matrix, eg 2
\vbox{\hrule
   \hbox to#2\unitlength{\vrule height#1\unitlength\hfil\vrule}%
   \hrule}%
}%end icmat
\def\icurt#1#2{%IConUpperRightTriangle
%#1 is ht of icon matrix, with UT the upper triangular part, eg 4
%#2 is wd of icon (upper triangular) matrix, eg 2
\vbox to #1\unitlength{\hrule
   \hbox{\picture(#2,#2)\put(0,#2){\line(1,-1){#2}}\endpicture
      \vrule}%
   \vss}%
}%end icurt
\def\icllt#1#2{%IConLowerLeftTriangle
%#1 is ht of icon matrix, with LT the lower triangular part, eg 4
%#2 is wd of icon (lower triangular) matrix, eg 2
\vbox to #1\unitlength{\vss
   \hbox{\vrule
      \picture(#2,#1)\put(0,#2){\line(1,-1){#2}}\endpicture}%
   \hrule}%
}%end icllt
\def\icuh#1#2#3{%IConUpperHessenberg
%#1 is size of icon matrix, with UH the upper Hessenberg part, eg 4
%#2 is wd of icon (upper Hesenberg) matrix, eg 1
%#3 is size Lower Left triangular part, #1-#2
% (for simplicity the latter is added, could have been calculated,
% perhaps some inconsistency test could be incorporated)
\vbox{\offinterlineskip
   \hrule
   \hbox to#1\unitlength{\vrule height #2\unitlength depth0pt\relax
      \hfil\vrule}%
   \hbox to#1\unitlength{%
      \picture(#3,#3)\put(0,#3){\line(1,-1){#3}}\endpicture
      \hfil\vrule}%
   \hbox to#1\unitlength{%
      \hfil\vrule width#2\unitlength height.2pt}%
   }%
}%end icuh