jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.63k stars 3.38k forks source link

(enhancement) proposal for footnotes #1720

Open ousia opened 10 years ago

ousia commented 10 years ago

Similar to #1612, I think it would be interesting that the user were able to place footnotes in the document.

My proposal doesn’t intend to change the default way footnotes are handled. It is an improvement, optional for the user to deploy.

Right now, footnotes in HTML documents are placed at the end of the first level section, such as in:


---
title: Footnotes
...

# Chapter One

^[footnote one]

# Chapter Two

^[footnote two]

# Chapter Three

^[footnote three]

# Chapter Four

^[footnote four]

# Chapter Five

^[footnote five]

How about being able to add a first–level title that places all footnotes in the document at the given location?

A minimal sample would be:

# footnotes

Similar to the table of contents, harcoding a title for footnotes should be avoided. The ttitle for footnotes could be specified as a YAML field, such as in:


---
footnotes: Notas
....

Another way to implement it would be to use a first–level title that contains an special identifier, such as in:

# Notas {#footnotes #notas .hidden}

Two important remarks for both approaches:

  1. Other attributes than the #footnotes identifier should be allowed in the title for footnotes.
  2. If there is some text—whatever it comes before the next first–level title—in the section for footnotes, it should be placed after the title and before the footnotes themselves. Sometimes these passages are useful to explain relevant information about the footnotes.
lierdakil commented 9 years ago

Relevant pandoc-discuss thread: https://groups.google.com/forum/#!topic/pandoc-discuss/HxmpFK-Ydus

ousia commented 7 years ago

@jgm, there is another issue with not being able to place #footnotes in a single place.

Using --epub-chapter-level' set to##or###increases the number of repeated footnote numbers. I mean, if you have parts and chapters and you need to have sections as single.xhtml` files in the epub, footnote numbers would be repeated many more times than only having a place and a single series of footnotes.

I’m afraid that this feature is essential for longer documents that require only one series of footnotes.

jgm commented 7 years ago

It's tough to see how to fix this. Currently we generate HTML for each "chapter" (that is, each split-up section, whatever level that is) as an independent document. So the numbers are going to start with 1 in each chapter. It wouldn't be enough just to move the actual notes; the numbering would still be off.

You can force everything to be in one chapter using --epub-chapter-level=1 --base-header-level=2, but if it's a long document this may have disadvantages.

ousia commented 7 years ago

Well, this is what I want to avoid: having all the document in a single chapter.

Isn’t it possible to have #footnotes the same way we have #references? This would be an alternative approach for footnotes. The best way to have endnotes as many books have.

jgm commented 7 years ago

+++ Pablo Rodríguez [Mar 09 17 11:38 ]:

Isn’t it possible to have #footnotes the same way we have #references? This would be an alternative approach for footnotes. The best way to have endnotes as many books have.

The issue is not just the location, but the numbering, as mentioned above.

ousia commented 7 years ago

The issue is not just the location, but the numbering, as mentioned above.

If numbering is problematic, wouldn’t it be possible to create a global variable that keeps track of footnote numbering between chapters?

Sorry if my proposal is stupid, but this is the simplest fix that comes to my mind to fix the issue.

nnmrts commented 6 years ago

I would propose something like --epub-chapter-level=0, it seems like the most "logical" solution for me. It would shift the --epub-chapter-level=1 --base-header-level=2 "solution" one number down, the header tags won't be replaced from h1 to h2 and the whole book would be treated like one big chapter. Currently the "long document disadvantage" is the smallest problem for the developer, but probably the biggest one for readers. I hate those problems, because they always ignite a debate about whether reducing stress for users or for developers should be the top priority, but honestly, considered in total, the stress for developers in this paticular problem is way more than the stress for the users.

At the moment I have to unzip the epub file afterwards and take out every footnote section from every chapter and place it in the last chapter or, in the --epub-chapter-level=1 --base-header-level=2-case, replace every h2 by h1, every h3 by h2 and so on...

Anyways, I'm inexpressible grateful for pandoc, thank you for your work. :pray:

ousia commented 6 years ago

@nnmrts, I think the proposal is reasonable, given the facts:

  1. We might get footnotes inside footnotes (#2053).

  2. We might have endnotes as different from footnotes (#4041, #4042).

  3. We might even get different types of notes: footnotes, endnotes, sidenotes... (#1425).

Unless there is a way to locate #footnotes, #endnotes (and other types or notes that might come [excepting sidenotes]) in the same way that we place #references, the usefulness of these implementations would be very limided.

And if we already have #references, there shouldn’t be impossible to get #footnotes (sorry for insisting again, but the issue is more than three years old).

reagle commented 3 years ago

I was just wondering this myself, but there doesn't seem to have been activity on this for a while.

ousia commented 3 years ago

@jgm, I reported this 6 years ago. Any news about the original report?

jgm commented 3 years ago

If there were news, you would read it here, so no need to ask.

ousia commented 3 years ago

@jgm, I honestly thought this issue was simply forgotten.

jgm commented 3 years ago

Mostly forgotten, yes. But it's still the case that if there were news, it would be here.

By the way, you may have missed that --reference-location now works with HTML output. That could help with your original request.

% pandoc --reference-location=section -t html
---
title: Footnotes
...

# Chapter One

^[footnote one]

# Chapter Two

^[footnote two]

# Chapter Three

^[footnote three]

# Chapter Four

^[footnote four]

# Chapter Five

^[footnote five]
<h1 id="chapter-one">Chapter One</h1>
<p><a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>
<section class="footnotes footnotes-end-of-section" role="doc-endnotes">
<hr />
<ol>
<li id="fn1" role="doc-endnote"><p>footnote one<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
<h1 id="chapter-two">Chapter Two</h1>
<p><a href="#fn2" class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a></p>
<section class="footnotes footnotes-end-of-section" role="doc-endnotes">
<hr />
<ol start="2">
<li id="fn2" role="doc-endnote"><p>footnote two<a href="#fnref2" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
<h1 id="chapter-three">Chapter Three</h1>
<p><a href="#fn3" class="footnote-ref" id="fnref3" role="doc-noteref"><sup>3</sup></a></p>
<section class="footnotes footnotes-end-of-section" role="doc-endnotes">
<hr />
<ol start="3">
<li id="fn3" role="doc-endnote"><p>footnote three<a href="#fnref3" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
<h1 id="chapter-four">Chapter Four</h1>
<p><a href="#fn4" class="footnote-ref" id="fnref4" role="doc-noteref"><sup>4</sup></a></p>
<section class="footnotes footnotes-end-of-section" role="doc-endnotes">
<hr />
<ol start="4">
<li id="fn4" role="doc-endnote"><p>footnote four<a href="#fnref4" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
<h1 id="chapter-five">Chapter Five</h1>
<p><a href="#fn5" class="footnote-ref" id="fnref5" role="doc-noteref"><sup>5</sup></a></p>
<section class="footnotes footnotes-end-of-section" role="doc-endnotes">
<hr />
<ol start="5">
<li id="fn5" role="doc-endnote"><p>footnote five<a href="#fnref5" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
reagle commented 3 years ago

BTW: My use case was a journal format that required notes before the bibliography, not after. I edited the resulting HTML manually.