0

I want to implement the nested footnotes appearing in a single sequence as in Nested footnotes with the memoir class. While the solution given by Werner as an answer to that question does work at first glance, but because it is based on the definitions in the article class it eliminates the multiple footnote feature in memoir (similar to \usepackage[multiple]{footmisc}). The mwe below shows the problem. The correct formatting of the footnote marks can be seen by commenting out the redefinitions of \footnotemark and \footnotetext.

\documentclass{memoir}

\usepackage{letltxmacro}

\newcounter{fnmarkcntr}
\newcounter{fntextcntr}
\makeatletter
\renewcommand{\footnotemark}{%
   \@ifnextchar[\@xfootnotemark
     {\stepcounter{fnmarkcntr}%
      \refstepcounter{footnote}\label{footnotemark\thefnmarkcntr}%
      \protected@xdef\@thefnmark{\thefootnote}%
      \@footnotemark}}
\makeatother
\LetLtxMacro{\oldfootnotetext}{\footnotetext}
\renewcommand{\footnotetext}[1]{%
  \refstepcounter{fntextcntr}
  \oldfootnotetext[\ref{footnotemark\thefntextcntr}]{#1}
}

\begin{document}

This text has footnotes%
\footnote{Which contains sub-footnotes\footnotemark% \multfootsep
\footnotemark that should be marked clearly as separate}%
\footnotetext{This footnote should be labeled `2'}%
\footnotetext{This footnote should be labeled `3'}%
\footnote{Another footnote}%

\end{document}

The output has badly formatted footnote marks, both in the main text and in the first footnote: mwe output

Without the two \renewcommands we get the default output which numbers the footnotes wrong: enter image description here

I think \m@makefootnotemark (and maybe other macros) from memoir needs to be modified but its definition (and usage) is too complicated for me to figure out the necessary change by analogy.

6
  • I tried your MWE, changing the \documentclass from memoir to article. The result looked bad to me. Are you sure about what you want to happen? But perhaps I am completely confused. May 14, 2022 at 18:29
  • @PeterWilson I don't see significant difference with the footnotes by switching from memoir to article. But removing/commenting out the two \renewcommands shows what I want it to look like (except for the incorrect numbering).
    – ronno
    May 15, 2022 at 14:14
  • Well I see a significant difference. You expect me to twiddle with your MWE. I don't think that I can help you any more. --- GOM May 16, 2022 at 17:58
  • @PeterWilson Sorry, could you at least describe what difference you're seeing? For me the MWE as written and changing memoir to article both produce output that's like the first screenshot (ignoring the difference in margins and page number placement), whereas I want the appearance to be more like the second screenshot except for the incorrect numbering.
    – ronno
    May 16, 2022 at 20:51
  • 1
    I was probably being confused. For your original MWE with the \renew... commands there was no difference between memoir and article output. Without the \renew... commands the memoir output put a comma between between multiple footnote markers (like 1,4 or 2,3) but the article output just strung multiple footnote markers together (like 14 or 23). Good luck. May 18, 2022 at 17:37

1 Answer 1

1
+50

I am not sure if this is reason. I think the \label command introduce space to mess up the multifootnote typing. This is a working example:

\documentclass{memoir}
\newcounter{myfn}
\newcounter{tpmyfn}
\makeatletter
\def\footnotemark{\@ifnextchar [\@xfootnotemark%
{\advance\c@myfn1\c@tpmyfn\numexpr\value{myfn}+\value{footnote}%
\protected@xdef\@thefnmark{\thetpmyfn}%
\@footnotemark}}
      
\def\footnotetext{%
     \@ifnextchar [\@xfootnotenext%
     {\stepcounter{footnote}\c@myfn0\protected@xdef\@thefnmark{\thempfn}%
    \@footnotetext}}
\makeatother
\begin{document}

This text has footnotes%
\footnote{Which contains sub-footnotes\footnotemark\footnotemark that should be marked clearly as separate}%
\footnotetext{This footnote should be labeled `2'}%
\footnotetext{This footnote should be labeled `3'}%
\footnote{Another footnote}%
\end{document}

enter image description here enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .