3

This question led to a new feature in a package:
sepfootnotes

I'm using a "mix" of sepfootnotes, endnotes and subfiles in an arrangement like that of the MWE below. The actual project is eleven chapters by now (so a few files) and I'd like to keep the note content i the chapter-/subfiles.

I would like to declare the \sepfootnotecontent in the top of each chapter like the \sepfootnotecontent{a}{In subfile.} in the subfile. Unfortunately, this doesn't work and I get a message 'a' has not been assigned a content on input line 4..

In the resulting PDF, the footnote content of foot note no one is (obciously) empty whereas note no 2 and 3 look as expected.

I've been reading the sepfootnotes.sty file but I'm not getting it. The subfilespackage is simply inputing the subfile so what is the actual difference between the first and third note with respect to sepfootnotes.

I'm wondering why this is and whether there's a solution.

subfiles-sepfootnotes.tex

\documentclass{article}
\usepackage{subfiles,sepfootnotes}
\usepackage{endnotes}
\let\footnote\endnote
\begin{document}

\sepfootnotecontent{b}{In main file.}
\subfile{child}

\theendnotes
\end{document}

child.tex

\documentclass[subfiles-sepfootnotes.tex]{subfiles}
\begin{document}

\sepfootnotecontent{a}{In subfile.}

Some text with footnotes in
subfile\sepfootnote{a}, with
endnote\endnote{In endnote.}
and in parent
file\sepfootnote{b}.

\end{document}
Stefan Pinnow
  • 29,535
Mats
  • 553
  • It dawns on me, could it be that sepfootnotes gathers content before subfiles includes the subfiles? Would that be circumventable? – Mats May 20 '16 at 15:51
  • 1
    On a side note, notice that the sepfootnotes package also provides endnotes. – eduardo.tex Jul 12 '16 at 19:30

1 Answers1

1

This is due to scope: notes defined in a subfile are not available to the main document because in the subfile they must be defined within a document environment, and are thus restricted to it.

In order to circumvent this, you may insert \global right before \@namedef (not \sep@namedef) at lines 134 and 145 in sepfootnote.sty (v0.3b) to give your note definitions global scope. But I can't guarantee anything in other contexts.

  • Ahh. So, If I use end notes, then the \theendnotes command want access to the locally "def'ed names" and since they're def'ed in local scopes it doesn't work? – Mats Jul 13 '16 at 16:33
  • Sweet! Works like a charm. are you Eduardo, the maintainer of sepfootnotes? Is this an issue and a solution you might consider to incorporate in future releases or is the scope considered a wanted feature? – Mats Jul 13 '16 at 17:21
  • 1
    Yep, that's me. I'm not sure about incorporating it to the package. There is a trade-off here between making sepfootnotes compatible with subfiles, but then making it impossible for users to have notes defined locally. I have think about it. At any rate, thanks for drawing my attention to this issue! – eduardo.tex Jul 14 '16 at 05:31
  • Using an option, scoped? only since you know the solution. sepfootnotes is a gem. Having a unruly mind I'm using tons of notes. TeX code is kind of tiresome to decipher with notes all over the place. Thanks for making my life easier. – Mats Jul 17 '16 at 08:07
  • (It makes mine easier too.) I might introduce a global notion instead. This would break fewer documents. Thanks for the suggestion! – eduardo.tex Jul 17 '16 at 23:50
  • Also, I've asked a question (here) about the safest way to implement this global option. Would you test the new code (based on David Carlisle's suggestion) with your subfiles, please? I don't have any actual documents using sufiles. – eduardo.tex Jul 18 '16 at 13:19
  • I'll be glad to. Let's see if I have the time tonight. Otherwise; first thing tomorrow. – Mats Jul 18 '16 at 17:49
  • @Mats: Thanks. A new sepfootnotes (v0.3c) is available here. Please be so kind as to tell me whether version 0.3c works with more complex documents using subfiles. I will submit it to CTAN as soon as I hear from you. – eduardo.tex Jul 19 '16 at 00:20
  • Oh, ha ha. I started editing my own sepfootnotes.sty. Sure. I'll check it right away. – Mats Jul 19 '16 at 07:49
  • And it is a go. The new global option works fine on a 20-subfiles-project which won't compile without it. Great Eduardo. – Mats Jul 19 '16 at 08:03
  • 1
    Nice. Thanks for the feedback. I've already uploaded version 0.3c to CTAN. It should be available for update within 24 hours. – eduardo.tex Jul 19 '16 at 13:29