I use LaTeX for text processing in conjunction with a template parser.
I want to do things, when there would be text to print. So I have
\newcommand{\zahltext}{%
%% here may be dragons, this is generated
}
\ifdefempty{\zahltext}{}{%else
\subsection{heading}
\zahltext
}
My problem is, that "%% here be dragons" may be feed with ordinary text, but also with only comments, spaces and newlines. So \zahltext is not empty in the sense of "no characters", but in the sense of "nothing to output".
My question: is there a macro I did not find, that tells me "if LaTeX outputs \zahltext, there would be no output at all or just a paragraph-separator"?
EDITH:
\documentclass[12pt]{article}
\usepackage{etoolbox}
\begin{document}
\newcommand{\zahltext}{}
\renewcommand{\zahltext}{% from Generator
%% here may be dragons, this is generated
}
\section{should be empty}
\ifdefempty{\zahltext}{cool}{%else
\subsection{do not print}
\zahltext
}
\renewcommand{\zahltext}{% from Generator
content
}
\section{should show}
\ifdefempty{\zahltext}{}{%else
\subsection{found test}
\zahltext
}
\renewcommand{\zahltext}{% from Generator
%% an empty line, could not help with that
%% it comes from an extern source
}
\section{should be empty!!}
\ifdefempty{\zahltext}{}{%else
\subsection{but is not. No output whatsoever}
\zahltext
}
\end{document}
my problem is with the third case. I want \zahltext to evaluate to "empty", because it creates no visible output.
\ifdefemptycomes from. Also please make the MWE full, I don't quite understand your last sentence, provide more examples – daleif Jul 12 '18 at 11:07