I have a shared preamble file that provide uniform configuration for my documents. But it has no document class of its own. That way, I can determine the class for each document. But that means it doesn't stand alone. I would like to be able to have a document class loaded if none is already loaded, and to evaluate test content when in stand-alone mode.
How might this be accomplished?
This has pseudo-code in the comments explaining what I want to happen:
%% kile looks for a file if there is a filename dot t-e-x on this line
%% SHARED PREAMBLE FILE header.tex
%%
%% To use this, set the environment:
%% ~/.bashrc export TEX_HOME=$HOME/Documents/TeX
%% export TEXINPUTS=.:$TEX_HOME/share/:$TEXINPUTS
%%
%% In the document being produced load a document class. for example
%% \documentclass[letterrpaper,10pt]{book}
%%
%% add this to the document being produced
%% \input{header.tex}
%%
%% If no document class is loaded set standalone to TRUE
%% if standalone then load a document class for testing
\documentclass{article}
%% endif standalone
%% Begin shared preamble used by every document class
\usepackage{amsmath}
\usepackage{stix2}% must follow amsmath or arrows get flinky.
%% a bunch of shared configuration
%% All my documents need these
\newcommand{\st}{\mathrel{\backepsilon}} %% such that
\newcommand{\bc}{\mathrel{\because}} %% because
\newcommand{\tf}{\mathrel{\therefore}} %% therefore
%% if standalone load the test content
\begin{document}
Test my commands:
\[
\bc a=b \st c \tf d
\]
\end{document}
%% eindif standalone
%% if not standalon continue processing the document with
%% \input{header.tex}