Sidenotes style

From ConTeXt wiki

Andy Thomas


I am writing a physics textbook in ConTeXt Mk IV and I would like to share the macros I collected in a module. It is based on the design of our recent PhD theses and might be useful as an example with a lot of sidenotes (text, figures, tables, references). The newest version of the module is hosted on github.com: TeX-sidenotes. Many thanks to the mailing list for all the help with it.

Prelude

Load the module with the layout and the helper macros:

\usemodule[caesar]

The next task is to set the main language of the manuscript. This is done the usual way.

\mainlanguage[en]
\language[en]

To avoid the hassle of several files, a library to set up dummy figures is initialized.

\useMPlibrary[dum] 

BibTeX

The next lines set up the look of the citations and a file containing the sample references.

\setupbibtex[database={library.bib},sort=author]
\setuppublications[alternative=apa]

Title page

Now, the text starts and information about the book has to be added. The name of the author, the title and the publisher can be set to automatically generate the title page.

\starttext
\setvariables
  [titlepage]
  [title={Caesar\\Examples},
   author={Andy Thomas},
   publisher={Bielefeld University}]

Table of contents

An auto-generated table of contents (toc) is placed the usual way, the look of the toc and e.g. the chapter headings is changed by the caesar module. In this case, only chapters are shown in the toc.

\title{Contents} 
\placelist[chapter]

List of tables

A list of all the tables can be placed as well. The placelist macro needs two parameters this time, all tables are supposed to be shown here.

\title{Tables}
\placelist[table,widetable]

Chapter

It is time for the first chapter. This in done in the usual way.

\chapter{Examples}

Sidenote

After some text, an annotation can be placed on the same page in the margin using the sidenote macro.

\sidenote{All information is on the same page, no turning of pages is necessary.} 

Citations

Citations work in a similar manner and are also placed in the margin of the document. This is done with the sidecite macro. The macro allows two optional parameters besides the citekey. The values of left and right are placed directly in front of the reference and directly afterwards, respectively.

\sidecite[left={See e.g.\ }, right={ And other Tufte books.}][Tufte1990,Tufte2006]

Section

The sections are also started the common way.

\section{Figures}

Figures

There are 3 different macros to place figures in the document. The first option is a small figure in the margin.

\startplacemarginfigure[ title={A small rectangle put in the margin.}, reference=fig1]
  \externalfigure[dummy][marginwidth]
\stopplacemarginfigure

A larger figure can be put in the text with

\startplacefigure[
  title={A larger rectangle in the main area of the
         text, i.e.\ it does not span into the margin.},
  reference=fig2]
  \externalfigure[dummy][textwidth]
\stopplacefigure

In case that an even wider figure is needed, the third option spans over the text as well as the margin area. No special macro is needed here, just the figure width is larger.

\startplacefigure[
  title={An even larger rectangle. This is the widest figure 
         option. Both, the text as well as the margin width 
         are used for the diagram.}]
  \externalfigure[dummy][fullwidth]
\stopplacefigure

Tables

The same options are available for placing tables. The first one is again a small one in the margin.

\startplacemargintable[
  reference=table1, 
  title={A couple of numbers in a table in the margin.}]
\starttable[|c|c|c|]
  \NC A \NC B \NC C\NC\SR
  \NC 0.50 \NC 0.47 \NC 0.48  \NC \FR
\stoptable
\stopplacemargintable

The next option is a table across the text width.

\startplacetable[
  reference=table2, 
  title={A couple of numbers in a larger table. This table spans the 
         usual text width.}]
\starttable[|c|c|c|c|c|c|c|c|]
  \NC  A \NC  B \NC C \NC D \NC E \NC F \NC G \NC H \NC \SR
\NC 0.21	\NC 0.23 \NC 0.34 \NC 0.42 \NC 0.53 \NC 0.64 \NC 0.72	\NC 0.33 \NC\FR
\stoptable
\stopplacetable

And the last example show a table across the full page (textwidth plus margin). A special widefigure float is needed to get an appropriate caption width.

\startplacewidetable[
  reference={table3}, 
  title={Even more numbers in a big table are shown here. This table
         spans across the full page, text width plus margin.}]
\starttable[|c|c|c|c|c|c|c|c|c|c|c|c|]
  \NC  A \NC B \NC C \NC D \NC E \NC F 
  \NC G \NC H \NC I \NC J \NC K \NC \ L \NC 
  \SR
  \NC 0.21 \NC 0.23 \NC 0.34 \NC 0.42 \NC 0.53 \NC 0.64 
  \NC 0.72 \NC 0.33 \NC 0.22\NC 0.04 \NC 0.93 \NC 0.81 \NC
  \FR
\stoptable
\stopplacewidetable

Fullwidth text

Additionally, there is a start/stopfullwidth that allows to fill text across the full page as well. However, it does not necessary work across page breaks and might overlap with marginal material.

\startfullwidth
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus 
elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur 
dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer 
id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque 
habitant morbi tristique senectus et netus et malesuada fames ac 
turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla 
et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus 
sit amet tortor gravida placerat. Integer sapien est, iaculis in, 
pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices 
bibendum. Aenean faucibus. 
\stopfullwidth

Margintext

Also useful might be the usual macro to place a note in the margin, but this time without a mark in the text.

\margintext{It is also possible to put a remark in the margin without a 
  corresponding mark in the text.}

References

Finally, the references are placed, also using the common macro, but only used references are printed.

\placepublications[criterium=text]

The example ends here.

\stoptext