Changes

Jump to navigation Jump to search
5,732 bytes removed ,  18:00, 8 July 2012
Make all examples narrower, turn tables into wikitables, kill some <cmd> tags, and improve a few sentences.
Titles define the structure of your document. Decide yourself, how deep you want to nest them:
<table> <tr bgcolor{| class="#CCCCCC"> <th>numbered</th>wikitable <th>unnumbered</th>! Numbered !! Unnumbered </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>|section</}} || {{cmd></td> <td><cmd>|subject</cmd></td>}} </tr>|- <tr> <td><| {{cmd>|subsection</cmd></td> <td><}} || {{cmd>|subsubject</cmd></td> </tr>}} <tr>|- <td><| {{cmd>|subsubsection</cmd></td> <td><}} || {{cmd>|subsubsubject</cmd></td> </tr>}} <tr>|- <td>| ...</td> <td>|| ...</td> </tr></table>|}
The ''unnumbered'' versions don't appear in a table of contents! But you canswitch off To change that, see the numbering section on[[#Unnumbered_titles_in_table_of_contents|Unnumbered titles in the table of the ''numbered'' versions with <cmd>setuphead</cmd>to get unnumbered titles ''and'' a toc (confusing?)contents]].
Also note that in the front matter of the document, all titles are unnumberedby default. In this case, The titles from the only difference between the "'numbered" and"unnumbered" titles is that the latter don't category still show up in the table of contents, though, and the titles from the 'unnumbered' category still don't.
===Referencing Titles===
\at{page}[hasselt-by-night].
(see <{{cmd>|at</cmd>}})
</texcode>
==Titling Style==
see <{{cmd>|setuphead</cmd> }} and some enhanced samples below.
A FAQ is, how to get a line under the pageheader:
<texcode>
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}] % "flushleft" is the same as "right"
</texcode>
If you want you may have colors on your document's chapters or sections.
To do that you should use <{{cmd>|setuphead</cmd>}}. Take a look at the following
example:
</texcode>
A new header <{{cmd>|myheader</cmd> }} is defined and it inherits the propertiesof <{{cmd>|section</cmd> }} (title, subject, whatever). You can ''define'' several
headers at once!
==Formatting Titles with <{{cmd>|setuphead</cmd>}}==
<The following parameters to {{cmd>|setuphead</cmd> accepts a number of parameters which }} change the style ofthe heading. At least the following commands are available:
<table> <tr bgcolor{| class="#CCCCCC"> <th>text</th>wikitable <th>number</th>|- </tr>! Text !! Number <tr>|- <td><tt>| textstyle</tt></td> <td><tt>| numberstyle</tt></td> </tr> <tr>|- <td><tt>| textcommand</tt></td> <td><tt>| numbercommand</tt></td> </tr> <tr>|- <td><tt>| deeptextcommand</tt></td> <td><tt>| deepnumbercommand</tt></td> </tr>|-</table>|}
Quite obviously, the number-commands work on the chapter/section/etc. number,
their text counterparts change the text itself. However, there are differences
between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.)
or a font switch (<{{cmd>|em</cmd>}}, <{{cmd>|tfx</cmd>}}, etc). <tt>textstyle</tt> prepends
the text with the associated style. <tt>textcommand</tt> is a command name which
is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is
similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).
So, if we have <{{cmd>|title|2={A story}</cmd>}}, the different parameters have the following results:
<table>{| <tr>|- <td><tt>| textstyle=\em</tt></td> <td><tt>| =></tt></td> <td><tt>| \em A story</tt></td> </tr> <tr>|- <td><tt>| textstyle=\em, textcommand=\uppercase</tt></td> <td><tt>| =></tt></td> <td><tt>| \uppercase{\em A story}</tt></td> <td><tt>| =></tt></td> <td><tt>| \em A STORY</tt></td> </tr> <tr>|- <td><tt>| textstyle=\em, deeptextcommand=\uppercase</tt></td> <td><tt>| =></tt></td> <td><tt>| \em\uppercase{A story}</tt></td> <td><tt>| =></tt> </td><td><tt>| \em A STORY</tt></td> </tr>|-</table>|}
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>,
it wreaks havoc with markup:
<table>{| <tr>|- <td><tt>| textstyle=\em, textcommand=\WORD</tt></td> <td><tt>| =></tt></td> <td><tt>| \WORD{\em A story}</tt></td> <td><tt>| =></tt></td> <td><tt>| \EM A STORY</tt></td> </tr>|- <tr> <td><tt>| textstyle=\em, deeptextcommand=\WORD</tt></td> <td><tt>| =></tt></td> <td><tt>| \em\WORD{A story}</tt></td> <td><tt>| =></tt></td> <td><tt>| \em A STORY</tt></td> </tr>|-</table>|}
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing
headers. (Using <{{cmd>|uppercase</cmd> }} works in this specific case, but only if you stick
to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented
characters, like CAFé.)
Use <{{cmd>|setuphead</cmd>}}<tt>[part][conversion=Romannumerals]</tt>, for example, to employ an
alternative numbering scheme.
=== Truly empty pagebreak before chapters ===
Using <{{cmd>|setuppagenumbering|2=[alternative=doublesided]</cmd> }} makes the chapters start
on the right page. However, the blank page is not truely empty, it contains headers and
footers. To get truely empty pages, use the following
* 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.
* You set options for the header of type chapter and use for the option page the afore defined new pagebreak.
* You might want to experiment with the commented lines and see what happens. For example, the <{{cmd>|setupsectionblock</cmd> }} commands will give a truly blank page (if needed) after the specified <cmd>{{code|1=stop*part</cmd> }} command.
==== When using front, body, back matters and appendices ====
As Wolfgang explained on the mailing list, when using <cmd>{{code|1=*frontmatter</cmd>}}, <cmd>{{code|1=*bodymatter</cmd>}}, <cmd>{{code|1=*backmatter</cmd> }} and <cmd>{{code|1=*appendices</cmd>}}, you need to remove the page they create to get the page before a new chapter or part with no headers and footers.
<texcode>
Sometimes one wants an unnumbered chapter, say introduction, the following might do that trick:
<texcodecontext source=yes>\definehead [intro] [chapter]\setuphead [intro] [number=no]\definecombinedlist [content][intro,chapter,section]\setuplist setuppapersize[introA5] [headnumber=no] \starttext\completecontent\startfrontmatter\intro{No number}\stopfrontmatter
\startbodymatter
\chapter{Has number}
\stopbodymatter
\stoptext
</texcode>
 
