We have \hskip
, \vskip
, and \mskip
, but only \kern
and \mkern
. Why doesn't TeX distinguish between horizontal and vertical kerns like it does for skips?
[Tex/LaTex] Why doesn’t TeX have hkern and vkern
tex-core
Related Solutions
If whatsits
are aptly named is a matter of opinion, as I think they would fit better in TeX's semantics if they were called afterallnodes
; whatsits
represent commands whose execution is delayed or are special commands associated with a particular device or system and are not part of TeX's normal processing flow.
It is interesting to investigate Knuth's rationale for introducing them. In a meeting with NTG members on March 13th, 1996 Knuth in reply to a question said:
I tried to make the programs so that they would have logical structure and it would be easy to throw in new features. This hasn’t happened anywhere near as often as I thought because people were more interested, I think, in inter-changeability of what they do; once you have your own program, then other people don’t have it. Still, if I were a large publisher, and I were to get special projects— some encyclopaedia, some new edition of the Bible, things like that — I would certainly think that the right thing to do would be to hire a good programmer and make a special computer system just for this project. At least, that was my idea about the way people would do it. It seems that hasn’t happened very much, although in Brno I met a student who is well along on producing Acrobat format directly in TeX, by changing the code. And the Omega system that you mentioned, that’s 150,000 lines of change files [laughter].
I built in hooks so that every time TeX outputs a page, it could come to a whatsit node and a whatsit node could be something that was completely different in each version of TeX. So, when the program sees a whatsit node, it calls a special routine saying, ‘how do I typeset this whatsit node?’ It’ll look at the sub-type and the sub-type might be another sub-type put in as a demo or it might be a brand new sub-type.
A whatsit
can appear in either a horizontal or a vertical list and has no dimensions. It signifies an operation that should be delayed as it doesn't fit in its ordinary scheme of things. The paragraph builder and the page builder scan lists submitted to them and execute certain types of whatsit
. They are useful when associated with specific implementations.
The more common whatsits
are the ones associated with the main vertical list:
(a) delayed writes generated by \write
. The token list of a delayed \write
is not written-out until the surrounding material of a \write
makes it to the output routine where a \shipout
is executed. Therefore, the write token list has to be stored on the main vertical list.
(b) specials that use the \special
command. The token list of a special command is stored with the main vertical list because the token list needs to be written to the dvi file. This happens, as in the case of write at the time of shipout.
Practical implementations can be found in postcript, pdf, color drivers and graphics programs. An interesting read is always the hyperref manual. The package uses \specials
extensively to implement the interface between TeX commands and the PDF page description language. They are very simple to write:
\immediate\special{!pdfpagelabels #2}%
To summarize it is a free for all hook/interface. Why they were called whatsit
-- my guess is that it was a Knuth (ala \fi
) whatisit
. This simple innocent special
command enabled TeX to survive and adapt over the years, producing output from postcript
to PDF
and introducing color and graphics.
Best Answer
There is no annotation in
errorlog.tex
about the introduction of\kern
, but a note of 1978-03-27 saysSo this is possibly where the idea of
\kern
started to arise and it also can explain why there is no distinction between vertical and horizontal kerns: they have the same properties of boxes (so they behave differently in horizontal and vertical mode) plus the ability to disappear at line/page breaks.While users want to know or to specify what kind of glue (skip) is appended to what list, programmers should know why they're adding a kern and it makes little sense to say
\vkern
at some point: vertical kerns are things to be added as final touches. On the other hand, saying\vskip 1pc
(or whatever) means “leave a vertical space” and must end a paragraph.Note also that two primitives instead of one would increase the size of the program and there's at least another example of a primitive with a dual function, namely
\span
.And as far as implementation is concerned,
\kern
appends a kern item to the current list, so it's not important to know what kind of list it's being built.