Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Difference between \kern and \hskip in macros

172 views
Skip to first unread message

Mike Wileman

unread,
Feb 27, 1994, 11:30:36 PM2/27/94
to

Netters,
I was trying to modify Norman Walsh's marginal note macro,
"mhack.tex", to put the note in the left margin rather than the right.
The macro (as modified) begins like this

% mhack.tex %
\font\marginhackfont=cmr7
\newinsert\margin
\dimen\margin=\maxdimen
\count\margin=0 \skip\margin=0pt
\newdimen\marginhackwidth
\newdimen\marginhackshift
\marginhackwidth=.5in
\marginhackshift=-\marginhackwidth
\advance\marginhackshift by -.1in
\def\ihack#1{\insert\margin{\hbox{\marginhackpara{#1}}}}
\def\vhack#1{\vadjust{\vbox to 0pt{%
\vskip-8.5pt% move it back up the page
\hskip\marginhackshift\rlap{%
% \hbox{\kern\marginhackshift\rlap{%
% \marginhackpara{#1}}}\vss}}}
\marginhackpara{#1}}\vss}}}

The \vhack macro should create a box containing the note, shift it to
the left by the amount of \marginhackshift, which should be -0.6 inches
here, then put the box at this location. What I find is that the box
actually gets moved to the left less than 0.6 inches, so that the text
of the note overlaps with body text.

If I use the lines which are commented out above, where I have moved the
note using \kern rather than \hskip, the macro works as desired.

I have solved my problem, but I am still curious. What causes \hskip to
move the box less than the specified amount. Is there some stretchable
glue somewhere in this setup that I am missing?

Thanks,
Mike
--
Mike Wileman
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!memsthd
Internet: mem...@prism.gatech.edu

Timothy Larkin

unread,
Mar 1, 1994, 3:01:19 PM3/1/94
to
In article <141...@hydra.gatech.EDU>, mem...@prism.gatech.EDU (Mike
Wileman) wrote:

> If I use the lines which are commented out above, where I have moved the
> note using \kern rather than \hskip, the macro works as desired.
>
> I have solved my problem, but I am still curious. What causes \hskip to
> move the box less than the specified amount.

I think that the difference has nothing to do with hskip vs. kern. It has
to do with whether TeX goes into unrestricted or restricted horizontal
mode.

From The Good Book, p. 85--86: When TeX is in vertical mode or internal
vertical mode, the first token of the new paragraph changes the mode to
horizontal for the duration of a paragraph. In other words, thigs that do
not have a vertical orientation cause the mode to switch automatically from
vertical to horizontal. This occurs when you type ... \hskip.... TeX
inserts the current paragraph indentation and rereads the horizontal token.

So the hskip causes TeX to contribute the current indentation to the list.
Whereas, just constructing an hbox does not. I predict that you will find
the difference between the two cases to be the width of the indentation.

--
ts...@cornell.edu
Timothy Larkin
otior ergo sum

0 new messages