I have something like the following MWE code (see below), a \if condition is checked only if the corresponding if command is defined. Otherwise the \if condition is skipped by the \else of the \ifdefined.
But I get an error when the 'if command', i.e. \ifiskomascriptloaded, is undefined.
! Extra \else.
l.13 \else
Is there any problem in nesting these two kinds of if's?
\documentclass[]{article}
% Defining an 'if command'
% !!! The ERROR pops up IF THIS LINE IS COMMENTED OUT
\newif\ifiskomascriptloaded \iskomascriptloadedfalse
%Checking if the 'if command' is defined
\ifdefined\ifiskomascriptloaded
%In case defined we use the 'if command'
\ifiskomascriptloaded
\newcommand{\testtext}{Package Not Loaded}
\else
%Note: Never to use with a komma script document
\usepackage{scrextend} %with the nice functionality addmargin.
\newcommand{\testtext}{Package Loaded}
\fi
\else
%In case not defined we do something else
\newcommand{\testtext}{Not defined}
\fi
\begin{document}
The result is: \testtext
\end{document}
\if– David Carlisle Nov 08 '16 at 14:54