Changes

Jump to navigation Jump to search
15 bytes removed ,  11:20, 7 January 2021
fix a few instances of old code, remove comments about MkIV being new, some restructuring
==Default==
Titles define the structure of your document. Decide yourself, how deep you want to nest them, there are 12 levels of depth predefined:
{| class=wikitable
! Numbered !! Unnumbered
|-
| {{cmd|part}} || —
|-
| {{cmd|chapter}} || {{cmd|title}}
|}
 The unnumbered versions don't don’t appear in a table of contents! To change that, see the section on [[#Unnumbered_titles_in_table_of_contents|Unnumbered titles in the table of contents]].
Also note that in the front matter of the document, all titles are unnumbered by default. The titles from the 'numbered' category still show up in the table of contents, though, and the titles from the 'unnumbered' category still don't.
Note that reference labels are limited to ASCII characters in traditional TeX.
This limitation has been removed in ConTeXt mkivMkIV.
==New MkIV Sectioning=start/stop sectioning===
ConTeXt MkIV adds several new commands which supersede Besides the older traditional {{cmd|chapter}}, {{cmd|section}} etc. The new commands are you can also use the more verbose, but also more flexibleversion of sectioning commands, and allow better these support for tagged-PDF, XML and ePUB outputbetter and also allow to insert code at the end of these sections.
{| class=wikitable
! Traditional !! NewStart/Stop
|-
| {{cmd|part}} || {{cmd|startpart}}
|}
Each of these start-commands has a corresponding stop-command which should to be used at the end of the section. For example:
<context mode=mkiv source=yes text=produces>% mode=mkiv
\setuppapersize[A5]
</context>
The following keys are available for the start-commands(see also {{cmd|setupsection}}):
{| class=wikitable
|}
It is also possible to set per-section variables, and retrieve them with the {{cmd|structureuservariable}} command:
===Section Variable=== You can set custom variables per section, and retrieve them with the {{cmd|structureuservariable}} command: <context mode=mkiv source=yes text=produces>% mode=mkiv
\setuppapersize[A5]
\startchapter[title={Foo Bar}][foo=bar]% extra brackets!
foo is \quote{\structureuservariable{foo}}
</context>
 
Beware, if you want to reference these in your ToC setup, you need {{cmd|structurelistuservariable}}.
==Titling Style==
==Using colors in chapters and sections==
If you want you may have colors on your document's For colorful chapters or sections.To do that you should use refer to {{cmd|setuphead}}. Take a look at the following
example:
<texcode>
\setupcolors[state=start] \setuphead[chapter][header=empty] % Important. You won't Chapter pages won’t have colors without it.headers
\setuphead[chaptersection][headercolor=emptydarkcyan] % Chapter pages won't have headersThis is how you change your section’s color.
\setupheadertexts[][chapter] % The header will be the chapter's name
\chapter{Black chapter 1}
 
\setuphead[section][color=darkcyan] % This is how you change your chapter's color.
\section{Dark cyan section 1.1}
\setuphead[chapter][color=darkgreen]
% This works, but avoid changing setups in the middle of your document,
% better define different versions of chapter, see next section
\chapter{Dark green chapter}
==Your Own Titling Levels==
Of course you can define your own titling commands and probably must want to adapt the default settings.
<texcode>
A new header {{cmd|myheader}} is defined and it inherits the properties
of {{cmd|section}} (title, subject, whatever). You can ''define'' or setup severalheaders at once!
==Formatting Titles with {{cmd|setuphead}}==
{| class=wikitable
|-
! Text !! Number!! Both
|-
| textstyle
| numberstyle
| style
|-
| textcommand
| numbercommand
| command
|-
| deeptextcommand
| deepnumbercommand
| —
|-
|}
</texcode>
'''Explanation''' (provided by Willi Egger on the mailing list)
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.
==== When using front, body, back matters and appendices ====
As Wolfgang explained on the mailing list, when When using {{code|1=*frontmatter}}, {{code|1=*bodymatter}}, {{code|1=*backmatter}} and {{code|1=*appendices}}, you need to remove the page they create to get the page before a new chapter or part with no headers and footers.
<texcode>
\stoptext
</texcode>
 
