Two small questions here:
- Why is Subentry3 not in
\scriptsize? - How to arrange ... Mainentry1 so that it will only appear at the end of the last Subentry (however many pairs that may be), instead of at the end of the first pair (i.e. at the end of Subentry2)?
MWE
% !TEX TS-program = lualatexmk
\documentclass{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%
%
%
%
\newenvironment {mainentry} {\mainentryA}{}
\def\mainentryA#1#2#3{%
\def\subentry##1##2{%
\scriptsize ##1 \space \Huge ##2 ... #1
}%
#1 #2 #3
}
%
%
%
\def\subentry{\def\subentryS{\def\subentryS{\endgraf}}\futurelet\next\subentryA}
\def\subentryA{\ifx\bgroup\next\expandafter\subentryB\fi}
\def\subentryB#1#2{\subentryS\subentry{#1}{#2}\futurelet\next\subentryA}
%
%
%
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{mainentry}{
Mainentry1
}{
Mainentry2
}{
Mainentry3
}
\subentry{
Subentry1
}{
Subentry2
}{
Subentry3
}{
Subentry4
}
\end{mainentry}
\end{document}
\subentrymacro inside the environment. Why do you blemish the outer definition of\subentry: there is infinitive loop of calls because\subentryBincludes\subentryagain? It seems that you doesn't know basic principles of TeX. It is very difficult to explain you such basics. And you are not able to formulate, what is your intend. You can try to explain this by this way: "I want to print such thing ... when I write such code ... in my source document". – wipet Oct 11 '17 at 09:11