9

I don't know if I am right. Let's read the codes :)

\setbox0=\vbox{a\par
  \vskip2pt
  \kern2pt
  b}
\showbox0

the snippet of the log file:

.\glue 2.0
.\kern 2.0
.\glue(\parskip) 0.0 plus 1.0
.\glue(\baselineskip) 5.05556

When we

\setbox1=\vbox{\unvbox0
  \setbox2=\lastbox
  \unskip
  \unskip
  \global\skip0=\lastkern
  \unkern
  \global\skip1=\lastskip
  \unskip}

Sometimes, we have no chance of examining the log file, so, how can we decide the glue or the kern in some \skip<number> is glue or kern?

  • You can use e-TeX's \lastnodetype (texdoc etex is your friend). – egreg Mar 31 '13 at 13:41
  • @egreg thank you, egreg, I will visit my friend :) – Lucas Li Mar 31 '13 at 13:44
  • @egreg: I notice that when I input etex in the shell, it refers to pdfTeX. – Lucas Li Mar 31 '13 at 13:49
  • Yes: the modern TeX distributions always use pdftex for etex, pdftex, latex and pdflatex. – egreg Mar 31 '13 at 13:50
  • 1
    BTW, use odd numbers for local assignments and even numbers for global assignments of the first ten scratch registers (\global\skip1=\lastkern and \global\skip3=\lastskip). This is the convention in plain TeX and LaTeX to prevent problems with "save stack buildup". – Heiko Oberdiek Mar 31 '13 at 15:00
8

This can be done with e-TeX (which is incorporated in pdftex):

\def\unkernorunskip#1{%
  \ifnum\lastnodetype=12 % kern
    \global\skip#1=\lastkern\unkern
  \else
    \ifnum\lastnodetype=11 % skip
      \global\skip#1=\lastskip\unskip
    \fi
  \fi}


\setbox0=\vbox{a\par
  \vskip4pt
  \kern2pt
  b}

\setbox1=\vbox{\unvbox0
  \setbox2=\lastbox
  \unskip
  \unskip
  \unkernorunskip{1}%
  \unkernorunskip{3}%
  }

\showthe\skip1
\showthe\skip3

The output is

> 2.0pt.
l.24 \showthe\skip1

?
> 4.0pt.
l.25 \showthe\skip3

?
|improve this answer|||||
  • 1
    Yeah, I think I can always ask a teacher like you when in troube. – Lucas Li Mar 31 '13 at 13:54
  • 1
    @TimLi You have asked eight questions, of which six received at least an answer. Please review them and, if one of the answers has helped you, mark it as accepted by clicking the tick mark next to the vote marks. This is useful for future readers, who can thus know what answer helped you most. – egreg Mar 31 '13 at 15:08
  • Yeah, I have done that :) – Lucas Li Mar 31 '13 at 15:24
  • @TimLi Upvoting is not the same as accepting. – egreg Mar 31 '13 at 15:27
  • This time, I really have marked all :) – Lucas Li Mar 31 '13 at 15:36
5

In classic TeX you can not tell. You can examine \lastskip or \lastkern but these will be 0pt whether the last item on the list is not a skip or if it is a skip of size 0pt, you can not distinguish those cases.

Using e-tex however you can examine the value of the integer \lastnodetype which will be 11 for a glue (skip) node and 12 for a kern node.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.