== Independent Section Numbering ==
<texcode>
\setuphead defineresetset[default][chapter1,1,0][resetnumber=no1]% reset part, chapter, but not section\setupsection[section]setuphead[previousnumbersectionresetset=nodefault]
</texcode>
This is handled differently in mkiv (where "resetnumber=no" is silently ignored)The MkII way was:
<texcode>
\defineresetsetsetuphead [defaultchapter][1,1,0resetnumber=no]\setupsection[1section] % reset part, chapter, but not section\setuphead[sectionresetsetpreviousnumber=defaultno]
</texcode>
 
==Unnumbered titles in table of contents==
\setuphead [intro] [number=no]
\definecombinedlist [content][list={intro,chapter,section}]
\setuplist [intro] [headnumber=no]
</context>
Note that just putting the introduction in the frontmatter already did the trick for me (on a recent MkIV)is enough, since frontmatter switches off chapter numbering.
An alternative approach:
% Redefine the toc list to include titles
\definecombinedlist[content][list={title, section}]
</texcode>
 
Usually you don’t want this. It also includes implicit titles (from ToC or Index) in the ToC.
== Complete Section Numbering ==
</texcode>
In that case, you would get <code>1 A</code> <code>1 C</code>. To enable complete section numbering, you would need in this case (using a beta after 2017.08.07 11:30):
<texcode>
==Your Own Title Styles==
Sometimes the possibilities of {{cmd|setuphead}} aren't aren’t enough. You can define
your own styling commands, as shown in the following examples.
===Start the title in the margin===
This very simple example shows how to start a title within the margin, rather than at the text's text’s edge
<context source=yes>
</context>
===Chapter number and titles in new lineseparate lines=== To have the chapter title simply in a new line , a new command needs to be defined that takes care of this. It needs to be wrapped in {{cmd|framed}}.
<context source=yes>
===Title page with special background===
If you want the title page of every chapter to have a special background (different from the background of normal pages), here's here’s a very effective trick that Hans has provided on the mailing list. In addition, this will give every chapter its own color scheme (Mkiv only, hence won't compile on contextgarden):
<context source=yes>
</context>
See [http://www.ntg.nl/pipermail/ntg-context/2003/002053.html the mailing list thread(2003)] for more on this.
===Headings numbered independent of chapters or other headings===
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list(2003)]:
<texcode>
% use a lower level head
\definehead[Problem][subsubsubsection]
% cleaned up
\setuphead[Problem]
[style=\ss\bf,
color=red,
% use a label text
\setuplabeltext[Problem={Problem }]
% use your own numbers
\setuphead[Problem]
[ownnumber=yes]
% nicer here
\setuplist[Problem]
[alternative=c,
criterium=all,
===Chapter headers===
This is an example of chapter headings with an enlarged shadow behind them, based on [http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 a solution by Hans(2004)].
<context source=yes>
</texcode>
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html](2005)
Users of MkIV can safely rely on <tt>command</tt> and don't have to bother with the <tt>deep...command</tt> variants. However, {{cmd|currentheadnumber}} does not seem to return anything but 0. Thus, the following code is required to define <tt>\MyChapterCommand</tt> when using MkIV:
</texcode>
[http://archive.contextgarden.net/message/20100817.102859.206d858e.en.html](2010)
===Chapter head with absolute positioning of following text===
===Section head without chapter number ===
If you only want the section number (in mark IV) in the section title you add  
<texcode>
===Editing Bold Math in Section Titles===
When a section title is formatted in boldface text, this doesn't automatically typeset embedded math in bold. This is probably a good thing, as many math fonts do not include all characters in boldface, and often authors use boldface to distinguish between different meanings (for instance, scalar and vector variables). However, in some cases, it <i>''is</i> '' desirable to format the math in the section titles in boldface.
Here a very simple example:
<texcode>\definetypeface[boldmath][mm][boldmath][latin-modern][default]\setuphead[section][style=\boldmath\rm\bfa]\starttext\section{Bold $a^2+b^2=c^2$ {\em bla}}text: not bold $a^2+b^2context source=c^2$ {\em bla}\stoptext</texcode> <contextyes>
\definetypeface[boldmath][mm][boldmath][latin-modern][default]
\setuphead[section][style=\boldmath\rm\bfa]

Navigation menu