<context>
\definehead [intro] [chapter]
\setuphead [intro] [number=no]
Note that just putting the introduction in the frontmatter already did the trick for me (on a recent MkIV).
 
An alternative approach:
<texcode>
\setuphead[title][
incrementnumber=yes, % keep an internal title counter+list
number=no] % don't display the counter
 
% Manually specify the composition of the section and subsection
% numbers, so subsection 1.1 in the second title won't appear as
% Subsection 2.1.1
\setuphead[section][sectionsegments=section]
\setuphead[subsection][sectionsegments=section:subsection]
 
% Redefine the toc list to include titles
\definecombinedlist[content][title, section]
</texcode>
==Your Own Title Styles==
Sometimes the possibilities of <{{cmd>|setuphead</cmd> }} aren't enough. You can define
your own styling commands, as shown in the following examples.
This very simple example shows how to start a title within the margin, rather than at the text's edge
<texcodecontext source=yes>\setupheadsetuppapersize[chapterA5][alternative=margin]</texcode> This looks like <context>
\setuphead[chapter][alternative=margin]
===Chapter titles in new line===
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</cmd>. <texcode>\setuplabeltext [en] [chapter=Chapter~]% Does not work, not wrapped in \framed% \def\MyChapter#1#2{#1\blank#2}\define[2]\MyChapter {\cmd|framed[frame=off,width=broad,align=flushleft]{#1\\#2}}\setuphead [chapter] [command=\MyChapter]\startchapter [title=Foo Bar]\stopchapter</texcode> This looks like.
<contextsource=yes>\setuppapersize[A5]
\setuplabeltext [en] [chapter=Chapter~]
\define[2]\MyChapter
This example illustrates expanded chapter titles.
<texcodecontext source=yes>\def\MyChapterCommand#1#2% #1 is number, #2 is text {\framed[frame=off,bottomframe=on,topframe=on] {\vbox{\headtext{chapter} #1\blank#2}}} % \vbox is needed for \blank to work \setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}] \setupheadtextsetuppapersize[chapter=ChapterA5] % used by \headtext</texcode> so <tt>\chapter{My First Chapter}</tt> looks like: <context>
\def\MyChapterCommand#1#2%
{\framed[frame=off,bottomframe=on,topframe=on]
===A complex graphical element under the chapter title===
<texcodecontext source=yes> \setupcolorssetuppapersize[state=startA6]\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</texcode> It looks like: <context>
\setupcolors[state=start]
\startuseMPgraphic{HeaderDeco}
This is achieved by the following setup:
<texcodecontext source=yes>\setuphead setuppapersize[subjectA5] [alternative=text,distance=0pt,command=\MyHead] \def\MyHead#1#2{\inmargin{#1 #2}}</texcode> This (with 'style=\sc' added in setuphead) gives: <context>
\setuphead
[subject]
\subject{First Subject}
This is the text in the first subject. This is the text in the first subject.This is the text in the first subject. This is the text in the first subject.This is the text in the first subject. This is the text in the first subject.This is the text in the first subject. This is the text in the first subject.\input weisman
\subject{Second Subject}
This is the text in the second subject. This is the text in the second subject.This is the text in the second subject. This is the text in the second subject. This is the text in the second subject. This is the text in the second subject. This is the text in the second subject. This is the text in the second subject. \input ward
\stoptext
</context>
See the mailing list thread [[http://www.ntg.nl/pipermail/ntg-context/2003/002053.html]the mailing list thread] for more on this.
===Headings numbered independent of chapters or other headings===
===Chapter headers===
Setup This is an example of headers like chapters. While reading Pixar docs about Rendermanchapter headings with an enlarged shadow behind them, I've found their headers nice and wanted to copy this style.I found a premise in Metafun manual, p.187 (Hello text), and Hans email me (based on [http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 ]) on the context list a more simple solution than using metapost. The minimum is to put it here, for others who are like me, wandering for source code.Feel free to adapt code below to your langage specific settings, mine is french. <texcode>\useencoding[ffr]\mainlanguage[fr]\enableregime[utf] %for UTF8 % \enableregime[il1by Hans] %for ISO 8859-1 8859-15 \usetypescript[palatino][texnansi]\setupbodyfont[palatino,rm,12pt] \setupcolors[state=start] \definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted \definecolor[BigColorOne][r=.86,g=.850,b=.54]\definecolor[BigColorTwo][r=.43,g=.425,b=.27] \setuphead [chapter] [deeptextcommand=\MyChapterText, color=BigColorTwo, style=\BigFontTwo] \def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}
<context source=yes>\starttextsetuppapersize[A5]
\chapter[chap:ques]{Question}
\chapter[chap:answ]{Answer}
\chapter[chap:answ]{Remarque}
\chapter[chap:answ]{Cours}
\chapter[chap:answ]{Exercice}
\chapter[chap:answ]{Travail dirigé}
\chapter[chap:answ]{Exposé}
\stoptext
</texcode>
 
I've tryed to change a bit Hans code, by putting \kern15pt, for moving backgroundtext to the left of \rlap alignment, and an unsuccess one to switch same backgroundtext in Sans font (no french accents).
 
olivier
 
<context>
\useencoding[ffr]
\mainlanguage[fr]
 
% fonts currently don't work this way,
% I'll fix that soon. Patrick
 
% \usetypescript[palatino][texnansi]
% \setupbodyfont[palatino,rm,12pt]
\setupcolors[state=start]
\chapter[chap:ques]{Question}
% only one page please, since this is displayed inline. Patrick
% \chapter[chap:answ]{Answer}
% \chapter[chap:answ]{Remarque}
% \chapter[chap:answ]{Cours}
% \chapter[chap:answ]{Exercice}
% \chapter[chap:answ]{Travail dirigé}
% \chapter[chap:answ]{Exposé}
\stoptext
</context>
<context source="yes">
\setuppapersize[A5]
\setupexternalfigures[location=default] % needed only for the wiki to the find the figure
\useexternalfigure[chaptersection-1][cow.pdf][width=5cm,height=1cm]\useexternalfigure[chaptersection-2][hackermill.jpgpng][width=5cm,height=1cm]
\setuphead
[chaptersection] [command=\MyChapterCommandMySectionCommand]\setuphead [subsection] [command=]
\def\MyChapterCommandMySectionCommand#1#2% {\externalfigure[chaptersection-\currentheadnumber][height=5cm]}
\starttext
\chaptersection{One}\sectionsubsection{First section subsection of Chapter Section One}\chaptersection{Two}
\stoptext
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html]
Users of MkIV can safely rely on <tt>command</tt> and don't have tobother with the <tt>deep...command</tt> variants. However,<tt>\{{cmd|currentheadnumber</tt> }} does not seem to return anything but 0.Thus, the following code is required to define<tt>\MyChapterCommand</tt> when using MkIV:
<texcode>
===Chapter head with absolute positioning of following text===
 
<texcode>
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]
\starttext
\chapter{test} \input tufte
\stoptext
</texcode>
No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:
<context>\setuppapersize[A6][A6]\setuphead[chapter][beforesource=\vbox to 4cm\bgroup,after=\vss\egroup]\setupbodyfont[8pt]\starttext\chapter{test} \input tufte\stoptext</context> ====Bug and proposed workaround==== I tried this sample and <cmd>getmarking[chapter]</cmd>, used in my headers,stopped to work properly. Proposed workaround below.--[[User:Sebastian.rooks|SeR]] 00:52, 27 January 2006 (CET) <texcode>\def\MyChapterCommand#1#2% {\vbox to 4cm\bgroup {#1\hskip.75em #2} \vss \egroup} \setuphead[chapter][header=nomarking,command=\MyChapterCommand]\starttext\chapter{test} \input tufte\stoptext</texcode> <contextyes>
\setuppapersize[A6][A6]
\setupbodyfont[8pt]
\vss
\egroup}
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]
\starttext
\chapter{test} \input tufte
Hans came up with this cleverness, showing two alternate ways of doing it:
<context source="yes" text="produces">\setuppapersize[A5] % ---- First solution ---- 
\def\FirstSolution#1#2%
{\vbox\bgroup
\blackrule[width=\scratchdimen,height=1pt]
\egroup}
 
