summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/subfiles
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/subfiles')
-rw-r--r--Master/texmf-dist/tex/latex/subfiles/subfiles.cls2
-rw-r--r--Master/texmf-dist/tex/latex/subfiles/subfiles.sty140
2 files changed, 82 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/latex/subfiles/subfiles.cls b/Master/texmf-dist/tex/latex/subfiles/subfiles.cls
index 8ed10c07c0d..51d0aa76894 100644
--- a/Master/texmf-dist/tex/latex/subfiles/subfiles.cls
+++ b/Master/texmf-dist/tex/latex/subfiles/subfiles.cls
@@ -26,7 +26,7 @@
%% and the derived files subfiles.sty and subfiles.pdf
%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{subfiles}[2020/09/07 v2.0 Multi-file projects (class)]
+\ProvidesClass{subfiles}[2020/10/29 v2.1 Multi-file projects (class)]
\DeclareOption*{%
\typeout{Preamble taken from file `\CurrentOption'}%
\let\preamble@file\CurrentOption
diff --git a/Master/texmf-dist/tex/latex/subfiles/subfiles.sty b/Master/texmf-dist/tex/latex/subfiles/subfiles.sty
index 0d773d81897..aba9b2882e6 100644
--- a/Master/texmf-dist/tex/latex/subfiles/subfiles.sty
+++ b/Master/texmf-dist/tex/latex/subfiles/subfiles.sty
@@ -26,53 +26,86 @@
%% and the derived files subfiles.sty and subfiles.pdf
%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{subfiles}[2020/09/07 v2.0 Multi-file projects (package)]
+\ProvidesPackage{subfiles}[2020/10/29 v2.1 Multi-file projects (package)]
\def\subfiles@DOCUMENT{document}
-{\escapechar=-1\relax
- \xdef\subfiles@BEGINDOCUMENT{\string\\begin\string\{document\string\}}%
- \xdef\subfiles@ENDDOCUMENT{\string\\end\string\{document\string\}}%
+\def\ifDOCUMENT#1#2#3{%
+ \def\subfiles@tmp{#1}%
+ \ifx\subfiles@tmp\subfiles@DOCUMENT
+ \def\subfiles@tmp{#2}%
+ \else
+ \def\subfiles@tmp{#3}%
+ \fi
+ \subfiles@tmp
}
-\def\subfiles@skipDocument{%
- \let\subfiles@skiplinescont\ignorespaces
- \let\subfiles@skiplinesend\subfiles@ENDDOCUMENT
- \subfiles@skiplines
+\def\subfiles@renewDocument#1#2{%
+ \expandafter\def\csname#1\endcsname##1{%
+ \ifDOCUMENT{##1}{%
+ \expandafter\let\csname#1\expandafter\endcsname\csname subfiles@#1\endcsname
+ #2%
+ }{%
+ \csname subfiles@#1\endcsname{##1}%
+ }%
+ }%
}
-\def\subfiles@skipDocumentclass{%
- \renewcommand\documentclass[2][]{%
- \let\documentclass\subfiles@documentclass
+\def\subfiles@newSkipToDocument#1#2#3{%
+ \long\def#2##1#1##2{\ifDOCUMENT{##2}{#3}{#2}}%
+}
+\def\subfiles@handleMainDocumentVi{%
+ \let\subfiles@begin\begin
+ \subfiles@renewDocument{begin}{%
+ \subfiles@newSkipToDocument\end\subfiles@skipToEndDocument\ignorespaces
+ \subfiles@skipToEndDocument
+ }%
+}
+\def\subfiles@handleMainDocumentVii{%
+ \let\subfiles@begin\begin
+ \subfiles@renewDocument{begin}{%
+ \endinput
\ignorespaces
}%
}
-\def\subfiles@skipPreamble{%
+\def\subfiles@handleSubDocumentVi{%
+ \let\subfiles@documentclass\documentclass
\def\documentclass{%
+ \@ifnextchar[\subfiles@documentclass@{\subfiles@documentclass@[]}%
+ }%
+ \def\subfiles@documentclass@[##1]##2{%
\let\documentclass\subfiles@documentclass
- \def\subfiles@skiplinescont{\begin{document}}%
- \let\subfiles@skiplinesend\subfiles@BEGINDOCUMENT
- \subfiles@skiplines
+ \ignorespaces
+ }%
+ \let\subfiles@begin\begin
+ \subfiles@renewDocument{begin}{%
+ \subfiles@saveEnd
+ \subfiles@renewDocument{end}\ignorespaces
+ \ignorespaces
}%
}
-\let\subfiles@handleMain\endinput
-\let\subfiles@handleSubpreamble\subfiles@skipPreamble
-\let\subfiles@handleTextAfterSubdocument\endinput
+\def\subfiles@handleSubDocumentVii{%
+ \let\subfiles@documentclass\documentclass
+ \subfiles@newSkipToDocument\begin\documentclass{%
+ \let\documentclass\subfiles@documentclass
+ \subfiles@saveEnd
+ \subfiles@renewDocument{end}{%
+ \endinput
+ \ignorespaces
+ }%
+ \ignorespaces
+ }%
+}
+\def\subfiles@saveEnd{%
+ \ifcsname subfiles@end\endcsname
+ \else
+ \let\subfiles@end\end
+ \fi
+}
+\let\subfiles@handleMainDocument\subfiles@handleMainDocumentVii
+\let\subfiles@handleSubDocument\subfiles@handleSubDocumentVii
\DeclareOption{v1}{%
- \let\subfiles@handleMain\subfiles@skipDocument
- \let\subfiles@handleSubpreamble\subfiles@skipDocumentclass
- \let\subfiles@handleTextAfterSubdocument\relax
+ \let\subfiles@handleMainDocument\subfiles@handleMainDocumentVi
+ \let\subfiles@handleSubDocument\subfiles@handleSubDocumentVi
}
\DeclareOption*{\PackageWarning{subfiles}{Option '\CurrentOption' ignored}}
\ProcessOptions\relax
-\def\subfiles@skiplines{%
- \begingroup
- \let\do\@makeother\dospecials
- \@makeother\^^L%
- \endlinechar`\^^M\relax \catcode`\^^M=12\relax \subfiles@skipline}
-{\catcode`\^^M=12 \endlinechar=-1 %
- \gdef\subfiles@skipline#1^^M{\def\subfiles@tmp{#1}%
- \ifx\subfiles@tmp\subfiles@skiplinesend
- \def\subfiles@tmp{\endgroup\subfiles@skiplinescont}%
- \else\let\subfiles@tmp\subfiles@skipline
- \fi \subfiles@tmp}
-}
\RequirePackage{import}
\def\subfiles@split#1{%
\let\subfiles@filename@simple\filename@simple
@@ -88,20 +121,9 @@
\let\subfiles@loadfile\subincludefrom
\subfiles@subfile
}
-\newcommand\subfiles@subfile[1]{%
+\def\subfiles@subfile#1{%
\begingroup
- \let\subfiles@documentclass\documentclass
- \let\subfiles@document\document
- \let\subfiles@enddocument\enddocument
- \subfiles@handleSubpreamble
- \renewenvironment{document}{%
- \let\document\subfiles@document
- \ignorespaces
- }{%
- \let\enddocument\subfiles@enddocument
- \@ignoretrue
- \subfiles@handleTextAfterSubdocument
- }%
+ \subfiles@handleSubDocument
\subfiles@split{#1}%
\subfiles@loadfile{\filename@area}{\filename@base}%
\endgroup
@@ -122,18 +144,28 @@
}%
}
\let\subfiles@bibliography\bibliography
-\renewcommand\bibliography[1]{%
+\def\bibliography#1{%
\subfiles@fixfilelist{#1}%
\expandafter\subfiles@bibliography\expandafter{\subfiles@list}%
}
\@ifpackageloaded{graphics}{%
\let\subfiles@graphicspath\graphicspath
- \renewcommand\graphicspath[1]{%
+ \def\graphicspath#1{%
\subfiles@fixpathlist{#1}%
\edef\subfiles@list{{\subfix{}}\subfiles@list}%
\expandafter\subfiles@graphicspath\expandafter{\subfiles@list}%
}%
}{}
+\@ifpackageloaded{standalone}{
+ \RequirePackage{xpatch}
+ \xpretocmd\includestandalone{%
+ \let\subfiles@end@\end
+ \ifcsname subfiles@end\endcsname
+ \let\end\subfiles@end
+ \fi
+ }{}{}
+ \xapptocmd\includestandalone{\let\end\subfiles@end@}{}{}
+}{}
\newcommand\ifSubfilesClassLoaded{%
\expandafter\ifx\csname ver@subfiles.cls\endcsname\relax
\expandafter\@secondoftwo
@@ -142,17 +174,7 @@
\fi
}
\ifSubfilesClassLoaded{%
- \let\subfiles@begin\begin
- \def\begin#1{%
- \def\subfiles@tmp{#1}%
- \ifx\subfiles@tmp\subfiles@DOCUMENT
- \let\begin\subfiles@begin
- \let\subfiles@tmp\subfiles@handleMain
- \else
- \def\subfiles@tmp{\subfiles@begin{#1}}%
- \fi
- \subfiles@tmp
- }%
+ \subfiles@handleMainDocument
}{}
\endinput
%%