Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在lua中构建Latex/Tex参数(2)_Lua_Latex_Tex_Tikz - Fatal编程技术网

在lua中构建Latex/Tex参数(2)

在lua中构建Latex/Tex参数(2),lua,latex,tex,tikz,Lua,Latex,Tex,Tikz,与更复杂的案例相同的问题: 第二部分 更合适的模型: 我尝试用lua产品替换绘图参数: 原件: \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{(\x-1.0)^2.0*(\x+3.0)}); \end{tikzpicture}% 替换为“手动”宏:工作正常 \def\te

与更复杂的案例相同的问题:

第二部分 更合适的模型: 我尝试用lua产品替换绘图参数: 原件:

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{(\x-1.0)^2.0*(\x+3.0)});
\end{tikzpicture}%
替换为“手动”宏:工作正常

\def\tempD{(\x-1)*(\x-1)*(\x+3)}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{\tempD}); % works fine
\end{tikzpicture}%
尝试使用lua生成的字符串替换手动宏:仍有待找到

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
%\draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{\strfunc??????}); % the correct \strfuncXX is still to be found !
\end{tikzpicture}%
尝试找到正确的
\strfuncXX
,考虑到egreg的信息:

\def\strfuncA{\luaexec{tex.write("(\\x-1)*(\\x-1)*(\\x+3)")}} % fails in draw, probably because it is not expanded enough as an argument of draw
%\edef\strfuncAA{\luaexec{tex.write("(\\x-1)*(\\x-1)*(\\x+3)")}} % fails because \luaexec non expandable
\def\strfuncB{\directlua{tex.write("(\\x-1)*(\\x-1)*(\\x+3)")}} % fails because \directlua has a problem managing the "\\"
\def\strfuncC{\directlua{tex.write("(x-1)*(x-1)*(x+3)")}}
\edef\strfuncCC{\directlua{tex.write("(x-1)*(x-1)*(x+3)")}} % works fine ... except that we get an expression with xs instead of \xs
\def\strfuncD{\directlua{tex.write("(\string\ x-1)*(\string\ x-1)*(\string\ x+3)")}} % \strfuncD fails (why ?)
%\edef\strfuncDD{\directlua{tex.write("(\string\ x-1)*(\string\ x-1)*(\string\ x+3)")}} % \strfuncD fails so \edef will fail
\luaexec
移动到
\luadirect
(或
\directlua
)造成了我必须生成的强制
\x
的问题,我无法解决