gpt4 book ai didi

mysql - Archlinux 上的 LuaLaTeX 与 LuaSQL

转载 作者:行者123 更新时间:2023-11-29 18:29:50 26 4
gpt4 key购买 nike

我正在处理一个 LuaLaTeX 文件,它将使用 LuaSQL 从我的数据库中获取数据。这是我想出的 003-v1.tex003-v1.lua 文件:

003-v1.tex 文件:

\documentclass{article}
\usepackage{luacode}

% Lua kodo vpišemo v ločeno datoteko zaradi syntax highlithing
\directlua{dofile('003-v1.lua')}

\newcommand{\stranke}{\luadirect{stranke()}}

\begin{document}
\begin{tabular}{ll}
\hline
id stranke & ime \\
\hline
\stranke
\hline
\end{tabular}
\end{document}

003-v1.lua 文件:

function stranke ()

package.cpath = package.cpath .. ";/usr/lib/i386-linux-gnu/lua/5.1/?.so"
luasql = require "luasql.mysql"

env = assert (luasql.mysql())
con = assert (env:connect("linux_krozki","root","mypassword"))
cur = assert (con:execute("SELECT * FROM stranke"))

vnos = cur:fetch ({}, "a")

while vnos do

print(
string.format([[%s & %s \\]], vnos.id_stranke, vnos.ime)
)
vnos = cur:fetch (vnos, "a")

end

end

这个文件应该可以工作,但是当我尝试使用 lualatex 003-v1.tex 进行编译时,出现错误:

This is LuaTeX, Version 1.0.4 (TeX Live 2017/Arch Linux) 
restricted system commands enabled.
(./003-v1.tex
LaTeX2e <2017-04-15>
(using write cache: /home/ziga/.texlive/texmf-var/luatex-cache/generic)(using r
ead cache: /var/lib/texmf/luatex-cache/generic /home/ziga/.texlive/texmf-var/lu
atex-cache/generic)
luaotfload | main : initialization completed in 0.144 seconds
Babel <3.12> and hyphenation patterns for 1 language(s) loaded.
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo(load luc: /home/ziga/.texlive/
texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc)))
(/usr/share/texmf-dist/tex/lualatex/luacode/luacode.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/share/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))) (./003-v1.aux)
003-v1.lua:8: module 'luasql.mysql' not found:
no field package.preload['luasql.mysql']
[kpse lua searcher] file not found: 'luasql.mysql'
[kpse C searcher] file not found: 'luasql.mysql'
no file '/usr/local/lib/lua/5.2/luasql.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './luasql.so'
no file '/usr/lib/i386-linux-gnu/lua/5.1/luasql.so'
stack traceback:
[C]: in function 'require'
003-v1.lua:8: in function 'stranke'
[\directlua]:1: in main chunk.
\luadirect ... { \luacode@maybe@printdbg {#1} #1 }

l.14 \stranke

根据this topic出现此错误是因为 LuaLaTeX 无法加载模块 luasql.mysqllua 可以自行加载。我怎么知道这个?如果我在使用 编译之前注释掉 003-v1.lua 中的第一行 (function strranke ()) 和最后一行 (end) >lua 003-v1.lua 我得到一个完全正常的输出:

1 & Žiga \\
2 & Ranja \\
3 & Romana \\

所以我的问题是,如何确保调用 LuaLateX 时加载模块 luasql.mysql ?我在 Archlinux 上并使用 texlive。我听说人们再次编译了支持 luasql 的 texlive,但是找不到分步指南...那太棒了!如果有人已经编译过就更好了。

<小时/>

这是有关我的 Texlive 版本的信息:

[ziga@laptop ~]$ pacman -Qs tex | grep live
local/texlive-bibtexextra 2017.44915-1 (texlive-most)
local/texlive-bin 2017.44590-2
local/texlive-core 2017.44918-1 (texlive-most)
local/texlive-fontsextra 2017.44818-1 (texlive-most)
local/texlive-formatsextra 2017.44177-2 (texlive-most)
local/texlive-games 2017.44131-1 (texlive-most)
local/texlive-humanities 2017.44833-1 (texlive-most)
local/texlive-langchinese 2017.44333-1 (texlive-lang)
local/texlive-langcyrillic 2017.44895-1 (texlive-lang)
local/texlive-langextra 2017.44908-1 (texlive-lang)
local/texlive-langgreek 2017.44917-1 (texlive-lang)
local/texlive-langjapanese 2017.44914-1 (texlive-lang)
local/texlive-langkorean 2017.44467-1 (texlive-lang)
local/texlive-latexextra 2017.44907-1 (texlive-most)
local/texlive-music 2017.44885-1 (texlive-most)
local/texlive-pictures 2017.44899-1 (texlive-most)
local/texlive-pstricks 2017.44742-1 (texlive-most)
local/texlive-publishers 2017.44916-1 (texlive-most)
local/texlive-science 2017.44906-1 (texlive-most)

最佳答案

我们在 Archlinux 上找到了答案此帖子发布后的论坛。看起来 Lua 语言存在一些内部问题 - package.cpath 无法识别问号,因此 ?.so 必须更改为 mysql.so。谁能解释为什么会发生这种情况?

关于mysql - Archlinux 上的 LuaLaTeX 与 LuaSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45787737/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com