使用参数化文件时,2021-08-25 MiKTex 更新后出现未定义的控制序列错误

使用参数化文件时,2021-08-25 MiKTex 更新后出现未定义的控制序列错误

我上次更新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}

相关内容