在 LuaTeX texconfig 中设置变量?

在 LuaTeX texconfig 中设置变量?

LuaTeX 文档提到,可以通过设置名为 的表来访问多个变量texconfig。特别是,我想通过设置为 false 来减少输出trace_file_names。其他人要求相似的解决方案,但对于其他 TeX 引擎来说似乎不那么容易。现在 LuaTeX 提供了这个选择,但我不确定在哪里以及如何设置该参数。文档只提到了表格,但没有提供进一步的提示。

那么如何texconfig在LuaTeX(在MiKTeX 2.9下运行)中设置或修改表中的值?

我尝试了以下示例,但没有帮助,也许必须在流程早期进行设置。

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents*}{word.tex}
hello
\end{filecontents*}

\begin{document}
\directlua{print(texconfig)}
% prints: "table: 02900A90"

\directlua{print(texconfig["trace_file_names"])}
% prints "nil", so value does not exist in table

\directlua{texconfig["trace_file_names"] = false}

\input{word.tex}
% LuaTeX outputs: "(C:/Users/alexander/test/word.tex)"
\end{document}

答案1

仅当您使用 禁用 kpathsea 库时,布尔变量texconfig.trace_file_names才有效texconfig.kpse_init = false

您可以在使用 调用的 ini 文件中禁用 kpathsea 库luatex --lua <inifile> ...。见下文。

A不工作示例(用几行代码很难替换 kpathsea)是这样的。调用lualatex --ini --lua foo.lua test.tex

test.tex

Hello
\end

foo.lua

texconfig.kpse_init = false
texconfig.trace_file_names = false


function kpse.find_file(filename,what)
    return filename
end

local function reader( asked_name )
  local tab = { }
  tab.file = io.open(asked_name)
  tab.reader = function (t)
                  local f = t.file
                  return f:read('*l')
               end
  tab.close = function (t)
                  t.file:close()
              end
  return tab
end


local function find_xxx_file( asked_name )
  return asked_name
end
local function return_asked_name( asked_name )
  return asked_name
end
local function read_font_file( name )
  local f = io.open(name)
  local buf = f:read("*all")
  f:close()
  return true,buf,buf:len()
end
local function find_read_file( id_number,asked_name )
  local file = kpse.find_file(asked_name)
  return file
end
function find_write_file(id_number,asked_name)
  return asked_name
end
local function read_xxx_file(name)
  return nil,nil,0
end

callback.register('open_read_file',reader)

callback.register('find_opentype_file',return_asked_name)
callback.register('find_type1_file',   return_asked_name)
callback.register('find_output_file',  return_asked_name)

callback.register('read_opentype_file',read_font_file)
callback.register('read_type1_file',   read_font_file)

callback.register('find_write_file',find_write_file)

callback.register('find_read_file',find_read_file)

for _,t in ipairs({"find_font_file",'find_vf_file','find_format_file','find_map_file','find_enc_file','find_sfd_file','find_pk_file','find_data_file','find_image_file','find_truetype_file'}) do
  callback.register(t,find_xxx_file)
end
for _,t in ipairs({'read_vf_file','read_sdf_file','read_pk_file','read_data_file','read_font_file','read_map_file'}) do
  callback.register(t, read_xxx_file )
end

如果所有文件都在本地目录中,它就可以工作,但我还没有尝试过。

相关内容