Difference between revisions of "Footnotes"

From Wiki
Jump to navigation Jump to search
m (beginning to post a few examples, to be continued)
Line 107: Line 107:
 
</texcode>
 
</texcode>
  
This produces the the following footnotes, using the text of the previous example.
+
This produces the following footnotes, using the text of the previous example.
  
 
<context>
 
<context>

Revision as of 07:50, 5 August 2010

< Structurals | References >

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 as usual with \setupfootnotes. 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:

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

Beware, in MkIV this became

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

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

Alternate Footnote Locations

The \setupfootnotes 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]
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

Footnote Formatting

You can change the font used in the footnotes with \setupfootnotedefinition[before=\MyFontCommand].

Footnotes can be placed in multiple columns, using the n=number option in \setupfootnotes.

\setupfootnotes[n=3]
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 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

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.

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.

  • 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
  • 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 in the \setupnotedefinition command. Here are some examples:

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

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

\setuppapersize[wiki][wiki]

\starttext

\showframe

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

test \footnote{test}

\stoptext 

produces


Suppose that one wants a width of 1.5em. Then

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

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

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 strc-ref.mkiv.

\unexpanded\def\textreference {\dosingleargument\dotextreference}
\unexpanded\def\pagereference {\dosingleargument\dopagereference}
\unexpanded\def\reference     {\dosingleargument\doreference    }
\unexpanded\def\setreference  {\dodoubleargument\dosetreference }