Difference between revisions of "Titles"

From Wiki
Jump to navigation Jump to search
(added some text; changed order of items, because "own styles" got too big)
Line 2: Line 2:
  
 
==Default==
 
==Default==
 +
 +
Titles define the structure of your document. Decide yourself, how deep you want to nest them:
  
 
<table>
 
<table>
 
<tr bgcolor="#CCCCCC"><th>numbered</th><th>unnumbered</th></tr>
 
<tr bgcolor="#CCCCCC"><th>numbered</th><th>unnumbered</th></tr>
<tr><td><cmd>part</cmd></td><td>--</td></tr>
+
<tr><td><cmd>part</cmd></td><td>&#151;</td></tr>
 
<tr><td><cmd>chapter</cmd></td><td><cmd>title</cmd></td></tr>
 
<tr><td><cmd>chapter</cmd></td><td><cmd>title</cmd></td></tr>
 
<tr><td><cmd>section</cmd></td><td><cmd>subject</cmd></td></tr>
 
<tr><td><cmd>section</cmd></td><td><cmd>subject</cmd></td></tr>
Line 12: Line 14:
 
<tr><td>...</td><td>...</td></tr>
 
<tr><td>...</td><td>...</td></tr>
 
</table>
 
</table>
 +
 +
The "unnumbered" versions don't appear in a table of contents! But you can switch off the numbering of the "numbered" versions with <cmd>setuphead</cmd> to get unnumbered titles ''and'' a toc (confusing?).
 +
 +
===Referencing Titles===
  
 
Every heading command can take an optional parameter as reference:
 
Every heading command can take an optional parameter as reference:
Line 25: Line 31:
 
(see <cmd>at</cmd>)
 
(see <cmd>at</cmd>)
  
Of course you can switch off numbering even for a "numbered" title, see <cmd>setuphead</cmd>.
+
==Titling Style==
 +
 
 +
see <cmd>setuphead</cmd> and some enhanced samples below.
 +
 
 +
A FAQ is how to get a line under the title:
 +
<texcode>
 +
\setupbackgrounds[header][text][bottomframe=on]
 +
</texcode>
 +
 
 +
==Your Own Titling Levels==
 +
 
 +
Of course you can define your own titling commands and probably must adapt the default settings.
 +
 
 +
<texcode>
 +
\definehead[myheader][section]
 +
 
 +
\setuphead[myheader]
 +
[numberstyle=bold,
 +
textstyle=cap,
 +
before=\hairline\blank,
 +
after=\nowhitespace\hairline]
 +
 
 +
\myheader[hasselt-ref]{Hasselt makes headlines}
 +
</texcode>
 +
 
 +
A new header <cmd>myheader</cmd> is defined and it inherits the properties of <cmd>section</cmd> (title, subject, whatever).
 +
You can "define" several headers at once!
 +
 
 +
==Table(s) of Contents==
 +
 
 +
Default:
 +
<texcode>
 +
\completecontent % with title
 +
\placecontent % without title
 +
</texcode>
 +
 
 +
Define your own "table of somewhat" with <cmd>definelist</cmd> and <cmd>setuplist</cmd>!
 +
You can "collect" several section levels in one list using <cmd>definecombinedlist</cmd>, that's even explained in "ConTeXt, an excursion" (see [[Official_ConTeXt_Documentation]]).
  
==Your own title styles==
+
To have some parts of your title texts ''not'' appear in the table of contents, use <cmd>nolist</cmd> and have a look at http://www.pragma-ade.com/general/magazines/mag-0001.pdf.
 +
 
 +
===Page Numbering in Tables of Contents===
 +
 
 +
If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example,
 +
 
 +
<texcode>
 +
\starttext
 +
\startfrontmatter
 +
\placecombinedlist[MyContentsList]
 +
\stopfrontmatter
 +
\startbodymatter
 +
\setuppagenumbering[way=bychapter, left=A, chapternumber=yes, numberseparator=/]
 +
...
 +
\stopbodymatter
 +
</texcode>
 +
 
 +
will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately.
 +
 
 +
To get a prefix to the page numbering (like "A"), use
 +
 
 +
<texcode>
 +
\def\ChapterPrefix#1{A#1}
 +
\setuplist[chapter][pagecommand=\ChapterPrefix]
 +
</texcode>
 +
 
 +
To get the numberseparator working, you need to know that the ToC will use the separator that is active ''at the time the ToC is output''. So you need to set it immediately before you call the ToC command, e.g.
 +
 
 +
<texcode>
 +
\setuppagenumbering[numberseparator=/]
 +
\placecombinedlist[MyContentsList]
 +
</texcode>
 +
 
 +
==Your Own Title Styles==
  
 
Sometimes the possibilities of <cmd>setuphead</cmd> aren't enough.
 
Sometimes the possibilities of <cmd>setuphead</cmd> aren't enough.
Line 33: Line 109:
  
 
<texcode>
 
<texcode>
\def\MyChapterCommand#1#2{\framed[frame=off, bottomframe=on, topframe=on]{\headtext{chapter} \vbox{#1\blank#2}}}
+
\def\MyChapterCommand#1#2{\framed[frame=off, bottomframe=on, topframe=on]{\vbox{\headtext{chapter} #1\blank#2}}}
 
% #1 is number, #2 is text
 
% #1 is number, #2 is text
 
% \vbox is needed for \blank to work
 
% \vbox is needed for \blank to work
 +
 
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]
 
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]
\setupheadtext[chapter=Chapter]
+
 
 +
\setupheadtext[chapter=Chapter] % used by \headtext
 
</texcode>
 
</texcode>
 
so <tt>\chapter{My First Chapter}</tt> looks like:
 
so <tt>\chapter{My First Chapter}</tt> looks like:
Line 48: Line 126:
 
</context>
 
</context>
  
Willi Egger posted the following two examples of a simple line under the chapter title, and a complex graphical element under the chapter title.
 
  
Here's the simple line:
+
===A complex graphical element under the chapter title===
<texcode>
 
\setupbackgrounds[header][text][bottomframe=on]
 
</texcode>
 
  
Here's the graphical element:
 
 
<texcode>
 
<texcode>
 
\setupcolors[state=start]
 
\setupcolors[state=start]
Line 101: Line 174:
  
 
It looks like:
 
It looks like:
 +
 
<context>
 
<context>
    \setupcolors[state=start]
+
  \setupcolors[state=start]
 
   \startuseMPgraphic{HeaderDeco}
 
   \startuseMPgraphic{HeaderDeco}
 
           numeric w, h, repeats;
 
           numeric w, h, repeats;
Line 144: Line 218:
 
\stoptext
 
\stoptext
 
</context>
 
</context>
 
==Your own titling levels==
 
 
Of course you can define your own titling commands and probably must adapt the default settings.
 
 
<texcode>
 
\definehead[myheader][section]
 
 
\setuphead[myheader]
 
[numberstyle=bold,
 
textstyle=cap,
 
before=\hairline\blank,
 
after=\nowhitespace\hairline]
 
 
\myheader[hasselt-ref]{Hasselt makes headlines}
 
</texcode>
 
 
A new header <tt>\myheader</tt> is defined and it inherits the properties of <tt>section</tt> (title, subject, whatever).
 
You can "define" several headers at once!
 
 
 
==Table(s) of Contents==
 
 
Default:
 
<texcode>
 
\completecontent % with title
 
\placecontent % without title
 
</texcode>
 
 
Define your own tables of somewhat with <cmd>definelist</cmd> and <cmd>setuplist</cmd>!
 
 
To have some parts of your title texts ''not'' appear in the table of contents, use <cmd>nolist</cmd> and have a look at http://www.pragma-ade.com/general/magazines/mag-0001.pdf.
 
 
==Page numbering in tables of contents==
 
 
If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example,
 
 
<texcode>
 
\starttext
 
\startfrontmatter
 
\placecombinedlist[MyContentsList]
 
\stopfrontmatter
 
\startbodymatter
 
\setuppagenumbering[way=bychapterleft=A,chapternumber=yes,numberseparator=/]
 
...
 
\stopbodymatter
 
</texcode>
 
 
will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately.
 
 
To get a prefix to the page numbering (like "A"), use
 
 
<texcode>
 
\def\ChapterPrefix#1{A#1}
 
\setuplist[chapter][pagecommand=\ChapterPrefix]
 
</texcode>
 
 
To get the numberseparator working, you need to know that the ToC will use the separator that is active ''at the time the ToC is output''. So you need to set it immediately before you call the ToC command, e.g.
 
 
<texcode>
 
\setuppagenumbering[numberseparator=/]
 
\placecombinedlist[MyContentsList]
 
</texcode>
 

Revision as of 12:11, 29 December 2005

< Structurals | Visuals >

Default

Titles define the structure of your document. Decide yourself, how deep you want to nest them:

numberedunnumbered
\part&#151;
\chapter\title
\section\subject
\subsection\subsubject
\subsubsection\subsubsubject
......

The "unnumbered" versions don't appear in a table of contents! But you can switch off the numbering of the "numbered" versions with \setuphead to get unnumbered titles and a toc (confusing?).

Referencing Titles

Every heading command can take an optional parameter as reference:

\title[hasselt-by-night]{Hasselt by night}

The bracket pair is optional and used for internal References. If you want to refer to this header you type for example

\at{page}[hasselt-by-night].

(see \at)

Titling Style

see \setuphead and some enhanced samples below.

A FAQ is how to get a line under the title:

\setupbackgrounds[header][text][bottomframe=on]

Your Own Titling Levels

Of course you can define your own titling commands and probably must adapt the default settings.

\definehead[myheader][section]

\setuphead[myheader]
[numberstyle=bold,
textstyle=cap,
before=\hairline\blank,
after=\nowhitespace\hairline]

\myheader[hasselt-ref]{Hasselt makes headlines}

A new header \myheader is defined and it inherits the properties of \section (title, subject, whatever). You can "define" several headers at once!

Table(s) of Contents

Default:

\completecontent % with title
\placecontent % without title

Define your own "table of somewhat" with \definelist and \setuplist! You can "collect" several section levels in one list using \definecombinedlist, that's even explained in "ConTeXt, an excursion" (see Official_ConTeXt_Documentation).

To have some parts of your title texts not appear in the table of contents, use \nolist and have a look at http://www.pragma-ade.com/general/magazines/mag-0001.pdf.

Page Numbering in Tables of Contents

If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example,

\starttext
\startfrontmatter
\placecombinedlist[MyContentsList]
\stopfrontmatter
\startbodymatter
\setuppagenumbering[way=bychapter, left=A, chapternumber=yes, numberseparator=/]
...
\stopbodymatter

will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately.

To get a prefix to the page numbering (like "A"), use

\def\ChapterPrefix#1{A#1}
\setuplist[chapter][pagecommand=\ChapterPrefix]

To get the numberseparator working, you need to know that the ToC will use the separator that is active at the time the ToC is output. So you need to set it immediately before you call the ToC command, e.g.

\setuppagenumbering[numberseparator=/]
\placecombinedlist[MyContentsList]

Your Own Title Styles

Sometimes the possibilities of \setuphead aren't enough. Just define your own styling command like this:

\def\MyChapterCommand#1#2{\framed[frame=off, bottomframe=on, topframe=on]{\vbox{\headtext{chapter} #1\blank#2}}}
% #1 is number, #2 is text
% \vbox is needed for \blank to work

\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]

\setupheadtext[chapter=Chapter] % used by \headtext

so \chapter{My First Chapter} looks like:


A complex graphical element under the chapter title

\setupcolors[state=start]
\startuseMPgraphic{HeaderDeco}
    numeric w, h, repeats;
    path p[];
    w := OverlayWidth ; h := OverlayHeight ;
    repeats := abs(TextWidth/BodyFontSize);
    p[1] := unitsquare xscaled w yscaled h ;
    draw p[1] withcolor white;
    p[2] := fullcircle scaled BodyFontSize;
    p[3] := fullcircle scaled .25BodyFontSize;
    draw p[2] shifted (.5BodyFontSize,0);
    for i = 1 upto repeats:
        if odd i :
            filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);
        else :
            draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);
        fi;
    endfor;
\stopuseMPgraphic

\setuphead[chapter][command=\Myheader]
\setupheadtext
      [chapter=Chapitre]
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]

\def\Myheader#1#2{%
    \framedtext
        [width= \overlaywidth,
        height=6\bodyfontsize,
        background={foreground,HeaderDeco},
        offset=0pt,
        strut=no,
        frame=off,
        align=middle]{%
            \headtext{chapter} #1
            \blank[small]
            #2}}

\starttext
   \chapter{Here we go!}
\stoptext

It looks like: