19

I am using chemmacros with beamer and it produces the following error

2017/08/28 basic chemmacros module (/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrlfile.sty Package: scrlfile 2019/10/12 v3.27 KOMA-Script package (loading files) LaTeX Warning: Command \InputIfFileExists has changed. Check if current package is valid. LaTeX Warning: Command \InputIfFileExists has changed. Check if current package is valid. ) (/usr/local/texlive/2019/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty Package: filehook-scrlfile 2011/01/03 v0.1 filehook patch for scrlfile package ! Package filehook Error: Detected 'scrlfile' package with unknown definition o f \InputIfFileExists. Use the 'force' option of 'filehook' to overwrite it.. See the filehook package documentation for explanation. Type H for immediate help.

If I comment out chemmacros or use a different documentclass to beamer there is no error.

Can anyone shed any light on this?

While I do get a usable output it is disconcerting to see an error coming up in the compilation and I am not sure if it will cause a fatal output in different usage of chemmacros . Is this a bug in KOMA-script as I believe it was recently updated but chemmacros wasn't.

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

Test

\end{document}
9
  • According to my TexLiveUtility I have the latest filehook package Version v0.6 – 2019/10/03. The included filehook-scrlfile.sty is version 2011/01/03 v0.1 but '\RequirePackage{filehook}` which is indeed the latest version.
    – Leeser
    Oct 14, 2019 at 12:46
  • @PhelypeOleinik This happens with the newest filehook version 0.6 from ctan
    – nuojuk
    Oct 14, 2019 at 12:58
  • 5
    Actually, the problem is with filehook-scrlfile (a filehook patch to the scrlfile package). Unfortunately there's no update to that yet... Try adding \PassOptionsToPackage{force}{filehook} before \documentclass{beamer}. I'm not sure if all funcitonalities of scrlfile will be preserved though... Oct 14, 2019 at 13:14
  • 5
    @Leeser (I ammended my last comment) The problem is actually caused by loading filehook and then scrlfile. beamer loads the former and then chemmacros loads the latter. Oct 14, 2019 at 13:15
  • 2
    scrlfile got updated as reaction to changes in the LaTeX kernel; now filehook-scrlfile probably has to be updated, too
    – cgnieder
    Oct 17, 2019 at 17:12

3 Answers 3

2

The problem has been resolved by an update of the sansmathaccent package. It now no longer uses the filehook package.

1
  • Sorry for the huge delay: I released a fix for filehook yesterday. Feb 4, 2020 at 7:01
12

The issue has been fixed in the last filehook update. An update to your LaTeX installation should resolve the issue. (Additionally, as Ulrike wrote, sansmathaccent had already been changed not to use filehook, which removed this particular incompatibility.)


As noted in the comments, the problem is that filehook-scrlfile has not been updated to work with the new definition of \InputIfFileExists in scrlfile. Until the author updates this file accordingly, as a workaround, you can place a file called filehook-scrlfile.sty with the following content in your compilation directory.

%% 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'.
5
  • Thank you, this helped for me!
    – Jan
    Nov 11, 2019 at 12:58
  • doesn't work for me, is there a way not to use this package?
    – Jakob
    Dec 3, 2019 at 11:13
  • Of course. Just don't use it. If you have a different problem, consider writing a new, elaborate question.
    – schtandard
    Dec 5, 2019 at 9:40
  • Update the filehook-scrlfile.sty with the above filehook-scrlfile.sty code. The directory location is ..........\AppData\Local\Programs\MiKTeX 2.9\tex\latex\filehook
    – J4cK
    Jan 2, 2020 at 10:52
  • 1
    @J4cK MiKTeX will "repair" the file on the next update, so this is not a very safe solution. If you don't like having to put the file in the same directory while the bug persists, you can create a user texmf tree, which will be safe from being modified by MiKTeX.
    – schtandard
    Jan 3, 2020 at 11:39
5

I am on a Windows 10 system using TeXstudio. I updated MiKTeX 2.9 on 1/9/2020 and still have the filehook error. By using the \PassOptionsToPackage{force}{filehook} command in my preamble, my \include commands are working again. I hope this may help someone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .