2

I upgraded to the new lualatex 1.12 and it seems that I have problems with the combination of different packages and lualatex.

I tried to follow this implementation for underlining. But somehow the package arabluatex seems to raise compatibility issues. i.e.

\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}

result in a strange error - namely

 ! LaTeX Error: Command \underLine already defined.

The same code can be compiled properly with lualatex 1.10. Has the package arabluatex been changed or is now lualatex somehow more strict?

Plus is there a simple way to fix this problem to let luatex compile the code?

3

The code you are referring to has been put in a package lua-ul and arabluatex loads this package. Simply remove your code and enjoy:

\documentclass{article}
\usepackage{luacode}
\usepackage{pict2e}

\usepackage{arabluatex} % for support of arabic fonts

\begin{document}
V\underLine{A}V

\strikeThrough{Dinner is ready!}
\end{document}

enter image description here

3
  • uhu... just for the sake of clarity: Load arabluatex has a fix for the kerning in the underline part. So loading it won't be any longer alone for the purpose of arabfonts - which is quite strange. Is this something which might be removed again? Otherwise I rename the commands by myself...
    – LeO
    Apr 29 '20 at 13:34
  • 2
    You can load the new package lua-ul also yourself. Check its documentation. Marcel simply put the code of his answer in it (with some improvements) to make it generally available. And the arabluatex author liked it so much that he loads it in arabluatex to use it for his underlining commands. Apr 29 '20 at 13:50
  • Thx for the clarifications. So can simply use the lua-ul and if needed I'll load the arabluatex.
    – LeO
    Apr 29 '20 at 14:00

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.