避免在脚注内添加脚注

避免在脚注内添加脚注

我正在处理一些手稿。正文运行流畅,但有时作者会在页边距/线下添加一些文本,并用一些符号指向它们。因此,我必须将页边距文本添加到正文中,并添加一个脚注,说明它是在页边距中找到的。为此,我创建了一个宏 \FoundBelowLine 或 \FoundInMargin 宏,它接受一个参数并将其打印在正文中,然后使用相同的文本创建脚注。一切正常。

现在,我有另一个脚注,其中根据手稿提到了行尾,例如“手稿的第一行到此结束”。

当附加文本位于当前行下方且包含多行时,我必须使用 \FoundBelowLine 宏,然后在其中使用 \MSSLineEnds 宏。这会在脚注内创建脚注,并且我得到“内容已定义”的信息。

为了解决这个问题,我认为最好以某种方式禁用其他宏,例如当 \FoundBelowLine 宏使用 \MSSLineEnds 时。但是,我不知道该怎么做。使用 Python-tex 进行编译似乎有点问题。

此外,我还必须在页边文本中使用脚注来指出读法不正确等。当必须在 \FoundBelowLine 宏内使用此类脚注时,也会出现同样的问题。但这次我不想完全禁用脚注,而是想提取参数,以便使用它来创建正确的单词。

MWE 中提到了何时编译,何时不编译。请查看。

以下是 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}

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

解决方案 正如@Maïeul所建议的

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

这将打印出所有想要打印在书正文中的文本,并将我的所有评论移至脚注,避免因脚注内的脚注而产生冲突。

答案1

您必须在宏内重新定义宏。由于您主要想要使用第一个或无参数,因此您可以将\let宏设置为\@firstofone\@gobble

您必须使用本地分组才能获得本地定义。

据我了解,您的问题就是这样的。

\documentclass[twoside]{book}

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

\makeatletter
\newcommand{\FoundBelowLine}[1]{%
  \begingroup%
  \let\MSSWrongReading\@firstoftwo%
  \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}

相关内容