Changes

Jump to navigation Jump to search
simplified the code, removed some outdated stuff
{{todo|This page needs to be reorganized: progression from simple to more complex use is a bit circular..}} ==First View== < context source="yes">\setuppapersize[A7]\starttext\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[Structurals]] | [[References]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}\stoptext</contextHere 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 <{{cmd>|footnote</cmd><tt>|[reference]{footnote text}</tt>}}.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:
<texcodecontext source="yes">\setuppapersize[A7]\starttextThis\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].}.
\stoptext</texcodecontextThanks to Oblomov, it’s also possible to use footnotes in footnotes, as in this example.
<contextsource="yes">\setuppapersize[A7]
\starttext
\strut\vfill % A hack to shorten the page.This\footnote[footA]({Or that\footnote{Or possibly even 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].}.
\stoptext
</context>
==Footnote Numbering==
Thanks to Oblomov, it's also possible to use You can setup the exact behaviour of footnotes in footnotes, as in this examplewith {{cmd|setupnotation|[footnote]}} or {{cmd|setupfootnotes}}.
<texcode>This\For example, to use footnotes with standard footnotesymbols like asterisks and daggers (Or that\footnote{Or possibly even which ConTeXt has defined as the other.}conversion "set 2"), if you prefer.} is a sentencewith a the footnote. </texcode>counter resetting on each page, one would use the following:
<contextsource="yes" text="This produces the following footnotes:">\setuppapersize[A7]\setupnotation[footnote][way=bypage,numberconversion=set 2]
\starttext
\strut\vfill % A hack to shorten the page.This\footnote([footA]{Or that\footnote{Or possibly even the other.}, if you prefer.} is a sentencewith a footnote\footnote{Actually,two footnotes; this one and \in{footnote}[footA] on \at{page}[footA], denoted by \note[footA].}.
\stoptext
</context>
==Alternate Footnote Locations==
 
The {{cmd|setupnotation}} 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.
<context source="yes">\setuppapersize[A7]\setupnotation[footnote][location=text]\starttextThis\footnote[footA]{Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,two footnotes; this one and footnote \note[footA].}. \placefootnotesThis is some more text, with more footnotes\footnote{Specifically, this one.}.\placefootnotes\stoptext</context> === Footnotes at the end of each chapter =Footnote Formatting==
Footnotes can Another elegant 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 in multiple columns. At no extra cost, using the <tt>n=<i>number</i></tt> option in <cmd>setupfootnotes</cmd>.subject title "Footnote" will be singular or plural depending if there is only one or several footnotes to be placed:
<texcode>
\setupfootnotesstartsetups[nchapter:after] \ifcase\rawcountervalue[footnote]\relax \or \startsubject[title=3Footnote]This \footnoteplacefootnotes \stopsubject \else \startsubject[footAtitle=Footnotes](Or that \placefootnotes \stopsubject \footnote{Or the other.}, if you prefer.} is a sentencefiwith a footnote\footnote{Actually, two footnotes; this one and stopsetups \in{footnote}setupnotes[footAlocation=none]on \at{page}setupnotation[footAway=bychapter], denoted by  \notesetuphead[footAchapter].[aftersection=\setups{chapter:after}. </texcode>]
<context>
\setupfootnotes[n=3]
\starttext
 \strut\vfill % A hack to shorten the page.startchapter[title={Chapter One}] Thisone\footnote[footA](Or that{is placed}. And\footnote{Or the other.this one is too}, if you prefer.} is a sentencewith a footnote\stopchapter \footnotechapter[title={Actually, two footnotes; Chapter Two}] But this one and \infootnote{footnoteis not flushed}. \startchapter[footAtitle={Chapter Three}]on Unless \attype{page\stopchapter}was invoked. \stopchapter \startchapter[footAtitle={Chapter Three}], denoted by  On a chapter with\note[footA].footnote{footnote}.  \stopchapter 
\stoptext
</contexttexcode> You can also just use {{cmd|endnote}} and {{cmd|placeendnotes}}. ===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>
{{todo|This is ugly, and points up some ConTeXt bugs that need to be fixed===.}}.. but not at the bottom===
==Footnote Numbering==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:
You The only way I found to achieve this is by flushing the notes at the end of each footnoteentry which can setup be done with the exact behaviour next key. The positioning of footnotes as usual each margin text is trickybecause {{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. <cmdtt>setupfootnotes\placeinlinenotes</cmdtt>. For example, to use footnotes with standard footnote symbols () which ConTeXt has defined as flushes the conversion "set 2"), with notes without vertical skips and a rule at the footnote counter resetting on each page, one begin would use the following:help.
<texcode>
\setupfootnotesdefine\PlaceFootnote {\inrightmargin{\vtop{\placelocalnotes[wayfootnote][before=,after=]}}} \setupnote [footnote] [location=text, bodyfont=, next=\PlaceFootnote] \setupnotation [footnote] [alternative=serried] \setuplayout [width=12cm, rightmargindistance=bypage0.5cm, conversion rightmargin=set 25cm\starttext\dorecurse{6}{\input ward\expanded{\footnote{This is a footnote \recurselevel}} }\stoptext
</texcode>
This produces {{todo|It got a bit easier in LMTX, we must adapt the example.}} ==Footnote Formatting== You can change the font used in the following footnoteswith{{cmd|setupfootnotedefinition|[before=\MyFontCommand]}}. Footnotes can be placed in multiple columns, using the text <code>n=<i>number</i></code> option of the previous example{{cmd|setupnotes}} or {{cmd|setupnote}}.
<contextsource="yes">\setupfootnotessetuppapersize[A7]\setupnotes[way=bypage, conversionfootnote][n=set 23]
\starttext
\strut\vfill % A hack to shorten the page.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].}.
\stoptext
</context>
{{todo|This is ugly, and points up some ConTeXt bugs that need to be fixed.}} ==Alternate Footnote Locations=Footnotes in pagraph form===
The <cmd>setupfootnotes</cmd> command offers some options for the placement of When enabling footnotes; for instance(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>locationwidth=columnsbroad</code> option places the footnotes in a single column (of a multicolumn page) rather than across the whole page[http://www.ntg. The <code>location=text<nl/pipermail/ntg-context/code> option places the footnotes in text at a location specified by <cmd>placefootnotes<2013/cmd>; this can be easily used to create endnotes, or even to place footnotes after each paragraph or subsection073650.html Hans dixit]).
<texcode>
\setupfootnotessetupnote [location=textfootnote]This\footnote [footAparagraph=yes](Or that, if you prefer.} is a sentence with a footnote \footnote{Actually,setupnotationtwo footnotes; this one and [footnote \note[footA].}. \placefootnotes [alternative=serried,This is some more text width=broad, with more footnotes\footnote{Specifically distance=.5em, this one.}.\placefootnotes</texcode> display=no]
<context>
\starttext
\setupfootnotes[location=dorecurse{500}{text text text]This\footnote[footA](Or that, if you prefer.} is a sentence with a footnote\footnote{Actually,two footnotes; this one and footnote \note[footA].}. \placefootnotesThis is some more text, with more footnotes\footnote{Specifically, this one.}.\placefootnotes
\stoptext
</contexttexcode>
==Footnotes in Floats==
[[Floating Objects|Floats]] cannot include have problems with 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:
<texcodecontext source="yes">\startlocalfootnotes[n=0]
\placetable{A table with footnotes.}
\placelegend
{\strut\starttable[|l|r|]
\HL
\VL One\footnote{First} \VL Two\footnote{Second} \VL\FR
{\placelocalfootnotes}
\stoplocalfootnotes
</context>
 
When using natural tables, the above leads to alignment problems. An alternative is to use:
 
<context source="yes">
\setuppapersize[A7]
\defineframed[noteframed]
\setupframed[noteframed]
[width=\hsize,
frame=off,
%align=right,
%height=fit,
top=\hbox\bgroup,
bottom=\egroup]
 
\starttext
 
\startlocalfootnotes
\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
</context>
 
==Footnotes in a box==
 
Before LMTX, it was 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==
 
In some cases, ConTeXt’s footnoting system may not be able to do exactly what you want. (The examples mentioned were outdated.) 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}} 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.
 
<context source="yes">
\setuppapersize[A7]
\starttext
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.
\stoptext
</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>
You can also set the colors to empty (just a comma) to avoid changing text color at all. == Changing footnote interlinespace == If you want to change the interlinespace of footnotes without impacting the rest of the document, try:<contexttexcode>\startlocalfootnotesstartsetups[n=0footnote:interlinespace] \placetable{A table with footnotessetupinterlinespace[line=2.}8ex] \placelegendstopsetups  {\strut\starttablesetupnote[footnote][|l|r|setups=footnote:interlinespace] \HL</texcode>  == 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? <texcode> \VL One\setupnote[footnote][align={Firstnormal,hyphenated} ] \VL Twosetupalign[hyphenated] \input tufte \footnote{Second\input tufte \relax} \VLpar \setupalign[nothyphenated,stretch,tolerant] \FRinput tufte \VL Three\footnote{Third\input tufte \relax} \VL Four\par</texcode> ===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 footnotenumber 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 of {Fourth{cmd|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: <context source="yes" text="produces">\VLsetuppapersize[A7]\LRstarttext  \HLshowframe \setupnotation[footnote][location=left,width=1cm] \stoptable}setupnote[footnote][location=page,numbercommand=]  test \footnote{\placelocalfootnotestest} \stoplocalfootnotesstoptext
</context>
 
 
Suppose that one wants a width of 1.5 em. Then
 
<texcode>
\setupnote[footnote][margindistance=0em,command=\myfootnotecommand]
\setupnotation[footnote][location=left,hang=1]
 
\def\myfootnotecommand#1{\hbox to 1.5em{#1.}}
</texcode>
 
===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>
\def\setnotebodyfont
{\switchtobodyfont[your desired font size]\setupinterlinespace[your desired spacing]}
</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.</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 {{src|strc-not.mkvi}} for a starting point.
 
[[Category:Basics]]

Navigation menu