% ---- Second solution ----
\doglobal\newcounter\NextLinePos
\def\DoSecondSolution#1%
{\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}}
 
% ---- Trying it out solution ----
% \showstruts
\starttext
\setuphead[section][command=\FirstSolution]
 \starttext  \section{is this nice or not}  \section{is this nice or not nice, that's the question}
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]
  \section{is this nice or not}  \section{is this nice or not nice, that's the question} 
\stoptext
</context>
As if that wasn't enough, Taco pointed out that <{{cmd>|lastlinewidth</cmd>}}
is the easy route to finding the width of the last line. Use something like:
<codetexcode>
\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro
\global\advance\lastlinewidth-\hangindent\par % adjust
\blackrule[width=\lastlinewidth,height=1pt]
</codetexcode>
=== Flushing section head data without typesetting them in the text ===
The following is probably a very special case. Hoever suppose you need to place section information like the title e.g. in the topspace area. You want that the section is still displayed in the TOC, but you do not want that at the spot where <{{cmd>|startsection|2=[title=...,list=...]</cmd> }} resides there is any trace of it. The command to be used to hide the section title is:
<texcode>
</texcode>
What happens is that the information in the <{{cmd>|startsection|2=[title=...,list=...]</cmd> }} command is passed to the texttexts, which are flushed at every page. In order to see when it is flushed you might place e.g. !!! in front of the <{{cmd>|placerawheaddata|2=[section]</cmd>}}.
The result is a complete TOC without any trace of the section heading in the text.
\stoptext
 
</texcode>
[[Category:Graphics]]
[[Category:Text elements]]
table>
/td>

Navigation menu