# Avoid footnotes inside footnotes

I'm working with some manuscript. The main text runs fluently, but sometimes author added some text in margin/below the line and indicated towards them with some sign. So, I've to add the margin-text to main-text and also make a footnote mentioning that it was found in margins. For this I created a macro \FoundBelowLine or \FoundInMargin macro which takes a single argument and prints it in main text and then uses the same text to create a footnote. Everything works.

Now, I've another footnote which mentions end of line according to manuscript, like "1st line of MSS ends here".

When the additional text was provided just below the current line and it runs for multiple lines, then I've to use the \FoundBelowLine macro and then use \MSSLineEnds macro inside it. This creates footnotes inside footnotes and I'm getting 'content already defined'.

For solution, I thought it will be better to somehow disable other macros like \MSSLineEnds when it is used by \FoundBelowLine macro. But, I don't know how to do it. Using Python-tex appeared a bit problematic for compiling.

Moreover, I've to use footnotes in the margin-text to note that the reading is not correct, etc. When such footnote has to be used inside \FoundBelowLine macro, it also creates same problem. But, this time I don't want to totally disable the footnote, but want to extract the argument so that it can be used to create the correct word.

When it compiles and when not are mentioned in the MWE. Please, have a look.

Here is MWE:

\documentclass[twoside]{book}

\usepackage[paperheight=8.3in,paperwidth=5.8in,margin=1in]{geometry}
\usepackage[parapparatus]{reledmac}

\newcommand{\FoundBelowLine}[1]{{#1}\footnoteA{{#1} - was found below line.}}
\newcommand{\FoundLeftMargin}[1]{{#1}\footnoteA{{#1} - was found in left margin.}}
\newcommand{\FoundRightMargin}[1]{{#1}\footnoteA{{#1} - was found in right margin.}}
\newcommand{\MSSWrongReading}[2]{{#1}\footnoteC{{#1} - is not correct. It should be {#2}.}}
\newcommand{\MSSLineEnd}[1]{\footnoteD{{#1} line ends here.}}

\begin{document}
%This compiles, obviously.
\FoundBelowLine{
\textbf{
Some text in the main body of MSS.
}
}

%This doesn't.
%I'll like to use the first argument of \MSSWrongReading{arg1}{arg2} so that footnote has all words. So, we can't fully ignore the macro.
\FoundBelowLine{
\textbf{
Some text in the main \MSSWrongReading{doby}{body} of MSS.
}
}

%This also doesn't compile. Here I want to use the \MSSLineEnd{arg1} when it is use by \FoundBelowLine{arg1} as main text, but want to totally ignore when it is used by the same command inside \footnote command.
\FoundBelowLine{
\textbf{
Some text in the main body of\MSSLineEnd{1} MSS.
}
}
\end{document}


=============================================================

SOLUTION as suggested by @Maïeul

\makeatletter
\newcommand{\FoundBelowLine}[1]{%
{#1}%
\footnoteA{%
\begingroup
\let\MSSLineEnd\@gobble%
{#1} - was found below line.
\endgroup%
}%
}
\makeatother


This prints all the text which is intended to be printed in the body of book, and moves all my comments to footnotes avoiding conflict arising from footnote inside footnote.

• you can redefine macro inside your definition of FoundBelowLine. The redefinition will be local to FoundBelowLine. Sep 18, 2019 at 10:01
• Thanks, please provide some hints, since I'm not that proficient in LaTeX. Any link to samples will work. Sep 18, 2019 at 11:00

You must redefine macro inside macro. As what you want is mainly use first or none argument, you can just \let the macro to \@firstofone and \@gobble.

You must use local grouping to have local definition.

So, as far I understand your problem.

\documentclass[twoside]{book}

\usepackage[paperheight=8.3in,paperwidth=5.8in,margin=1in]{geometry}
\usepackage[parapparatus]{reledmac}

\makeatletter
\newcommand{\FoundBelowLine}[1]{%
\begingroup%
\let\MSSLineEnd\@firstofone%
{#1}%
\footnoteA{%
\begingroup
\let\MSSLineEnd\@gobble
{#1} - was found below line.
\endgroup
}%
\endgroup%
}
\newcommand{\FoundLeftMargin}[1]{{#1}\footnoteA{{#1} - was found in left margin.}}
\newcommand{\FoundRightMargin}[1]{{#1}\footnoteA{{#1} - was found in right margin.}}
\newcommand{\MSSWrongReading}[2]{{#1}\footnoteC{{#1} - is not correct. It should be {#2}.}}
\newcommand{\MSSLineEnd}[1]{\footnoteD{{#1} line ends here.}}
\makeatother
\begin{document}
\FoundBelowLine{
\textbf{
Some text in the main body of MSS.
}
}

\FoundBelowLine{
\textbf{
Some text in the main \MSSWrongReading{doby}{body} of MSS.
}
}

%This also doesn't compile. Here I want to use the \MSSLineEnd{arg1} when it is use by \FoundBelowLine{arg1} as main text, but want to totally ignore when it is used by the same command inside \footnote command.
\FoundBelowLine{
\textbf{
Some text in the main body of\MSSLineEnd{1} MSS.
}
}
\MSSLineEnd{A}
\end{document}

• Changed a bit as=== \makeatletter \newcommand{\FoundBelowLine}[1]{% {#1}% \footnoteA{% \begingroup \let\MSSWrongReading\@firstoftwo% \let\MSSLineEnd\@gobble {#1} - was found below line. \endgroup }% }`. Now everything works as I intend. Thanks. Sep 18, 2019 at 19:10
• nice, i didnt have a lot of time, and it was not easy to to understand exaclty what you needed, but the most import was to give you tools. Sep 19, 2019 at 18:50