5

Everything worked fine before using TexLive for updating my packages three days ago. Now it is not possible anymore to use the package subfiles

Here are the MWE

The minimum Preamble.tex file

\documentclass{amsart}
\usepackage{subfiles}

The MWE.tex file

\documentclass[MWE.tex]{subfiles}
\begin{document}
MWE
\end{document}

When I compile the MWE file I get on the console

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded >format=pdflatex)

restricted \write18 enabled.
entering extended mode

(./MWE.tex

LaTeX2e <2020-02-02> patch level 5

L3 programming layer <2020-02-25>
(/usr/local/texlive/2019/texmf-dist/tex/latex/subfiles/subfiles.cls

Document Class: subfiles 2020/02/14 v16 Multi-file projects (class)

Preamble taken from file `MWE.tex'

(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/verbatim.sty)

(/usr/local/texlive/2019/texmf-dist/tex/latex/import/import.sty)

! LaTeX Error: File `import.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:

I checked and the import.sty file is in the right directory, and everything worked fine before. Do you have any idea about what happened (apart from the fact that I should not upgrade stuff before the official releases of TexLive I suppose ...)?

6
  • that's weird (/usr/local/texlive/2019/texmf-dist/tex/latex/import/import.sty) shows the file was found and included then you get an error on the next line.... Mar 5 '20 at 20:33
  • but I get the same so should be able to trace Mar 5 '20 at 20:36
  • with texlive 2018 I get ! LaTeX Error: The font size command \normalsize is not defined: with texlive 2019 I get the error you show, is that what you expect for this minimal example? Mar 5 '20 at 20:37
  • you get the old behaviour if you use a texlive 2018 import.sty Mar 5 '20 at 20:55
  • @DavidCarlisle it complains about import.sty as that is the current value of \@curr@file, if one load another package before one would an error with its name. The real error is that subfiles tries to input /MWE.tex Mar 5 '20 at 20:57
7

The new import package code mis-handles an empty path segment and looks in the root of the filesystem rather than the current directory and unfortunately subfiles uses this form.

I think this gets back the previous behaviour.



\RequirePackage{import}
\makeatletter
\def\@sub@import#1#2#3{%
  \begingroup
  \protected@edef\@tempa{\endgroup
    \let\noexpand\IfFileExists\noexpand#2%
    \noexpand\@import  \noexpand#1%  param 1
      {\@ifundefined{input@path}{}{\input@path}}% 2
      {\@ifundefined{Ginput@path}{}{\Ginput@path}}% 3
      {\import@path#3}{\import@path}% 4,5
      {\ifx\IfFileExists\im@@IfFileExists \noexpand\im@@IfFileExists 
       \else \noexpand\IfFileExists \fi}}% 6
  \if\relax#3\relax% need expansion, for eg \filename@area
    \endgroup\expandafter#1%
  \else
    \expandafter\@tempa
  \fi}
\makeatother

\documentclass[MWE.tex]{subfiles}
\begin{document}
MWE
\end{document}

A simpler test case for just the import issue without involving subfiles is



\begin{filecontents}{\jobname-input-test}
abc
\end{filecontents}
\documentclass{article}
\usepackage{import}
\makeatletter
\def\@sub@import#1#2#3{%
  \begingroup
  \protected@edef\@tempa{\endgroup
    \let\noexpand\IfFileExists\noexpand#2%
    \noexpand\@import  \noexpand#1%  param 1
      {\@ifundefined{input@path}{}{\input@path}}% 2
      {\@ifundefined{Ginput@path}{}{\Ginput@path}}% 3
      {\import@path#3}{\import@path}% 4,5
      {\ifx\IfFileExists\im@@IfFileExists \noexpand\im@@IfFileExists 
       \else \noexpand\IfFileExists \fi}}% 6
  \if\relax#3\relax
    \endgroup\expandafter#1%
  \else
    \expandafter\@tempa
  \fi}
\makeatother

\begin{document}
\subimport{}{\jobname-input-test}
\end{document}

which gives

! LaTeX Error: File `zzz.aux' not found

with the new import package without the patch in the \makeatletter block.

3
  • You solve perfectly my problem! Unfortunately, I have to include your patch at the beginning of all the subfiles that use the subfiles package ... I hope import.sty will be corrected!
    – brunoh
    Mar 6 '20 at 16:51
  • 1
    @brunoh I mailed the package author this morning, so we'll see..... (you could do the patch more simply by placing it at the end of a local copy of import.sty that way if inport.sty gets updated with a fix you do not need to edit your files Mar 6 '20 at 16:57
  • Again, quite a good idea! Thank you so much for your quick suggestion
    – brunoh
    Mar 6 '20 at 17:04
8

That is due to the recent addition to import.sty:

% Check for "./" currdir, and make \import@path@fix ensure trailing /

(see third-last paragraph of the manual too).

I don't know why one would import from a null directory (is it to return to default path within nested \subimport?) but it should not "fix" the path in that case. The rationale is just for convenience, because forgetting the trailing "/" in the path is a common mistake.

For immediate relief, put

\makeatletter \let\import@path@fix\@firstofone \makeatother

in your (main) document header, or at the very end of import.sty. Or remove this block from import.sty:

% Check for "./" currdir, and make \import@path@fix ensure trailing /
\gdef\@gtempa{./}
\ifx\@gtempa\@currdir % *x style paths
 \gdef\import@path@fix#1{\@ensure@one@trailing@slash#1////\delimiter}%
 \gdef\@ensure@one@trailing@slash#1////#2\delimiter{#1/}%
\fi

--Donald Arseneau

6
  • 1
    A quick hint: If you highlight a code chunk and click on the {} "button" in the ribbon above the editing window, the site software automatically pretty-prints it for you.
    – Mico
    Mar 7 '20 at 7:13
  • @DonaldArsenau I tried to use your immediate relief trick and it does work in the main document that is now compilable again, but unfortunately the subfiles are still not compilable, even if I use the trick in their header. I also tried to remove the block you told us to in the last version of import.sty, but there I do not know how to make the TeX compiler aware of the changes? Can you give me a hint please?
    – brunoh
    Mar 7 '20 at 10:20
  • 3
    So we lured you on to the site, it seems:-) Mar 8 '20 at 14:25
  • 1
    Version 6.1 uploaded to CTAN. Yes, it seems so. Mar 10 '20 at 6:48
  • Thank goodness you are here! I was in a panic.
    – Cian
    Mar 12 '20 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.