chemmacros、beamer 和 filehook-scrlfile.sty 存在问题

chemmacros、beamer 和 filehook-scrlfile.sty 存在问题

我正在使用chemmacrosbeamer产生以下错误

2017/08/28 基本 chemmacros 模块 (/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrlfile.sty 包:scrlfile 2019/10/12 v3.27 KOMA-Script 包(加载文件)LaTeX 警告:命令 \InputIfFileExists 已更改。检查当前包是否有效。LaTeX 警告:命令 \InputIfFileExists 已更改。检查当前包是否有效。 )(/usr/local/texlive/2019/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty 包:filehook-scrlfile 2011/01/03 v0.1 scrlfile 包的 filehook 补丁!包 filehook 错误:检测到“scrlfile”包,其中 \InputIfFileExists 的定义未知。使用“force” 'filehook' 选项来覆盖它。请参阅 filehook 包文档以了解解释。输入 H 可立即获得帮助。

如果我注释掉chemmacros或者使用不同的文档类,则beamer不会出现错误。

有人可以解释一下这个问题吗?

虽然我确实得到了可用的输出,但令人不安的是,编译中出现了错误,我不确定它是否会在不同用法中导致致命输出chemmacros。这是一个错误吗?KOMA-script因为我相信它最近更新了,但chemmacros实际上并没有。

\documentclass{beamer}
\usepackage{chemmacros}
\begin{document}

Test

\end{document}

答案1

这个问题已通过更新 sansmathaccent 包得到解决。现在不再使用该filehook包。

答案2

该问题已在上次更新中得到修复filehook。更新您的 LaTeX 安装应该可以解决该问题。(此外,Ulrike写道sansmathaccent已被改为不使用filehook,从而消除了这个特殊的不兼容性。)


正如评论中所述,问题在于filehook-scrlfile尚未更新以适应\InputIfFileExists中的新定义scrlfile。在作者相应地更新此文件之前,作为一种解决方法,您可以filehook-scrlfile.sty在编译目录中放置一个名为的文件,其中包含以下内容。

%% Modified version of filehook-scrlfile as a workaround.
%% See https://tex.stackexchange.com/a/515183/48973.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{filehook-scrlfile}[2011/01/03 v0.1 filehook patch for scrlfile package]
\RequirePackage{filehook}
\begingroup
\long\def\scrlfile@InputIfFileExists#1#2{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname #1-@alias\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
    \expandafter\@firstoftwo
  \fi
  {%
    \expandafter\InputIfFileExists\expandafter{\csname
      #1-@alias\endcsname}{#2}%
  }%
  {\IfFileExists{#1}{%
      \expandafter\scr@input@withhook\expandafter{\@filef@und}{#1}{#2}%
    }}%
}
\long\def\filehook@scrlfile@InputIfFileExists#1#2{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname #1-@alias\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
    \expandafter\@firstoftwo
  \fi
  {%
    \expandafter\InputIfFileExists\expandafter{\csname
      #1-@alias\endcsname}{#2}%
  }%
  {\IfFileExists{#1}{%
      \expandafter\filehook@swap
      \expandafter{\@filef@und}%
      {\scr@load@hook{before}{#1}%
      #2\@addtofilelist{#1}%
      \filehook@every@atbegin{#1}%
      \filehook@atbegin{#1}%
      \@@input}%
      \filehook@atend{#1}%
      \filehook@every@atend{#1}%
      \scr@load@hook{after}{#1}%
    }}%
}
\long\def\filehook@@scrlfile@InputIfFileExists#1#2{%
  \let\InputIfFileExists\filehook@InputIfFileExists
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname #1-@alias\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
    \expandafter\@firstoftwo
  \fi
  {%
    \expandafter\InputIfFileExists\expandafter{\csname
      #1-@alias\endcsname}{#2}%
  }%
  {\IfFileExists{#1}{%
      \expandafter\filehook@swap
      \expandafter{\@filef@und}%
      {\scr@load@hook{before}{#1}%
      #2\@addtofilelist{#1}%
      \filehook@atbegin{#1}%
      \@@input}%
      \filehook@atend{#1}%
      \scr@load@hook{after}{#1}%
    }}%
}
\ifcase
    \expandafter\ifx\csname InputIfFileExists \endcsname\latex@InputIfFileExists 0\else
    \expandafter\ifx\csname InputIfFileExists \endcsname\scrlfile@InputIfFileExists 0\else
     1%
    \fi\fi
\relax
  \global\let\filehook@InputIfFileExists\filehook@scrlfile@InputIfFileExists
  \global\let\filehook@@InputIfFileExists\filehook@@scrlfile@InputIfFileExists
  \global\expandafter\let\csname InputIfFileExists \endcsname\filehook@InputIfFileExists
  \PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}%
\else
  \iffilehook@force
    \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
    \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
    \global\expandafter\let\csname InputIfFileExists \endcsname\filehook@InputIfFileExists
    \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J%
                              The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
  \else
    \show\InputIfFileExists
    \expandafter\show\csname InputIfFileExists \endcsname
    \show\scrlfile@InputIfFileExists
    \PackageError{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J%
                            Use the 'force' option of 'filehook' to overwrite it.}{}%
  \fi
\fi
\endgroup
\endinput
%%
%% End of file `filehook-scrlfile.sty'.

答案3

我在 Windows 10 系统上使用 TeXstudio。我于 2020 年 1 月 9 日更新了 MiKTeX 2.9,但仍然出现文件挂钩错误。通过使用\PassOptionsToPackage{force}{filehook}序言中的命令,我的\include命令又可以正常工作了。我希望这可以帮助到某些人。

相关内容