gsalzer / subfiles

class and package for multi-file projects in LaTeX
LaTeX Project Public License v1.3c
25 stars 1 forks source link

Compilation fails when using \includestandalone in "loaded" subfile #15

Closed yuishin-kikuchi closed 3 years ago

yuishin-kikuchi commented 3 years ago

Hi, gsalzer. Thank you for informing me about updating.

The former issue, using with LuaTeX-ja (CJK language support), was a problem in LuaTeX-ja. LuaTeX-ja 2020.10.30 solved this problem and works well with subfiles 2.0. In other hand, subfiles 2.1 attempted to solve the problem, collision with LuaTeX-ja 2020.10.01(--10.05), and it was very good!

However, after updated to subfiles 2.1, another problem occurred. When using \includestandalone (standalone package) in "loaded" subfile, compilation fails.

test.tex

\documentclass{article}
\usepackage{subfiles}
\usepackage{standalone}

\makeatletter
\def\input@path{{../}}
\makeatother

\begin{document}
\subfile{sections/sectest}
\end{document}

sections/sectest.tex

\documentclass[../test]{subfiles}
\begin{document}
This text is in \verb|sectest.tex|.\par
\includestandalone{standalone/salonetest} % HERE
\end{document}

standalone/salonte.tex

\documentclass[class=scrreprt,varwidth]{standalone}
\begin{document}
This is a text in standalone scrap.
\end{document}

Cannot compile test.tex, but can compile subfiles/sectest.tex.

./sections/sectest.tex:4: Extra }, or forgotten \endgroup.
<argument> ...t \Gin@ext \relax \expandafter \input \@tempa }
                                                  \vskip \z@ }}}
l.4 \includestandalone{standalone/salonetest}
./sections/sectest.tex:4: Missing \endgroup inserted.
<inserted text> 
\endgroup 
l.4 \includestandalone{standalone/salonetest}
./sections/sectest.tex:4: Missing } inserted.
<inserted text> 
}
l.4 \includestandalone{standalone/salonetest}

I think this is a rare case so it is not emergency.

I'm terribly sorry for confusing you. I wish I could analyze the problem. New LaTeX hook system is GREEK to me...

EDIT: I have no idea why but there are serious problems with using tabular in "loaded" subfile. So I decided to revert to 2.0.

gsalzer commented 3 years ago

Regarding the main problem: subfiles has to be loaded near the end of the preamble, in any case after standalone. Moreover, why do you modify \input@path? The strategy usually should be to specify filenames relative to the subfile. It should not be necessary to worry about how the path has to look like for subfiles to find everything.

The following works for me:

% test.tex
\documentclass{article}
\usepackage{standalone}
\usepackage{subfiles}
\begin{document}
\subfile{sections/sectest}
\end{document}

% sections/sectest.tex
\documentclass[../test]{subfiles}
\begin{document}
This text is in \verb|sectest.tex|.\par
\includestandalone{../standalone/salonetest}
\end{document}
yuishin-kikuchi commented 3 years ago

I overwrited \input@path because of preamble. I usually make a structure following:

main.tex preamble.tex sections/chapter-00.tex sections/chapter-01.tex ...

The old version (before 1.5?) of subfiles cannot find preamble.tex from chapter-00.tex, so I added to my format before. But now, in fact, after removing the input@path definition, it works well WITHOUT \includestandalone.

log file

This is LuaHBTeX, Version 1.12.0 (TeX Live 2020/W32TeX)  (format=lualatex 2020.11.1)
...
./sections/sectest.tex:4: Extra }, or forgotten \endgroup.
<argument> ...t \Gin@ext \relax \expandafter \input \@tempa }
                                                  \vskip \z@ }}}
l.4 \includestandalone{standalone/salonetest}
                                           \par
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

./sections/sectest.tex:4: Missing \endgroup inserted.
<inserted text> 
\endgroup 
l.4 \includestandalone{standalone/salonetest}
                                           \par
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

./sections/sectest.tex:4: Missing } inserted.
<inserted text> 
}
l.4 \includestandalone{standalone/salonetest}
                                           \par
I've inserted something that you may have forgotten.

And still, another problem occurred.

modify sectest.tex as

\documentclass[../test]{subfiles}
\begin{document}
This text is in \verb|sectest.tex|.\par
%\includestandalone{standalone/salonetest}\par % this fails in my environment
ABCABC

\begin{tabular}{ll}
\hline
Symbol & Name\\
\hline
p & Proton\\
n & Neutron\\
e & Electron\\
\hline
\end{tabular} % tabular something wrong? unwated space

ABCABC
\end{document}

The two problem are not occureed with subfiles 2.0.

gsalzer commented 3 years ago

Your first problem is not really a bug: load subfiles after standalone, then this works.

The issue with the tabular environment is a bug, thanks for reporting it!

Please try the new version of subfiles, 2.2, in the main directory of the github repository.