Changes

Jump to navigation Jump to search
2,749 bytes added ,  05:52, 15 July 2021
< [[Structurals]] | [[Visuals]] >
 
==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}} || &#151;
|-
| {{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.
<texcode>
\at{page}[hasselt-by-night].
</texcode>
(see See {{cmd|at}})</texcode>.
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]
This is an old-style \ConTeXt\ section.
\startsection [
title={New Section},
reference=sec:new,
]
This is a new-style section.
 
\stopsection
</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
| —
|-
|}
Using {{cmd|setuppagenumbering|2=[alternative=doublesided]}} makes the chapters start
on the right page. However, the blank page is not truely truly empty, it contains headers andfooters. To get truely truly empty pages, use the following
<texcode>
</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>
\definestructureresetsetsetuphead [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 == You might have documents in which your sections don’t follow the structure, such as in: <texcode>\section{A}%\subsection{B}\subsubsection{C}</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: <texcode>\setuphead[subsection][criterium=all]
</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>
\setupheadtext[chapter=Chapter]
\chapter[title={My First Chapter}]
</context>
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]
\defdefine[2]\Myheader#1#2{%
\framedtext
[width= \overlaywidth,
===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>
StartPage ;
fill ((topboundary Page --cycle) enlarged(0,5mm)) shifted (0,-20mm)
withcolor \MPcolor{color:title:\namedstructureuservariable{chapter}{mycolor}} ;
StopPage ;
MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} := 1 ;
[alternative=text,distance=0pt,command=\MyHead,style=\sc]
\defdefine[2]\MyHead#1#2{\inmargin{#1 #2}}
\starttext
</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,
</texcode>
===Chapter headersHeadings===
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>
[command=]
\defdefine[2]\MySectionCommand#1#2%
{\externalfigure[section-\currentheadnumber]}
</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===
</texcode>
===Section head without chapter number ===
 
If you only want the section number in the section title you add
 
<texcode>
\setuphead[section][sectionsegments=section]
\starttext
\chapter{Eric}
\section{Foo 1}
\subsection{Bar one}
\section{Foo 2}
\stoptext
</texcode>
 
But as once you changed one you have to change the lower ones.
So you have to add the definition of sectionsegments in subsection, subsubsection, ...
 
<texcode>
\setuphead[section][sectionsegments=section]
\setuphead[subsection][sectionsegments=section:subsection]
\setuphead[subsubsection][sectionsegments=section:subsubsection]
 
\starttext
\chapter{Eric}
\section{Foo 1}
\subsection{Bar one}
\subsubsection{Barbar one }
\subsubsection{Barbar two}
\subsection{Bar two}
\subsubsection{Barbar one}
\subsubsection{Barbar two}
\section{Foo 2}
\subsection{Bar one}
\subsubsection{Barbar one}
\subsubsection{Barbar two}
\stoptext
</texcode>
 
It's not written here but you can also change the conversion of the numbering with
 
<texcode>
\definestructureconversionset[mySet][A,R,n,n,a,r][n]
\setuphead[chapter,section,subsection,subsubsection,subsubsubsection][sectionconversionset=mySet]
</texcode>
 
The parameters in definestructureconversionset are
 
the set name
 
the codes for conversion (one for each level)
 
the default conversion for the missing level
 
You can find the conversions codes at [http://wiki.contextgarden.net/Conversions]
 
===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 ''is'' desirable to format the math in the section titles in boldface.
 
Here a very simple example:
<context source=yes>
\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^2=c^2$ {\em bla}
\stoptext
</context>
 
[[Category:Basics]]
[[Category:Fonts]]
[[Category:Graphics]]
[[Category:Text elementsMath]]
419

edits

Navigation menu