我正在使用 TeX Live 2017,并且当前 luatex 的 glue 节点文档表示subtype
粘合节点的字段具有以下可能的值:
0 = userskip, 1 = lineskip, 2 = baselineskip, 3 = parskip, 4 = abovedisplayskip, 5 = belowdisplayskip, 6 = abovedisplayshortskip, 7 = belowdisplayshortskip, 8 = leftskip, 9 = rightskip, 10 = topskip, 11 = splittopskip, 12 = tabskip, 13 = spaceskip, 14 = xspaceskip, 15 = parfillskip, 16 = mathskip, 17 = thinmuskip, 18 = medmuskip, 19 = thickmuskip, 98 = conditionalmathskip, 99 = muglue, 100 = leaders, 101 = cleaders, 102 = xleaders, 103 = gleaders
我尝试了解 LuaTeX,并编写了以下简单代码来输出有关每个段落的一些信息输出:
\documentclass{article}
\directlua{dofile("parinfo.lua")}
\begin{document}
Word1, word2 office. Word3. End.
\end{document}
哪里parinfo.lua
:
function traverse_paragraph(head)
while head do
print(string.format('In paragraph: %s %s', node.type(head.id), debugstr_node(head)))
head = head.next
end
return true
end
luatexbase.add_to_callback('pre_linebreak_filter', traverse_paragraph, 'Info for debugging')
function debugstr_node(n)
if node.type(n.id) == "glue" then
return debugstr_glue(n)
elseif node.type(n.id) == "glyph" then
return n.char < 128 and string.char(n.char) or string.format('[char %s]', n.char)
elseif node.type(n.id) == "kern" then
return string.format('%s', n.kern)
elseif node.type(n.id) == "penalty" then
return string.format('%s', n.penalty)
else
return ''
end
end
function debugstr_glue(n)
if n.subtype == 13 then
subtype = 'spaceskip'
elseif n.subtype == 14 then
subtype = 'xspaceskip'
elseif n.subtype == 15 then
subtype = 'parfillskip'
else
subtype = '' .. n.subtype
end
return string.format('<%s: %s plus %s(%s) minus %s(%s)', subtype, n.width, n.stretch, n.stretch_order, n.shrink, n.shrink_order)
end
因此,当.tex
使用 编译文件时lualatex
,我们会得到如下输出:
In paragraph: local_par
In paragraph: hlist
In paragraph: glyph W
In paragraph: kern -54395
In paragraph: glyph o
In paragraph: glyph r
In paragraph: glyph d
In paragraph: glyph 1
In paragraph: glyph ,
In paragraph: glue <spaceskip: 218235 plus 136396(0) minus 58196(0)
In paragraph: glyph w
In paragraph: kern -18350
In paragraph: glyph o
In paragraph: glyph r
In paragraph: glyph d
In paragraph: glyph 2
In paragraph: glue <spaceskip: 218235 plus 109117(0) minus 72745(0)
In paragraph: glyph o
In paragraph: glyph [char 64259]
In paragraph: glyph c
In paragraph: glyph e
In paragraph: glyph .
In paragraph: glue <spaceskip: 290980 plus 327351(0) minus 24248(0)
In paragraph: glyph W
In paragraph: kern -54395
In paragraph: glyph o
In paragraph: glyph r
In paragraph: glyph d
In paragraph: glyph 3
In paragraph: glyph .
In paragraph: glue <spaceskip: 290980 plus 327351(0) minus 24248(0)
In paragraph: glyph E
In paragraph: glyph n
In paragraph: glyph d
In paragraph: glyph .
In paragraph: penalty 10000
In paragraph: glue <parfillskip: 0 plus 65536(2) minus 0(0)
请注意,逗号后的粘连(具有较大的延伸)和 后的粘连.
(具有较大的宽度和较大的延伸)仍然都显示为具有子类型spaceskip
,而不是xspaceskip
。 (段落末尾的粘连具有子类型parfillskip
,正如预期的那样。)
这是预料之中的吗?我们什么时候会看到具有 类型的粘连xspaceskip
?除了跟踪最近看到的单词间粘连并比较差异之外,pre_linebreak 过滤器中还有其他方法可以检测标点符号或句末(带有\nonfrenchspacing
)后面的较大粘连吗?
我不完全理解这些工作原理,即使对于非 LuaTeX,所以我可能会感到困惑 :-) 以防万一,luatex --version
说
这是 LuaTeX,版本 1.0.4 (TeX Live 2017)
答案1
当你设置\xspaceskip
\documentclass{article}
\directlua{dofile("parinfo.lua")}
\setlength\xspaceskip{10pt}
\begin{document}
Word1, word2 office. Word3. End.
\end{document}
In paragraph: glyph 3
In paragraph: glyph .
In paragraph: glue <xspaceskip: 655360 plus 0(0) minus 0(0)
In paragraph: glyph E