使用 ctuthesis 类时出现非常奇怪的未定义控制序列错误

使用 ctuthesis 类时出现非常奇怪的未定义控制序列错误

我目前正在写一篇论文,我正在使用大学推荐的 LaTex 课程。它叫做 ctuthesishttps://github.com/tohecz/ctuthesis。我还使用了一个名为 gfig 的包(https://asinus.feld.cvut.cz/geec/#-> 导出 -> LaTex -> LaTex 库 (gfig)),它用于读取 cuircit 模拟器的输出文件,我必须使用它。问题是,即使我成功加载了包,我还是收到未定义的控制序列错误,说它无法识别 \gfig。在 .log 文件中,这个相同的错误多次出现,尽管只有一个 \gfig 实例,这也让我感到很奇怪。代码如下:

\documentclass{ctuthesis}

\usepackage{gfig}

\ctusetup{
    mainlanguage = czech,
    author = {Šimon Fojtík},
    month = 5,
    year = 2020
}

\ctuprocess

\begin{document}

\maketitle

\gfig{Circuit}
\end{document}

现在,我确信这是由 ctuthesis 类引起的错误,因为当我使用 article 类时,gfig 工作正常。另外,我正在使用 TeXstudio 和 miktex。ctuthesis 的创建者已经有几年没有回应问题了,但我希望这是一个微不足道且易于修复的问题。任何帮助都值得感激,提前致谢。

编辑:这是 lofg 文件的一部分:

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `\ctuthesis_field_use:nn' on input line 958.



Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `\ctuthesis_field_use:n' on input line 958.
.
.
.
! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...
l.18 \gfig{
           Circuit}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\GenericError  ...                                
                                                    #4  \errhelp \@err@     ...
l.18 \gfig{
           Circuit}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\GenericError  ...                                
                                                  \let \@err@               ...
l.18 \gfig{
           Circuit}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\GenericError  ...                                
                                                  \@empty \def \MessageBreak...
l.18 \gfig{
           Circuit}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\GenericError  ...                                
                                                     \endgroup 
l.18 \gfig{
           Circuit}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
.
.
.

答案1

无法识别的控制序列是\calc@next;错误消息以 结尾\gfig,但这就是 TeX 在遇到错误时到达输入文件的位置。

该错误通常发生在加载包(通过 间接完成)和 或在 内部扩展类似命令的情况下,calc而这些命令在加载后不会继续存在。ctuthesis.clspdfpages\setlength\edefcalc

keycommand包中定义了命令非常脆弱的方式;的作者gfig.sty小心地告诉keycommand要保持一些命令的安全,但没有考虑到\setlength\addtolength并且\setcounter确实可以通过进行修改calc

解决方案。打开gfig.sty文件并更改所有出现的

\setlength    \addtolength    \setcounter

进入

|\setlength|    |\addtolength|    |\setcounter|

您可能想要测试一下gfig.sty这个没有问题的版本。

%%% gfig.sty
\RequirePackage{graphicx,xparse}

\ExplSyntaxOn
\box_new:N \l_gfig_main_box
\dim_new:N \l_gfig_xn_dim   % natural width
\dim_new:N \l_gfig_xf_dim  % scaled or imposed width
\dim_new:N \l_gfig_yf_dim  % scaled or imposed height

\NewDocumentCommand{\gfig}{O{}m}
 {
  \group_begin:
  \keys_set:nn { gfig } { #1 }
  \gfig_main:n { #2 }
  \group_end:
 }

\keys_define:nn { gfig }
 {
  width .dim_set:N = \l_gfig_width_dim,
  width .initial:n = -1000pt,
  scale .tl_set:N = \l_gfig_scale_tl,
  scale .initial:n = 1,
  addtowidth .dim_set:N = \l_gfig_addtowidth_dim,
  addtowidth .initial:n = 0pt,
  addtoheight .dim_set:N = \l_gfig_addtoheight_dim,
  addtoheight .initial:n = 0pt,
  hshift .dim_set:N = \l_gfig_hshift_dim,
  hshift .initial:n = 0pt,
  vshift .dim_set:N = \l_gfig_vshift_dim,
  vshift .initial:n = 0pt,
  textsize .tl_set:N = \l_gfig_textsize_tl,
}

\cs_new_protected:Nn \gfig_main:n
 {
  \hbox_set:Nn \l_gfig_main_box { \includegraphics{#1} }
  \dim_set:Nn \l_gfig_xn_dim { \box_wd:N \l_gfig_main_box }
  \mbox
   {
    \dim_compare:nTF { \l_gfig_width_dim = -1000pt }
     {
      \hbox_set:Nn \l_gfig_main_box { \includegraphics[scale=\l_gfig_scale_tl]{#1} }
     }
     {
      \hbox_set:Nn \l_gfig_main_box { \includegraphics[width=\l_gfig_width_dim]{#1} }
     }
    \dim_set:Nn \l_gfig_xf_dim { \box_wd:N \l_gfig_main_box }
    \dim_set:Nn \l_gfig_yf_dim { \box_ht:N \l_gfig_main_box }
    \dim_set:Nn \unitlength { \fp_eval:n { \l_gfig_xf_dim/\l_gfig_xn_dim } in }
    \vbox_to_ht:nn { \l_gfig_yf_dim + \l_gfig_addtoheight_dim + \l_gfig_vshift_dim }
     {
      \vss
      \hbox_to_wd:nn { \l_gfig_xf_dim + \l_gfig_addtowidth_dim + \l_gfig_hshift_dim }
       {
        \skip_horizontal:n { \l_gfig_hshift_dim }
        \hbox_to_wd:nn { 0pt }
         {
          \includegraphics[width=\l_gfig_xf_dim]{#1}
          \hss
         }
        \l_gfig_textsize_tl 
        \begin{picture}(0,0)
        \input{#1.ppp}
        \end{picture}
       }
      \skip_vertical:n { \l_gfig_vshift_dim }
     }
   }
 }
\ExplSyntaxOff

相关内容