  In this work we present a general method to obtain the junction conditions of
modified theories of gravity whose action can be written in the form
$f\left(X_1,...,X_n\right)$, where $X_1$ to $X_n$ are any combination of scalar
dependencies, e.g. the Ricci scalar $R$, the trace of the stress-energy tensor
$T$, the Gauss-Bonnet invariant $\mathcal G$, among others. We discriminate the
junction conditions into three sub-groups: the immediate conditions, arising
from the imposition of regularity of the relevant quantities in the
distribution formalism; the differential conditions, arising from the
differential terms in the field equations; and the coupling conditions, arising
from the interaction between different scalars $X_i$. Writing the modified
field equations in terms of a linear combination of the different contributions
of the scalars $X_i$ allows one to analyze the direct and differential junction
conditions independently for each of these scalars, whereas the coupling
junction conditions can be analyzed separately afterwards. We show that the
coupling junction conditions induced on a scalar $X_i$ due to a coupling with a
scalar $X_j$ are of the same form as the differential junction conditions of
the scalar $X_j$, but applied to the analogous quantity in the framework of the
scalar $X_i$. We provide a complete analysis of three different types of
spacetime matching, namely smooth matching, matching with a thin-shell, and
matching with double gravitational layers, and we also describe under which
conditions the full sets of junction conditions might be simplified. Our
results are applicable to several well-known theories of gravity e.g.
$f\left(R\right)$, $f\left(T\right)$, and $f\left(\mathcal G\right)$, and can
be straightforwardly extrapolated to other theories with scalar dependencies
and more complicated scenarios where several dependencies are present
simultaneously.
