Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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 :) –  Timothy Li Mar 31 '13 at 13:44
    
@egreg: I notice that when I input etex in the shell, it refers to pdfTeX. –  Timothy 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

2 Answers 2

up vote 6 down vote accepted

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

?
share|improve this answer
1  
Yeah, I think I can always ask a teacher like you when in troube. –  Timothy 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 :) –  Timothy 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 :) –  Timothy Li Mar 31 '13 at 15:36

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.

share|improve this answer
    
Thanks, the information is very important for me. –  Timothy Li Mar 31 '13 at 13:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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