I try to autodefine the preamble using this and that approach but do get Undefined control sequence. \@ifundefined{\KOMAClassName }
in case I write report for scrreprt. for both options.
\documentclass[12pt,a4paper,notitlepage,oneside]{report}
%NOTE Packages, my Macros und Formatdefinitions
\usepackage[T1]{fontenc} % Allows different font encodings and hyphenation -> ctan.org/pkg/fontenc
\usepackage[utf8]{inputenc} % Translates input encodings into LaTeX internal language -> ctan.org/pkg/inputenc
\usepackage{blindtext}
\makeatletter
\@ifundefined{KOMAClassName }{\newcommand{\test}{num1} }{\newcommand{\test}{num2} } %option1
\@ifclassloaded{KOMAClassName }{\newcommand{\testb}{num1} }{\newcommand{\testb}{num2} } %option2
\makeatother
\begin{document}
\section{hi}
\test \\
\testb\\
\end{document}
Using scrreprt
or report
I get printed num1 and num2 for \test
and \testb
(which isnt also the case)
\@ifundefined{KOMAClassName}{...}{...}
, i.e. no backslash\@ifclassloaded{\KOMAClassName}{...}{...}
, since this does not expect a macro name. Your code tests whether the classKOMAClassName
is loaded, which is not the case