The following MCE:
% Subfile
%%%%%%%%%
\begin{filecontents}[overwrite]{subfile.tex}
\documentclass{article}
\tcbuselibrary{documentation}
\begin{document}
Foo.
\end{document}
\end{filecontents}
% Main file
%%%%%%%%%%%
\documentclass{article}
\usepackage{tcolorbox}
\usepackage[subpreambles]{standalone}
%
\tcbuselibrary{documentation} % ← To be removed
%
\begin{document}
\input{subfile}
\end{document}
compiles like a charm, except if \tcbuselibrary{documentation}
is removed from the main file (compile at least twice). The errors are:
! LaTeX hooks Error: Sorting rule for 'begindocument' hook applied too late. (hooks) Try setting this rule earlier.
For immediate help type H . ...
l.421 ...begindocument}{showkeys}{before}{nameref}
and, later:
! Undefined control sequence. \csname tcb@doc@index@\idx@format \endcsname \hypersetup { citeco... l.237 }}
? ! Undefined control sequence. \kvtcb@colhyper
l.237 }}
I'm aware of the Ulrike's warning:
This subpreambles stuff looks quite fragile, e.g. hyperref errors as it is loaded to late, [...]
in standalone package wrongly claims sub-preamble of a subfile changed if used with \file_input:n instead of \input but do you understand what's going on and how to fix this issue?