1

This is really specific and really weird;

I am trying to generate a longtable from Lua code, typset in the font GaramondNo8 (the exact one can be downloaded here).

Weirdly, while the table is generated successfully, LuaLaTeX complains about U+0A (Lin Feed) missing in Garammond, and the table has extra lines and a bunch of "Unrecognized Character" artifacts.

Furthermore, if I print out the table generated by lua and copy-paste it to the TeX code, that table is generated normally.

An MWE:

-- tex_table.lua
function get_tex_table(table_headers, table_body)
    local tex_output = {}
    table.insert(tex_output, "\\begin{longtable}{c|c|l}")
    for _, row in pairs(table_headers) do
        table.insert(tex_output, "\t" .. table.concat(row, " & "))
        table.insert(tex_output, "\t\\\\ \\hline")
    end
    table.insert(tex_output, '\t\\endhead')
    for _, row in pairs(table_body) do
        table.insert(tex_output, "\t" .. table.concat(row, " & "))
        table.insert(tex_output, "\t\\\\ \\hline")
    end
    table.insert(tex_output, "\\end{longtable}")
    return table.concat(tex_output, "\n")
end
% test.tex
\documentclass{article}
\usepackage{luacode}
\usepackage{fontspec}
\usepackage{longtable}      % Multipage table for the book to posting chapter numbers appendix

\begin{luacode} require "tex_table" \end{luacode}

\setmainfont{GaramondNo8-Regular}

\begin{document} \begin{luacode} table_head = {{"A", "B", "C"}} table_body = {{1, 2, 3}, {4, 5, 6}} tex_table = get_tex_table(table_head, table_body) io.write("\string\n" .. tex_table .. "\string\n") tex.print(tex_table) \end{luacode}

% This is the Generated Lua table, supposedly
\begin{longtable}{c|c|l}
    A & B & C
    \\ \hline
    \endhead
    1 & 2 & 3
    \\ \hline
    4 & 5 & 6
    \\ \hline
\end{longtable}

\end{document}

Then

lualatex test.tex

Outputs

\begin{longtable}{c|c|l}
        A & B & C
        \\ \hline
        \endhead
        1 & 2 & 3
        \\ \hline
        4 & 5 & 6
        \\ \hline
\end{longtable}
 [1
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!
Missing character: There is no
 (U+000A) in font GaramondNo8-Regular:mode=node;script=latn;language=dflt;+tlig
;!

and

enter image description here

  • 1
    If you use a standard font, do you get the desired result? I doubt that the font is the real problem here. The way LaTeX interprets new lines is a bit tricky. Concatenating your (Lua-)table tex_output with \n into a string is probably not what you want. Try to print the (Lua-)table with tex.print() directly, without creating a concatenated string first. –  Jul 09 '22 at 13:55

0 Answers0