Difference between revisions of "Footnotes"

From Wiki
Jump to navigation Jump to search
m (→‎Footnotes in Floats: - comment align key)
 
(29 intermediate revisions by 13 users not shown)
Line 1: Line 1:
< [[Structurals]] | [[References]] >
+
{{todo|This page needs to be reorganized: progression from simple to more complex use is a bit circular..}}
  
 
==First View==
 
==First View==
Line 60: Line 60:
 
==Basic Footnotes==
 
==Basic Footnotes==
  
For basic footnotes, simply use <cmd>footnote</cmd><tt>[reference]{footnote text}</tt>.
+
For basic footnotes, simply use {{cmd|footnote|[reference]{footnote text}}}.
The reference is optional, and can be used to refer to the same footnote again.  Footnotes can be referenced with the usual <cmd>in</cmd> and <cmd>at</cmd> macros (see [[References]]), or the note itself can be reproduced with <cmd>note</cmd><tt>[reference]</tt>.  For example:
+
The reference is optional, and can be used to refer to the same footnote again.  Footnotes can be referenced with the usual {{cmd|in}} and {{cmd|at}} macros (see [[References]]), or the note itself can be reproduced with {{cmd|note|[reference]}}.  For example:
  
 
<texcode>
 
<texcode>
This\footnote[footA](Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
+
This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
 
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.   
 
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.   
 
</texcode>
 
</texcode>
Line 71: Line 71:
 
\starttext
 
\starttext
 
\strut\vfill  % A hack to shorten the page.
 
\strut\vfill  % A hack to shorten the page.
This\footnote[footA](Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
+
This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
 
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.   
 
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.   
 
\stoptext
 
\stoptext
Line 80: Line 80:
  
 
<texcode>
 
<texcode>
This\footnote(Or that\footnote{Or possibly even the other.}, if you prefer.} is a sentence
+
This\footnote{Or that\footnote{Or possibly even the other.}, if you prefer.} is a sentence
 
with a footnote.   
 
with a footnote.   
 
</texcode>
 
</texcode>
Line 87: Line 87:
 
\starttext
 
\starttext
 
\strut\vfill  % A hack to shorten the page.
 
\strut\vfill  % A hack to shorten the page.
This\footnote(Or that\footnote{Or possibly even the other.}, if you prefer.} is a sentence
+
This\footnote{Or that\footnote{Or possibly even the other.}, if you prefer.} is a sentence
 
with a footnote.   
 
with a footnote.   
 
\stoptext
 
\stoptext
 
</context>
 
</context>
  
 +
==Footnote Numbering==
  
==Footnote Numbering==
+
You can setup the exact behaviour of footnotes with {{cmd|setupnotation|[footnote]}} (MkII: {{cmd|setupfootnotes}}).
 +
(The command page for the MkIV version is still missing, refer to the old version; translate location to alternative and conversion to numberconversion.)
  
You can setup the exact behaviour of footnotes as usual with <cmd>setupfootnotes</cmd>.  For example, to use footnotes with standard footnote symbols (which ConTeXt has defined as the conversion "set 2"), with the footnote counter resetting on each page, one would use the following:
+
For example, to use footnotes with standard footnote symbols (which ConTeXt has defined as the conversion "set 2"), with the footnote counter resetting on each page, one would use the following:
  
 
<texcode>
 
<texcode>
\setupfootnotes[way=bypage, conversion=set 2]
+
\setupnotation[footnote][way=bypage,numberconversion=set 2]
 
</texcode>
 
</texcode>
  
Beware, in MkIV this became
+
In MkII this was:
  
 
<texcode>
 
<texcode>
\setupnote[footnote][way=bypage, numberconversion=set 2]
+
\setupfootnotes[way=bypage, conversion=set 2]
 
</texcode>
 
</texcode>
  
Line 110: Line 112:
  
 
<context>
 
<context>
\setupfootnotes[way=bypage, conversion=set 2]
+
\setupnotation[footnote][way=bypage,numberconversion=set 2]
 
\starttext
 
\starttext
 
\strut\vfill  % A hack to shorten the page.
 
\strut\vfill  % A hack to shorten the page.
This\footnote[footA](Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
+
This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
 
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.   
 
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.   
 
\stoptext
 
\stoptext
Line 120: Line 122:
 
==Alternate Footnote Locations==
 
==Alternate Footnote Locations==
  
The <cmd>setupfootnotes</cmd> command offers some options for the placement of footnotes; for instance, the <code>location=columns</code> option places the footnotes in a single column (of a multicolumn page) rather than across the whole page.  The <code>location=text</code> option places the footnotes in text at a location specified by <cmd>placefootnotes</cmd>; this can be easily used to create endnotes, or even to place footnotes after each paragraph or subsection.
+
The {{cmd|setupfootnotes}} (MkII) command offers some options for the placement of footnotes; for instance, the <code>location=columns</code> option places the footnotes in a single column (of a multicolumn page) rather than across the whole page.  The <code>location=text</code> option places the footnotes in text at a location specified by {{cmd|placefootnotes}}; this can be easily used to create endnotes, or even to place footnotes after each paragraph or subsection.
  
 
<texcode>
 
<texcode>
\setupfootnotes[location=text]
+
\setupfootnotes[location=text] % MkII
 
This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
 
This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
 
two footnotes; this one and footnote \note[footA].}.   
 
two footnotes; this one and footnote \note[footA].}.   
Line 141: Line 143:
 
\stoptext
 
\stoptext
 
</context>
 
</context>
 +
 +
=== Footnotes at the end of each chapter ===
 +
 +
Another elegant (MkIV) example places all footnotes in a subject (unnumbered section) at the end of each chapter. It is intelligent and will not create an empty subject when there are no footnotes to be placed. At no extra cost, the subject title "Footnote" will be singular or plural depending if there is only one or several footnotes to be placed:
 +
 +
<texcode>
 +
\startsetups[chapter:after]
 +
    \ifcase\rawcountervalue[footnote]\relax
 +
    \or
 +
        \startsubject[title=Footnote]
 +
            \placefootnotes
 +
        \stopsubject
 +
    \else
 +
        \startsubject[title=Footnotes]
 +
            \placefootnotes
 +
        \stopsubject
 +
    \fi
 +
\stopsetups
 +
 +
\setupnotes[location=none]
 +
\setupnotation[way=bychapter]
 +
 +
\setuphead[chapter][aftersection=\setups{chapter:after}]
 +
 +
\starttext
 +
 +
\startchapter[title={Chapter One}]
 +
 +
This one\footnote{is placed}. And\footnote{this one is too}.
 +
 +
\stopchapter
 +
 +
\chapter[title={Chapter Two}]
 +
 +
But this one\footnote{is not flushed}.
 +
 +
\startchapter[title={Chapter Three}]
 +
 +
Unless \type{\stopchapter} was invoked.
 +
 +
\stopchapter
 +
 +
\startchapter[title={Chapter Three}]
 +
 +
On a chapter with\footnote{footnote}.
 +
 +
\stopchapter
 +
 +
\stoptext
 +
</texcode>
 +
 +
===Footnotes in the margin===
 +
 +
First we switch off footnote placement, then we place them manually into the margin.
 +
 +
<texcode>
 +
\setupnote[footnote][location=none]
 +
\setupnotation[footnote][
 +
    align=flushleft,
 +
    location=serried,
 +
    width=broad,
 +
]
 +
\setuptexttexts[margin][]
 +
    [{\framed[%
 +
    align={right,bottom},
 +
    frame=off,
 +
    height=\textheight,
 +
    width=\rightmarginwidth
 +
    ]{\placenotes[footnote]}}]
 +
</texcode>
 +
 +
===... but not at the bottom===
 +
 +
Hraban wanted numbered margin notes, starting in on the same line as the referenced text (like a combination of {{cmd|inmargin}} and {{cmd|footnote}}). Wolfgang answered:
 +
 +
The only way I found to achieve this is by flushing the notes at the end of each footnote
 +
entry which can be done with the next key. The positioning of each margin text is tricky
 +
because {{cmd|placenotes}} adds skips at the begin of the block (which can be reduced with
 +
{{cmd|placelocalnotes}}) but a inline version of the command (e.g. <tt>\placeinlinenotes</tt>) which
 +
flushes the notes without vertical skips and a rule at the begin would help.
 +
 +
<texcode>
 +
\define\PlaceFootnote
 +
  {\inrightmargin{\vtop{\placelocalnotes[footnote][before=,after=]}}}
 +
 +
\setupnote
 +
  [footnote]
 +
  [location=text,
 +
  bodyfont=,
 +
  next=\PlaceFootnote]
 +
 +
\setupnotation
 +
  [footnote]
 +
  [alternative=serried]
 +
 +
\setuplayout
 +
  [width=12cm,
 +
  rightmargindistance=0.5cm,
 +
  rightmargin=5cm]
 +
 +
\starttext
 +
\dorecurse{6}{\input ward\expanded{\footnote{This is a footnote \recurselevel}} }
 +
\stoptext
 +
</texcode>
  
 
==Footnote Formatting==
 
==Footnote Formatting==
  
 
You can change the font used in the footnotes with
 
You can change the font used in the footnotes with
<cmd>setupfootnotedefinition</cmd><code>[before=\MyFontCommand]</code>.
+
{{cmd|setupfootnotedefinition|[before=\MyFontCommand]}}.
  
Footnotes can be placed in multiple columns, using the <tt>n=<i>number</i></tt> option in <cmd>setupfootnotes</cmd>.
+
Footnotes can be placed in multiple columns, using the <code>n=<i>number</i></code> option of {{cmd|setupnotes}} or {{cmd|setupnote}} (MkII: {{cmd|setupfootnotes}}).
  
 
<texcode>
 
<texcode>
\setupfootnotes[n=3]
+
\setupfootnotes[n=3] % MkII
 
This\footnote[footA](Or that\footnote{Or the other.}, if you prefer.} is a sentence
 
This\footnote[footA](Or that\footnote{Or the other.}, if you prefer.} is a sentence
 
with a footnote\footnote{Actually, two footnotes; this one and \in{footnote}[footA]
 
with a footnote\footnote{Actually, two footnotes; this one and \in{footnote}[footA]
Line 160: Line 266:
 
\starttext
 
\starttext
 
\strut\vfill  % A hack to shorten the page.
 
\strut\vfill  % A hack to shorten the page.
This\footnote[footA](Or that\footnote{Or the other.}, if you prefer.} is a sentence
+
This\footnote[footA]{Or that\footnote{Or the other.}, if you prefer.} is a sentence
 
with a footnote\footnote{Actually, two footnotes; this one and \in{footnote}[footA]
 
with a footnote\footnote{Actually, two footnotes; this one and \in{footnote}[footA]
 
on \at{page}[footA], denoted by \note[footA].}.   
 
on \at{page}[footA], denoted by \note[footA].}.   
Line 167: Line 273:
  
 
{{todo|This is ugly, and points up some ConTeXt bugs that need to be fixed.}}
 
{{todo|This is ugly, and points up some ConTeXt bugs that need to be fixed.}}
 +
 +
===Footnotes in pagraph form===
 +
 +
When enabling footnotes (actually notes and linenotes) in pagraph form, there is some risk in having no right separation between body and the notes. This can be partially avoided using <code>width=broad</code> ([http://www.ntg.nl/pipermail/ntg-context/2013/073650.html Hans dixit]).
 +
 +
<texcode>
 +
\setupnote
 +
  [footnote]
 +
  [paragraph=yes]
 +
 +
\setupnotation
 +
  [footnote]
 +
  [alternative=serried,
 +
    width=broad,
 +
    distance=.5em,
 +
    display=no]
 +
 +
\starttext
 +
    \dorecurse{500}{text text text\footnote{note} }
 +
\stoptext
 +
</texcode>
  
 
==Footnotes in Floats==
 
==Footnotes in Floats==
  
[[Floating Objects|Floats]] cannot include normal footnotes, because they are likely to float to another page from the page on which they were defined, thus getting the footnotes out of order.  Thus, to include footnotes in a float, one must use local footnotes.  This table, which uses the <cmd>placelegend</cmd> command to create a place for the footnotes, illustrates the process:
+
[[Floating Objects|Floats]] cannot include normal footnotes, because they are likely to float to another page from the page on which they were defined, thus getting the footnotes out of order.  Thus, to include footnotes in a float, one must use local footnotes.  This table, which uses the {{cmd|placelegend}} command to create a place for the footnotes, illustrates the process:
  
 
<texcode>
 
<texcode>
Line 233: Line 360:
 
   [width=\hsize,
 
   [width=\hsize,
 
   frame=off,
 
   frame=off,
   align=right,
+
   %align=right,
 
   %height=fit,
 
   %height=fit,
 
   top=\hbox\bgroup,
 
   top=\hbox\bgroup,
Line 240: Line 367:
 
\starttext
 
\starttext
  
\startlocalfootnotes[n=0]
+
\startlocalfootnotes%[n=0]
 
\placetable
 
\placetable
 
{Caption}
 
{Caption}
Line 253: Line 380:
 
\stoptext
 
\stoptext
 
</context>
 
</context>
 +
 +
==Footnotes in a box==
 +
 +
Note that it is necessary to add the command {{cmd|automigrateinserts}} (for example before {{cmd|link=no|starttext}})
 +
in order to correctly handle the placement of footnotes within a box such as {{cmd|framed}} or {{cmd|placeongrid}}...
  
 
==Placing Footnotes Manually==
 
==Placing Footnotes Manually==
  
In some cases, ConTeXt's footnoting system may not be able to do exactly what you want.  For instance, you may want to place a footnote in a table so that the footnote appears with the rest of the footnotes on the page, or you may want to create a footnote to a footnote to a footnote.  Many of these cases can be handled by using the <cmd>footnotetext</cmd> command (which creates a footnote without placing the corresponding symbol in the text) and the <cmd>note</cmd> command (which places the footnote symbol in the text, but does not create a footnote).
+
In some cases, ConTeXt's footnoting system may not be able to do exactly what you want.  For instance, you may want to place a footnote in a table so that the footnote appears with the rest of the footnotes on the page, or you may want to create a footnote to a footnote to a footnote.  Many of these cases can be handled by using the {{cmd|footnotetext}} command (which creates a footnote without placing the corresponding symbol in the text) and the {{cmd|note}} command (which places the footnote symbol in the text, but does not create a footnote).
  
For example, to create a footnote to a footnote to a footnote, all but the first footnotes are created with <cmd>footnotetext</cmd> commands, which are placed in the main text -- thereby ensuring that the footnotes are numbered and appear in the correct order.  Then, these footnotes are referenced by <cmd>note</cmd> commands within the relevant footnotes.  In this example, the lines are broken for clarity; note the <tt>%</tt> at the end of each line to prevent spurious spaces in the text.
+
For example, to create a footnote to a footnote to a footnote, all but the first footnotes are created with {{cmd|footnotetext}} commands, which are placed in the main text thereby ensuring that the footnotes are numbered and appear in the correct order.  Then, these footnotes are referenced by {{cmd|note}} commands within the relevant footnotes.  In this example, the lines are broken for clarity; note the <code>%</code> at the end of each line to prevent spurious spaces in the text.
  
 
<texcode>
 
<texcode>
 
This%
 
This%
\footnote(Or that\note[footB], if you prefer.}%
+
\footnote{Or that\note[footB], if you prefer.}%
 
\footnotetext[footB]{Or possibly even the other\note[footC].}%
 
\footnotetext[footB]{Or possibly even the other\note[footC].}%
 
\footnotetext[footC]{It could be something entirely different.}
 
\footnotetext[footC]{It could be something entirely different.}
Line 269: Line 401:
  
 
<context>
 
<context>
 +
\starttext
 
\strut\vfill
 
\strut\vfill
 
This%
 
This%
\footnote(Or that\note[footB], if you prefer.}%
+
\footnote{Or that\note[footB], if you prefer.}%
 
\footnotetext[footB]{Or possibly even the other\note[footC].}%
 
\footnotetext[footB]{Or possibly even the other\note[footC].}%
 
\footnotetext[footC]{It could be something entirely different.}
 
\footnotetext[footC]{It could be something entirely different.}
 
is a sentence with nested footnotes.
 
is a sentence with nested footnotes.
 +
\stoptext
 
</context>
 
</context>
 +
 +
== Suppressing Footnotes Entirely ==
 +
 +
The boolean {{cmd|link=no|notesenabled}} controls whether footnotes are processed at all.
 +
If set to ''false'', invocations of {{cmd|footnote}} will be ignored.
 +
After it is set to ''true'' again ConTeXt will pick up the footnote counters at their
 +
previous state, so numbering will continuous.
 +
 +
<context source="yes" mode="mkiv">
 +
\setuppapersize [A7]
 +
\starttext
 +
 +
  \dorecurse {2} { foo \footnote {bar} baz \par }
 +
 +
  \notesenabledfalse
 +
 +
  \dorecurse {3} { foo \footnote {bar} baz \par }
 +
 +
  \notesenabledtrue
 +
 +
  \dorecurse {2} { foo \footnote {bar} baz \par }
 +
 +
\stoptext
 +
</context>
 +
 +
== Color of Footnote Links that Refer to the Same Page ==
 +
 +
If you have set footnotes to be interactive and have noticed that your footnote links become red, it is because they are linked to content on the same page on which they appear. This means they are governed by {{cmd|setupinteraction}}’s attribute <code>contrastcolor</code>, rather than <code>color</code>.
 +
 +
To fix the redness (or change it to a different color), try:
 +
 +
<texcode>
 +
\setupinteraction[state=start,color=black,contrastcolor=black]
 +
</texcode>
 +
 +
== Changing footnote interlinespace ==
 +
 +
If you want to change the interlinespace of footnotes without impacting the rest of the document, try:
 +
<texcode>
 +
\startsetups[footnote:interlinespace]
 +
  \setupinterlinespace[line=2.8ex]
 +
\stopsetups
 +
 +
\setupnote[footnote][setups=footnote:interlinespace]
 +
</texcode>
 +
 +
 +
  
 
== Special Needs ==
 
== Special Needs ==
 
There are numerous ways to display and format footnotes. The following section gathers solutions to some special tasks asked on the mailing list.
 
There are numerous ways to display and format footnotes. The following section gathers solutions to some special tasks asked on the mailing list.
  
 +
=== Hyphenation ===
 
* Is there a way to turn off hyphenation for the main body of my text, but enable it for the footnotes?
 
* Is there a way to turn off hyphenation for the main body of my text, but enable it for the footnotes?
  
Line 295: Line 478:
 
</texcode>
 
</texcode>
  
* Currently, footnotes are set so that the left end of the text of the footnote is aligned with the left edge of the text, and the footnote number hangs out into the margin. Is it possible to change this? (For instance, suppose I would like the number aligned to the text-edge, and then a fixed-width space, and then the text?)
+
===Mark Placement===
 +
* How can I change the placement of the footnote mark?
 +
 
 +
Currently, footnotes are set so that the left end of the text of the footnote is aligned with the left edge of the text, and the footnote number hangs out into the margin. Is it possible to change this? (For instance, suppose I would like the number aligned to the text-edge, and then a fixed-width space, and then the text?)
  
This behavior is controlled by the <code>location</code> key in the <code>\setupnotedefinition</code> command. Here are some examples:
+
This behavior is controlled by the <code>location</code> key of {{cmd|setupnotation}}. Here are some examples:
  
Note number is typeset in an area with a width of 1cm, aligned at the left of the text area:
+
Note number is typeset in an area with a width of 1 cm, aligned at the left of the text area:
  
 
<context source="yes" text="produces">
 
<context source="yes" text="produces">
Line 310: Line 496:
 
\showframe
 
\showframe
  
\setupnotedefinition[footnote][location=left,width=1cm]
+
\setupnotation[footnote][location=left,width=1cm]
 
\setupnote[footnote][location=page,numbercommand=]
 
\setupnote[footnote][location=page,numbercommand=]
  
Line 319: Line 505:
  
  
Suppose that one wants a width of 1.5em. Then
+
Suppose that one wants a width of 1.5 em. Then
  
 
<texcode>
 
<texcode>
 
\setupnote[footnote][margindistance=0em,command=\myfootnotecommand]
 
\setupnote[footnote][margindistance=0em,command=\myfootnotecommand]
\setupnotedefinition[footnote][location=left,hang=1]
+
\setupnotation[footnote][location=left,hang=1]
  
 
\def\myfootnotecommand#1{\hbox to 1.5em{#1.}}
 
\def\myfootnotecommand#1{\hbox to 1.5em{#1.}}
 
</texcode>
 
</texcode>
  
Sometimes footnotes grow huge and might consist of more than one paragraph, those paragraphs might end up on the following page and referencing the footnote itself will point to its beginning rather than the paragraph you desire.  To reference a paragraph inside a footnote directly you have to make references unexpanded by either placing the following snippet into your preamble or substituting the original macro definitions in [[source:strc-ref.mkiv|strc-ref.mkiv]].
+
===Line Spacing===
 +
* Can I change the line spacing of a footnote independently of that of the main text?
 +
 
 +
The way to do this is not obvious, but this is the code you need to use:
  
 
<texcode>
 
<texcode>
\unexpanded\def\textreference {\dosingleargument\dotextreference}
+
\def\setnotebodyfont
\unexpanded\def\pagereference {\dosingleargument\dopagereference}
+
{\switchtobodyfont[your desired font size]\setupinterlinespace[your desired spacing]}  
\unexpanded\def\reference    {\dosingleargument\doreference    }
 
\unexpanded\def\setreference  {\dodoubleargument\dosetreference }
 
 
</texcode>
 
</texcode>
 +
 +
===Placement in Bidirectional Documents===
 +
* Can the footnote rule be placed on the right-hand side?
 +
 +
This is possible via setting the <code>rule</code> key of {{cmd|setupnote}} and {{cmd|definenote}}.  In right-to-left documents it is usually desirable to have right-to-left footnotes, where right-aligned footnote rules make more sense aesthetically.  Set <code>rule=right</code> to achieve this.  Prior to 01-04-2016 Beta, this would have turned off the footnote rule completely: one needed to use <code>rule={on,right}</code>.
 +
 +
In a BiDi document the direction of the surrounding text where the {{cmd|footnote}} is invoked determines the direction of the footnote block to come later.  Therefore, some footnotes may be right-to-left whereas others can be left-to-right.  Note that the text of the footnote does not play a role here.  The style designer decides whether left or right footnote rules make more sense.  However, there is a third option: setting <code>rule=paragraph</code> looks at the first paragraph in the footnote block and let that determine the position of the footnote rule.  In other words, if the footnote block of the page starts with an RTL text we end up with a right-aligned footnote rule and a left-aligned rule is typeset otherwise.  (The first line/paragraph of the footnote block on a page need not correspond to the start of a footnote; it can rather be the leftover from a long footnote that started on some previous page.)
 +
 +
For more fancy footnote rules, you can use <code>rulecommand=\MyRuleCommand</code>.  Look at the definition of <code>\normalnoterule</code> in strc-not.mkvi for a starting point.
 +
 +
[[Category:Basics]]

Latest revision as of 21:20, 19 February 2022


TODO: This page needs to be reorganized: progression from simple to more complex use is a bit circular.. (See: To-Do List)


First View

\section{First}

Way to \ConTeXt\footnote{First footnote.} is painful.

\section{Second}

But \ConTeXt\ is amazing.\footnote{Second footnote}

\placetable
  {Complex Table\footnote{A table head footnote.}}
  {\startlocalfootnotes
   \placelegend
     {\starttable[|l|l|]
      \HL
      \NC First Column \NC Second Column \NC \FR
      \HL
      \NC East\footnote{Footnote inside graphic.} \NC  North \NC \FR
      \NC West         \NC   South          \NC \LR
      \HL
      \stoptable}
     {\placelocalfootnotes}
   \stoplocalfootnotes}

Here we have footnotes of two outer ones, a local one (in the table) and a postponed one (in the graphic).

Basic Footnotes

For basic footnotes, simply use \footnote[reference]{footnote text}. The reference is optional, and can be used to refer to the same footnote again. Footnotes can be referenced with the usual \in and \at macros (see References), or the note itself can be reproduced with \note[reference]. For example:

This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.  


Thanks to Oblomov, it's also possible to use footnotes in footnotes, as in this example.

This\footnote{Or that\footnote{Or possibly even the other.}, if you prefer.} is a sentence
with a footnote.  

Footnote Numbering

You can setup the exact behaviour of footnotes with \setupnotation[footnote] (MkII: \setupfootnotes). (The command page for the MkIV version is still missing, refer to the old version; translate location to alternative and conversion to numberconversion.)

For example, to use footnotes with standard footnote symbols (which ConTeXt has defined as the conversion "set 2"), with the footnote counter resetting on each page, one would use the following:

\setupnotation[footnote][way=bypage,numberconversion=set 2]

In MkII this was:

\setupfootnotes[way=bypage, conversion=set 2]

This produces the following footnotes, using the text of the previous example.

Alternate Footnote Locations

The \setupfootnotes (MkII) command offers some options for the placement of footnotes; for instance, the location=columns option places the footnotes in a single column (of a multicolumn page) rather than across the whole page. The location=text option places the footnotes in text at a location specified by \placefootnotes; this can be easily used to create endnotes, or even to place footnotes after each paragraph or subsection.

\setupfootnotes[location=text] % MkII
This\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,
two footnotes; this one and footnote \note[footA].}.  
\placefootnotes
This is some more text, with more footnotes\footnote{Specifically, this one.}.
\placefootnotes

Footnotes at the end of each chapter

Another elegant (MkIV) example places all footnotes in a subject (unnumbered section) at the end of each chapter. It is intelligent and will not create an empty subject when there are no footnotes to be placed. At no extra cost, the subject title "Footnote" will be singular or plural depending if there is only one or several footnotes to be placed:

\startsetups[chapter:after]
     \ifcase\rawcountervalue[footnote]\relax
     \or
         \startsubject[title=Footnote]
             \placefootnotes
         \stopsubject
     \else
         \startsubject[title=Footnotes]
             \placefootnotes
         \stopsubject
     \fi
\stopsetups

\setupnotes[location=none]
\setupnotation[way=bychapter]

\setuphead[chapter][aftersection=\setups{chapter:after}]

\starttext

\startchapter[title={Chapter One}]

This one\footnote{is placed}. And\footnote{this one is too}.

\stopchapter

\chapter[title={Chapter Two}]

But this one\footnote{is not flushed}.

\startchapter[title={Chapter Three}]

Unless \type{\stopchapter} was invoked.

\stopchapter

\startchapter[title={Chapter Three}]

On a chapter with\footnote{footnote}.

\stopchapter

\stoptext

Footnotes in the margin

First we switch off footnote placement, then we place them manually into the margin.

\setupnote[footnote][location=none]
\setupnotation[footnote][
    align=flushleft,
    location=serried,
    width=broad,
]
\setuptexttexts[margin][]
    [{\framed[%
    align={right,bottom},
    frame=off,
    height=\textheight,
    width=\rightmarginwidth
    ]{\placenotes[footnote]}}]

... but not at the bottom

Hraban wanted numbered margin notes, starting in on the same line as the referenced text (like a combination of \inmargin and \footnote). Wolfgang answered:

The only way I found to achieve this is by flushing the notes at the end of each footnote entry which can be done with the next key. The positioning of each margin text is tricky because \placenotes adds skips at the begin of the block (which can be reduced with \placelocalnotes) but a inline version of the command (e.g. \placeinlinenotes) which flushes the notes without vertical skips and a rule at the begin would help.

\define\PlaceFootnote
  {\inrightmargin{\vtop{\placelocalnotes[footnote][before=,after=]}}}

\setupnote
  [footnote]
  [location=text,
   bodyfont=,
   next=\PlaceFootnote]

\setupnotation
  [footnote]
  [alternative=serried]

\setuplayout
  [width=12cm,
   rightmargindistance=0.5cm,
   rightmargin=5cm]

\starttext
\dorecurse{6}{\input ward\expanded{\footnote{This is a footnote \recurselevel}} }
\stoptext

Footnote Formatting

You can change the font used in the footnotes with \setupfootnotedefinition.

Footnotes can be placed in multiple columns, using the n=number option of \setupnotes or \setupnote (MkII: \setupfootnotes).

\setupfootnotes[n=3] % MkII
This\footnote[footA](Or that\footnote{Or the other.}, if you prefer.} is a sentence
with a footnote\footnote{Actually, two footnotes; this one and \in{footnote}[footA]
on \at{page}[footA], denoted by \note[footA].}.  


TODO: This is ugly, and points up some ConTeXt bugs that need to be fixed. (See: To-Do List)


Footnotes in pagraph form

When enabling footnotes (actually notes and linenotes) in pagraph form, there is some risk in having no right separation between body and the notes. This can be partially avoided using width=broad (Hans dixit).

\setupnote
   [footnote]
   [paragraph=yes]

\setupnotation
   [footnote]
   [alternative=serried,
    width=broad,
    distance=.5em,
    display=no]

\starttext
     \dorecurse{500}{text text text\footnote{note} }
\stoptext

Footnotes in Floats

Floats cannot include normal footnotes, because they are likely to float to another page from the page on which they were defined, thus getting the footnotes out of order. Thus, to include footnotes in a float, one must use local footnotes. This table, which uses the \placelegend command to create a place for the footnotes, illustrates the process:

\startlocalfootnotes[n=2]
\placetable{A table with footnotes.}
  \placelegend
    {\starttable[|l|r|]
      \HL
      \VL One\footnote{First} \VL Two\footnote{Second} \VL\FR
      \VL Three\footnote{Third} \VL Four\footnote{Fourth} \VL\LR
      \HL
      \stoptable}
    {\placelocalfootnotes}
\stoplocalfootnotes

When using natural tables, the above leads to alignment problems. An alternative is to use:

\defineframed[noteframed]
\setupframed[noteframed]
  [width=\hsize,
   frame=off,
   align=right,
   %height=fit,
   top=\hbox\bgroup,
   bottom=\egroup]

\starttext

\startlocalfootnotes[n=0]
\placetable
{Caption}
{\placelegend
{\bTABLE
\bTR\bTD One\footnote{First} \eTD\bTD Two\footnote{Second} \eTD\eTR
\bTR\bTD Three\footnote{Third} \eTD\bTD Four\footnote{Fourth} \eTD\eTR
\eTABLE}
{\noteframed{\placelocalfootnotes}}}
\stoplocalfootnotes

\stoptext

Footnotes in a box

Note that it is necessary to add the command \automigrateinserts (for example before \starttext) in order to correctly handle the placement of footnotes within a box such as \framed or \placeongrid...

Placing Footnotes Manually

In some cases, ConTeXt's footnoting system may not be able to do exactly what you want. For instance, you may want to place a footnote in a table so that the footnote appears with the rest of the footnotes on the page, or you may want to create a footnote to a footnote to a footnote. Many of these cases can be handled by using the \footnotetext command (which creates a footnote without placing the corresponding symbol in the text) and the \note command (which places the footnote symbol in the text, but does not create a footnote).

For example, to create a footnote to a footnote to a footnote, all but the first footnotes are created with \footnotetext commands, which are placed in the main text – thereby ensuring that the footnotes are numbered and appear in the correct order. Then, these footnotes are referenced by \note commands within the relevant footnotes. In this example, the lines are broken for clarity; note the % at the end of each line to prevent spurious spaces in the text.

This%
\footnote{Or that\note[footB], if you prefer.}%
\footnotetext[footB]{Or possibly even the other\note[footC].}%
\footnotetext[footC]{It could be something entirely different.}
is a sentence with nested footnotes.

Suppressing Footnotes Entirely

The boolean \notesenabled controls whether footnotes are processed at all. If set to false, invocations of \footnote will be ignored. After it is set to true again ConTeXt will pick up the footnote counters at their previous state, so numbering will continuous.

\setuppapersize [A7]
\starttext

  \dorecurse {2} { foo \footnote {bar} baz \par }

  \notesenabledfalse

  \dorecurse {3} { foo \footnote {bar} baz \par }

  \notesenabledtrue

  \dorecurse {2} { foo \footnote {bar} baz \par }

\stoptext

Color of Footnote Links that Refer to the Same Page

If you have set footnotes to be interactive and have noticed that your footnote links become red, it is because they are linked to content on the same page on which they appear. This means they are governed by \setupinteraction’s attribute contrastcolor, rather than color.

To fix the redness (or change it to a different color), try:

\setupinteraction[state=start,color=black,contrastcolor=black]

Changing footnote interlinespace

If you want to change the interlinespace of footnotes without impacting the rest of the document, try:

\startsetups[footnote:interlinespace]
  \setupinterlinespace[line=2.8ex]
\stopsetups

\setupnote[footnote][setups=footnote:interlinespace]



Special Needs

There are numerous ways to display and format footnotes. The following section gathers solutions to some special tasks asked on the mailing list.

Hyphenation

  • Is there a way to turn off hyphenation for the main body of my text, but enable it for the footnotes?
 \starttext

 \setupnote[footnote][align={normal,hyphenated}]

 \setupalign[hyphenated] \input tufte \footnote{\input tufte \relax} \par

 \setupalign[nothyphenated,stretch,tolerant] \input tufte
 \footnote{\input tufte \relax} \par

 \stoptext

Mark Placement

  • How can I change the placement of the footnote mark?

Currently, footnotes are set so that the left end of the text of the footnote is aligned with the left edge of the text, and the footnote number hangs out into the margin. Is it possible to change this? (For instance, suppose I would like the number aligned to the text-edge, and then a fixed-width space, and then the text?)

This behavior is controlled by the location key of \setupnotation. Here are some examples:

Note number is typeset in an area with a width of 1 cm, aligned at the left of the text area:

\definepapersize[wiki][width=8cm,height=8cm]

\setuppapersize[wiki][wiki]

\starttext

\showframe

\setupnotation[footnote][location=left,width=1cm]
\setupnote[footnote][location=page,numbercommand=]

test \footnote{test}

\stoptext 

produces


Suppose that one wants a width of 1.5 em. Then

\setupnote[footnote][margindistance=0em,command=\myfootnotecommand]
\setupnotation[footnote][location=left,hang=1]

\def\myfootnotecommand#1{\hbox to 1.5em{#1.}}

Line Spacing

  • Can I change the line spacing of a footnote independently of that of the main text?

The way to do this is not obvious, but this is the code you need to use:

\def\setnotebodyfont
{\switchtobodyfont[your desired font size]\setupinterlinespace[your desired spacing]} 

Placement in Bidirectional Documents

  • Can the footnote rule be placed on the right-hand side?

This is possible via setting the rule key of \setupnote and \definenote. In right-to-left documents it is usually desirable to have right-to-left footnotes, where right-aligned footnote rules make more sense aesthetically. Set rule=right to achieve this. Prior to 01-04-2016 Beta, this would have turned off the footnote rule completely: one needed to use rule={on,right}.

In a BiDi document the direction of the surrounding text where the \footnote is invoked determines the direction of the footnote block to come later. Therefore, some footnotes may be right-to-left whereas others can be left-to-right. Note that the text of the footnote does not play a role here. The style designer decides whether left or right footnote rules make more sense. However, there is a third option: setting rule=paragraph looks at the first paragraph in the footnote block and let that determine the position of the footnote rule. In other words, if the footnote block of the page starts with an RTL text we end up with a right-aligned footnote rule and a left-aligned rule is typeset otherwise. (The first line/paragraph of the footnote block on a page need not correspond to the start of a footnote; it can rather be the leftover from a long footnote that started on some previous page.)

For more fancy footnote rules, you can use rulecommand=\MyRuleCommand. Look at the definition of \normalnoterule in strc-not.mkvi for a starting point.