Difference between revisions of "Sidenotes style"

From Wiki
Jump to navigation Jump to search
(created page)
 
(Improve presentation: true subheadings, and code no wider than 80-ish characters (horizontal scrollbars are the pits).)
Line 5: Line 5:
 
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: [https://github.com/andythomas/TeX-sidenotes TeX-sidenotes]. Many thanks to the mailing list for all the help with it.
 
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: [https://github.com/andythomas/TeX-sidenotes 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:
+
==== Prelude ====
 +
Load the module with the layout and the helper macros:
  
 
<texcode>
 
<texcode>
Line 24: Line 25:
 
</texcode>
 
</texcode>
  
'''bibtex'''. The next lines set up the look of the citations and a file containing the sample references.
+
==== BibTeX ====
 +
The next lines set up the look of the citations and a file containing the sample references.
  
 
<texcode>
 
<texcode>
Line 31: Line 33:
 
</texcode>
 
</texcode>
  
'''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.
+
==== 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.
  
 
<texcode>
 
<texcode>
Line 42: Line 45:
 
</texcode>
 
</texcode>
  
'''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
+
==== Table of contents====
by the caesar module. In this case, only chapters are shown in the toc.
+
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.
  
 
<texcode>
 
<texcode>
Line 50: Line 53:
 
</texcode>
 
</texcode>
  
'''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.
+
==== 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.
  
 
<texcode>
 
<texcode>
Line 57: Line 61:
 
</texcode>
 
</texcode>
  
'''chapter'''. It is time for the first chapter. This in done in the usual way.
+
==== Chapter ====
 +
It is time for the first chapter. This in done in the usual way.
  
 
<texcode>
 
<texcode>
Line 63: Line 68:
 
</texcode>
 
</texcode>
  
'''sidenote'''. After some text, an annotation can be placed on the same page in the margin using the sidenote macro.
+
==== Sidenote ====
 +
After some text, an annotation can be placed on the same page in the margin using the sidenote macro.
  
 
<texcode>
 
<texcode>
Line 69: Line 75:
 
</texcode>
 
</texcode>
  
'''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.
+
==== 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.
  
 
<texcode>
 
<texcode>
Line 75: Line 82:
 
</texcode>
 
</texcode>
  
'''section'''. The sections are also started the common way.
+
==== Section ====
 +
The sections are also started the common way.
  
 
<texcode>
 
<texcode>
Line 81: Line 89:
 
</texcode>
 
</texcode>
  
'''figures'''. There are 3 different macros to place figures in the document. The first option is a small figure in the margin.
+
==== Figures ====
 +
There are 3 different macros to place figures in the document. The first option is a small figure in the margin.
  
 
<texcode>
 
<texcode>
Line 92: Line 101:
  
 
<texcode>
 
<texcode>
\startplacefigure[title={A larger rectangle in the main area of the text, i.e.\ it does not span into the margin.},
+
\startplacefigure[
 +
  title={A larger rectangle in the main area of the
 +
        text, i.e.\ it does not span into the margin.},
 
   reference=fig2]
 
   reference=fig2]
 
   \externalfigure[dummy][textwidth]
 
   \externalfigure[dummy][textwidth]
Line 101: Line 112:
  
 
<texcode>
 
<texcode>
\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.}]
+
\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]
 
   \externalfigure[dummy][fullwidth]
 
\stopplacefigure
 
\stopplacefigure
 
</texcode>
 
</texcode>
  
'''tables'''. The same options are available for placing tables. The first one is again a small one in the margin.
+
==== Tables ====
 +
The same options are available for placing tables. The first one is again a small one in the margin.
  
 
<texcode>
 
<texcode>
\startplacemargintable[reference=table1, title={A couple of numbers in a table in the margin.}]
+
\startplacemargintable[
 +
  reference=table1,  
 +
  title={A couple of numbers in a table in the margin.}]
 
\starttable[|c|c|c|]
 
\starttable[|c|c|c|]
 
   \NC A \NC B \NC C\NC\SR
 
   \NC A \NC B \NC C\NC\SR
Line 120: Line 137:
  
 
<texcode>
 
<texcode>
\startplacetable[reference=table2, title={A couple of numbers in a larger table. This table spans the usual 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|]
 
\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  A \NC  B \NC C \NC D \NC E \NC F \NC G \NC H \NC \SR
Line 131: Line 151:
  
 
<texcode>
 
<texcode>
\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.}]
+
\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|]
 
\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  A \NC B \NC C \NC D \NC E \NC F  
\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
+
  \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
 
\stoptable
 
\stopplacewidetable
 
\stopplacewidetable
 
</texcode>
 
</texcode>
  
'''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.
+
==== 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.
  
 
<texcode>
 
<texcode>
 
\startfullwidth
 
\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.  
+
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
 
\stopfullwidth
 
</texcode>
 
</texcode>
  
'''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 ====
 +
Also useful might be the usual macro to place a note in the margin, but this time without a mark in the text.
  
 
<texcode>
 
<texcode>
\margintext{It is also possible to put a remark in the margin without a corresponding mark in the text.}
+
\margintext{It is also possible to put a remark in the margin without a  
 +
  corresponding mark in the text.}
 
</texcode>
 
</texcode>
  
'''references'''. Finally, the references are placed, also using the common macro, but only used references are printed.
+
==== References ====
 +
Finally, the references are placed, also using the common macro, but only used references are printed.
  
 
<texcode>
 
<texcode>

Revision as of 15:57, 11 June 2012

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