我升级到了新的lualatex 1.12,看来我在不同的包和lualatex的组合上遇到了问题。
我尝试遵循这个执行用于下划线。但不知何故,该软件包arabluatex
似乎引发了兼容性问题。即
\documentclass{article}
\usepackage{luacode}
\usepackage{pict2e}
\usepackage{arabluatex} % for support of arabic fonts
\newattribute\underlineattr
\begin{luacode*}
local underlineattr = token.create'underlineattr'.index
local underline_types = {}
function new_underline_type()
table.insert(underline_types, tex.box[0].head)
tex.box[0].head = nil
tex.sprint(#underline_types)
end
local add_underline_h
local function add_underline_v(head)
for n in node.traverse(head) do
if head.id == node.id'hlist' then
add_underline_h(n)
elseif head.id == node.id'vlist' then
add_underline_v(n.head)
end
end
end
function add_underline_h(head)
node.slide(head.head)
local last_value
local first
for n in node.traverse(head.head) do
local new_value = node.has_attribute(n, underlineattr)
if n.id == node.id'hlist' then
new_value = nil
add_underline_h(n)
elseif n.id == node.id'vlist' then
new_value = nil
add_underline_v(n.head)
elseif n.id == node.id'kern' and n.subtype == 0 then
if n.next and not node.has_attribute(n.next, underlineattr) then
new_value = nil
else
new_value = last_value
end
elseif n.id == node.id'glue' and (
n.subtype == 8 or
n.subtype == 9 or
n.subtype == 15 or
false) then
new_value = nil
end
if last_value ~= new_value then
if last_value then
local width = node.rangedimensions(head, first, n)
local kern = node.new'kern'
kern.kern = -width
kern.next = node.copy(underline_types[last_value])
kern.next.width = width
kern.next.next = n
n.prev.next = kern
end
if new_value then
first = n
end
last_value = new_value
end
end
if last_value then
local width = node.rangedimensions(head, first)
local kern = node.new'kern'
kern.kern = -width
kern.next = node.copy(underline_types[last_value])
kern.next.width = width
node.tail(head.head).next = kern
end
end
local function filter(b, loc, prev, mirror)
add_underline_v(b)
local new_prev = mirror and b.height or b.depth
if prev > -65536000 then
local lineglue = tex.baselineskip.width - prev - (mirror and b.depth or b.height)
local skip
if lineglue < tex.lineskiplimit then
skip = node.new('glue', 1)
node.setglue(skip, node.getglue(tex.lineskip))
else
skip = node.new('glue', 2)
node.setglue(skip, node.getglue(tex.baselineskip))
skip.width = lineglue
end
skip.next = b
b = skip
end
return b, new_prev
-- return node.prepend_prevdepth(b)
end
luatexbase.callbacktypes.append_to_vlist_filter = 3 -- This should not be necessary
luatexbase.add_to_callback('append_to_vlist_filter', filter, 'add underlines to list')
\end{luacode*}
\newcommand\newunderlinetype[2]{%
\setbox0\hbox{#2\hskip0pt}%
\chardef#1=\directlua{new_underline_type()}\relax
}
\newunderlinetype\mystrikethrough{\leaders\vrule height3.5ptdepth-3pt}
\newcommand\strikeThrough[1]{{\underlineattr=\mystrikethrough#1}}
\newunderlinetype\myunderline{\leaders\vrule height-1ptdepth1.5pt}
\newcommand\underLine[1]{{\underlineattr=\myunderline#1}}
\begin{document}
V\underLine{A}V
\strikeThrough{Dinner is ready!}
\end{document}
导致一个奇怪的错误 - 即
! LaTeX Error: Command \underLine already defined.
使用 lualatex 1.10 可以正确编译相同的代码。软件包是否arabluatex
已更改,或者现在 lualatex 是否变得更加严格?
另外还有一个简单的解决这个问题的方法是让 luatex 编译代码?