![使用参数化文件时,2021-08-25 MiKTex 更新后出现未定义的控制序列错误](https://linux22.com/image/438575/%E4%BD%BF%E7%94%A8%E5%8F%82%E6%95%B0%E5%8C%96%E6%96%87%E4%BB%B6%E6%97%B6%EF%BC%8C2021-08-25%20MiKTex%20%E6%9B%B4%E6%96%B0%E5%90%8E%E5%87%BA%E7%8E%B0%E6%9C%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E6%8E%A7%E5%88%B6%E5%BA%8F%E5%88%97%E9%94%99%E8%AF%AF.png)
我上次更新MiKTeX
已经是一年多了,到目前为止,下面的 MWE 仍然有效:
\begin{filecontents*}{tst.tex}
\begin{tikzpicture}[auto]
% placing the nodes
\node[signal] (input) {};
\node[
sum,
right = of input
] (left sum) {};
\node[
block,
right = of left sum
] (controller) {$#3$};
\node[
block,
right = of controller
] (system) {$#5$};
\node[
sum,
right = of system
] (right sum) {};
\node[
block,
above = of right sum
] (Gd) {$#7$};
\node[
signal,
above = of Gd
] (disturbances) {};
\node[
branch,
right = of right sum
] (branch) {};
\node[
signal,
right = of branch
] (output) {};
\node[
signal,
below = of left sum
] (feedback) {};
% connecting the nodes
\draw
[->] (input) -- node {$#1$} (left sum);
\draw
[->] (left sum) -- node {$#2$} (controller);
\draw
[->] (controller) -- node {$#4$} (system);
\draw
[->] (system) -- (right sum);
\draw
[->] (disturbances) -- node {$#6$} (Gd);
\draw
[->] (Gd) -- node {$#8$} (right sum);
\draw
(right sum) -- (branch);
\draw
[->] (branch) -- node {$#9$} (output);
\draw
(branch) |- (feedback);
\draw
[->] (feedback) -- node[pos = .95] {$-$} (left sum);
\end{tikzpicture}
\end{filecontents*}
\documentclass{scrartcl}
\usepackage{
tikz,
amsmath
}
\usepackage{siunitx} % for test reasons
\usetikzlibrary{positioning}
\tikzset{
signal/.style = coordinate,
sum/.style = {
draw,
circle,
inner sep = 0pt,
minimum size = 2mm
},
block/.style = {
draw,
rectangle,
minimum height = 2em,
minimum width = 4em
},
branch/.style = {
sum,
minimum size = 1mm,
fill = black
}
}
\newcommand*\Y{\underline Y}
\newcommand*\G{\mathbf G}
\newcommand*\D{\underline D}
\newcommand*\K{\mathbf K}
\newcommand*\E{\underline E}
\newcommand*\R{\underline R}
\ExplSyntaxOn
\cs_generate_variant:Nn
\cs_set_protected:Nn {cV}
\NewDocumentCommand{\loadFile}{mO{0}m}{\tl_set_from_file:Nnn
\l_tmpa_tl {}{#3}
\cs_set_protected:cV {__tempFuction:\prg_replicate:nn {#2}{n}}
\l_tmpa_tl
\cs_new_eq:Nc #1 {__tempFuction:\prg_replicate:nn {#2}{n}}}
\ExplSyntaxOff
\loadFile\controlWithoutNoise[9]{tst}
\begin{document}
\controlWithoutNoise{\R}{\E}{\K}{\underline0}{\G}{\D}{\G_d}{}{\Y}
\end{document}
因此,我认为这部分的语法(我从这里):
\ExplSyntaxOn
\cs_generate_variant:Nn
\cs_set_protected:Nn {cV}
\NewDocumentCommand{\loadFile}{mO{0}m}{\tl_set_from_file:Nnn
\l_tmpa_tl {}{#3}
\cs_set_protected:cV {__tempFuction:\prg_replicate:nn {#2}{n}}
\l_tmpa_tl
\cs_new_eq:Nc #1 {__tempFuction:\prg_replicate:nn {#2}{n}}}
\ExplSyntaxOff
这次改变了。有办法让它重新工作吗?
提前感谢您的帮助和努力!
答案1
\tl_set_from_file:Nnn
已被弃用。您必须替换它并更改参数的顺序:
\begin{filecontents*}{tst.tex}
\begin{tikzpicture}[auto]
% placing the nodes
\node[signal] (input) {};
\node[
sum,
right = of input
] (left sum) {};
\node[
block,
right = of left sum
] (controller) {$#3$};
\node[
block,
right = of controller
] (system) {$#5$};
\node[
sum,
right = of system
] (right sum) {};
\node[
block,
above = of right sum
] (Gd) {$#7$};
\node[
signal,
above = of Gd
] (disturbances) {};
\node[
branch,
right = of right sum
] (branch) {};
\node[
signal,
right = of branch
] (output) {};
\node[
signal,
below = of left sum
] (feedback) {};
% connecting the nodes
\draw
[->] (input) -- node {$#1$} (left sum);
\draw
[->] (left sum) -- node {$#2$} (controller);
\draw
[->] (controller) -- node {$#4$} (system);
\draw
[->] (system) -- (right sum);
\draw
[->] (disturbances) -- node {$#6$} (Gd);
\draw
[->] (Gd) -- node {$#8$} (right sum);
\draw
(right sum) -- (branch);
\draw
[->] (branch) -- node {$#9$} (output);
\draw
(branch) |- (feedback);
\draw
[->] (feedback) -- node[pos = .95] {$-$} (left sum);
\end{tikzpicture}
\end{filecontents*}
\documentclass{scrartcl}
\usepackage{
tikz,
amsmath
}
\usepackage{siunitx} % for test reasons
\usetikzlibrary{positioning}
\tikzset{
signal/.style = coordinate,
sum/.style = {
draw,
circle,
inner sep = 0pt,
minimum size = 2mm
},
block/.style = {
draw,
rectangle,
minimum height = 2em,
minimum width = 4em
},
branch/.style = {
sum,
minimum size = 1mm,
fill = black
}
}
\newcommand*\Y{\underline Y}
\newcommand*\G{\mathbf G}
\newcommand*\D{\underline D}
\newcommand*\K{\mathbf K}
\newcommand*\E{\underline E}
\newcommand*\R{\underline R}
\ExplSyntaxOn
\cs_generate_variant:Nn
\cs_set_protected:Nn {cV}
\NewDocumentCommand{\loadFile}{mO{0}m}{\file_get:nnN %<------------
{#3}{}\l_tmpa_tl %<----------
\cs_set_protected:cV {__tempFuction:\prg_replicate:nn {#2}{n}}
\l_tmpa_tl
\cs_new_eq:Nc #1 {__tempFuction:\prg_replicate:nn {#2}{n}}}
\ExplSyntaxOff
\loadFile\controlWithoutNoise[9]{tst}
\begin{document}
\controlWithoutNoise{\R}{\E}{\K}{\underline0}{\G}{\D}{\G_d}{}{\Y}
\end{document}