https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Mbork&feedformat=atomWiki - User contributions [en]2024-03-29T06:15:21ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Registers&diff=21810Registers2013-06-02T18:06:50Z<p>Mbork: Added a trick with "indicators"</p>
<hr />
<div>< [[Structurals]] | [[References]] > (It's also in the manual at "Registers")<br />
<br />
=Basics=<br />
<br />
Putting a word into the index as simple as <cmd>index</cmd><tt>{word}</tt>. (Always type <cmd>index</cmd> ''before'' the word you refer to!)<br />
<br />
To sort e.g. <cmd>ConTeXt</cmd> under "C", you write <cmd>index</cmd><tt>[CONTEXT]{\ConTeXt}</tt>.<br />
<br />
If you need multiple levels (up to three), use "+" or "&" separators like in <cmd>index</cmd><tt>{beans+baked}</tt>.<br />
<br />
'''Note: In MkIV (Sept.2010) "&" gives an error "Misplaced alignment tab character &" '''<br />
<br />
'''So, just use "+" '''<br />
<br />
You get a cross reference in your index with <cmd>seeindex</cmd> like in <cmd>seeindex</cmd><tt>[CONTEXT]{\ConTeXt}{\TeX}</tt> (ConTeXt: see TeX).<br />
<br />
To typeset the index, use <cmd>placeindex</cmd> (without title) or <cmd>completeindex</cmd> (with titling).<br />
<br />
==Example==<br />
<texcode><br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats.<br />
There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</texcode><br />
<context><br />
\tfx<br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats. There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</context><br />
<br />
=Styling the Index=<br />
<br />
Registers consist of three text elements that can be styled<br />
independently:<br />
the sections headings, the entry text, and a page number (reference).<br />
For formatting purposes each has its own key so it can be referred to<br />
consistently:<br />
<br />
* <tt>style</tt> refers to the style of ''headings''; ordinarily these are the letters of the alphabet.<br />
* <tt>textstyle</tt> refers to the typeset content of an entry;<br />
* <tt>pagestyle</tt> refers to the typeset page number of an entry;<br />
* page numbers are references so their appearance depends on the [[Interaction|interaction]] settings as well.<br />
<br />
== MkIV ==<br />
<br />
=== General Setup ===<br />
The appearance of a register can be configured with {{cmd|setupregister}}.<br />
An example setup for the register ''entity'' could look like:<br />
<br />
<texcode><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=sansbold, %% headings<br />
textstyle=slanted, %% entries<br />
pagestyle=bolditalic, %% page refs<br />
n=1, %% columns<br />
]<br />
</texcode><br />
<br />
This typesets sections in bold face sans serif, entries with slant, and<br />
page references in italic.<br />
Also, the register will use a single column.<br />
<br />
In MkIV {{cmd|setupregister}} is consistent with the common interface<br />
to [[Style_Alternatives|text style]].<br />
Thus for every <tt>style</tt> there is a corresponding <tt>color</tt><br />
option (''color'', ''textcolor'', and ''pagecolor''):<br />
<br />
<texcode><br />
\setupregister [entity] [<br />
color=red,<br />
textcolor=green,<br />
pagecolor=blue,<br />
]<br />
</texcode><br />
<br />
Naturally, self-defined alternatives are valid as well:<br />
<br />
<texcode><br />
\definefontfeature [textfigures] [onum=yes]<br />
<br />
\definealternativestyle [reg:bigbold] [\bfc] []<br />
\definealternativestyle [reg:tinybold] [\bfxx] []<br />
\definealternativestyle [reg:bignum] [\tfc\addff{textfigures}] []<br />
<br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=reg:bigbold,<br />
textstyle=reg:tinybold,<br />
pagestyle=reg:bignum,<br />
]<br />
</texcode><br />
<br />
Use with care!<br />
<br />
=== Processors ===<br />
<br />
The [[Registers#Individiual_Entries|traditional approach]] to<br />
fine-tuning entries has not (yet?) been implemented in MkIV<br />
[http://www.ntg.nl/pipermail/ntg-context/2013/070961.html].<br />
Instead, there is a new mechanism called ''processors'' available that<br />
has a similar effect<br />
[http://www.ntg.nl/pipermail/ntg-context/2010/049493.html].<br />
<br />
Processors are created via {{cmd|defineprocessor}}:<br />
<br />
<texcode><br />
\defineprocessor [relevant] [style=italic]<br />
</texcode><br />
<br />
To apply it to a register entry, we employ the <tt>-&gt;</tt> operator:<br />
<texcode><br />
Text \entity{foo}text.<br />
Text \entity{relevant->bar}text.<br />
Text \entity{baz}text.<br />
</texcode><br />
<br />
This will render ''bar''’s entry in the register ''entity'' in italic<br />
font, while the other two entries remain unchanged.<br />
<br />
<context mode=mkiv source=no><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=sansbold,<br />
textstyle=normal,<br />
pagestyle=bolditalic,<br />
n=1,<br />
]<br />
<br />
\defineprocessor [relevant] [style=italic]<br />
<br />
\starttext<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo}text.<br />
Text \entity{relevant->bar}text.<br />
Text \entity{baz}text.<br />
Text after.<br />
\stoptext<br />
</context><br />
<br />
A processor is not local to a specific register (as it was in MkII).<br />
Once defined it can be applied to different registers, yielding the<br />
same effect:<br />
<br />
<texcode><br />
\defineregister [first]<br />
\defineregister [second]<br />
\defineregister [third]<br />
\defineprocessor [relevant] [style=italic,color=blue]<br />
\starttext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br />
\placefirst \placesecond \placethird \page<br />
Text before.<br />
Text \first {foo} \first {relevant->bar 1} \first {baz}text.<br />
Text \second{foo} \second{relevant->bar 2} \second{baz}text.<br />
Text \third {foo} \third {relevant->bar 3} \third {baz}text.<br />
Text after.<br />
\stoptext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br />
</texcode><br />
<br />
The same processor can be applied to to both entries and page numbers.<br />
(Another difference from MkII.)<br />
For page numbers, apply the <tt>-&gt;</tt> operator on the optional<br />
first argument:<br />
<br />
<texcode><br />
\entity[relevant->]{foo}<br />
</texcode><br />
<br />
Note that <code>\entity[weird]{foo}</code> is not enough.<br />
Without the <tt>-&gt;</tt>, the first argument is interpreted as sort<br />
key.<br />
However, if in addition to the page number processor you wish to supply<br />
a custom sort key, then the sort key must follow the processor:<br />
<br />
<texcode><br />
\entity[relevant->baz]{foo}<br />
</texcode><br />
<br />
In this example, the page number will be displayed using the processor<br />
''relevant'' and the entity ''foo'' will be treated like the string<br />
''baz'' for sorting purposes.<br />
Of course, page number and text formatting can be combined:<br />
<br />
<texcode><br />
\entity[relevant->]{relevant->foo}<br />
</texcode><br />
<br />
Processors work well with multi-level indices:<br />
<br />
<texcode><br />
\entity {relevant->foo}<br />
\entity {relevant->foo+bar}<br />
\entity {relevant->foo+bar+baz}<br />
</texcode><br />
<br />
''Applying multiple processors to a single entry has no effect.''<br />
Context will ignore any other processor after the first.<br />
(This is probably a feature, as there is no need to repeat the<br />
processor with every entry.)<br />
However, different entries in the page reference list can be formatted<br />
differently:<br />
<br />
<context mode=mkiv source=yes><br />
\setupcolor[rgb]<br />
\defineregister [stuff] [style=sansbold,pagestyle=italic,n=1]<br />
\defineprocessor [relevant] [style=bold,color=red]<br />
\defineprocessor [irrelevant] [color=darkgray]<br />
<br />
\starttext<br />
\placestuff<br />
<br />
\page Text \stuff {relevant->foo} text.<br />
\page Text \stuff {foo} text.<br />
\page Text \stuff [relevant->] {foo} text.<br />
\page Text \stuff {irrelevant->foo} text. %% no effect!<br />
\page Text \stuff [irrelevant->] {foo} text.<br />
\stoptext<br />
</context><br />
<br />
=== Examples ===<br />
==== Simple Setup ====<br />
<br />
<context mode=mkiv source=yes><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=sansbold,<br />
textstyle=slanted,<br />
pagestyle=bolditalic,<br />
n=1,<br />
]<br />
<br />
\starttext<br />
<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{baz} text.\page<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{xyzzy} text.\page<br />
Text after.<br />
<br />
\stoptext<br />
</context><br />
<br />
==== Colorful Setup ====<br />
<br />
<context mode=mkiv source=yes><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
color=red,<br />
textcolor=green,<br />
pagecolor=blue,<br />
n=1,<br />
]<br />
<br />
\starttext<br />
<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{baz} text.\page<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{xyzzy} text.\page<br />
Text after.<br />
<br />
\stoptext<br />
</context><br />
<br />
==== Setup with Alternatives ====<br />
<br />
<context mode=mkiv source=yes><br />
\definefontfeature [textfigures] [onum=yes]<br />
<br />
\definealternativestyle [reg:bigbold] [\bfc] []<br />
\definealternativestyle [reg:tinybold] [\bfxx] []<br />
\definealternativestyle [reg:bignum] [\tfc\addff{textfigures}] []<br />
<br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=reg:bigbold,<br />
textstyle=reg:tinybold,<br />
pagestyle=reg:bignum,<br />
]<br />
<br />
\starttext<br />
<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{baz} text.\page<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{xyzzy} text.\page<br />
Text after.<br />
<br />
\stoptext<br />
</context><br />
<br />
==== Complex Setup ====<br />
<br />
<texcode><br />
\definefontfeature [textfigures] [onum=yes]<br />
<br />
\definealternativestyle [reg:heada] [\WORD\ssa\bold]<br />
\definealternativestyle [reg:headb] [\word\tfb\sc]<br />
\definealternativestyle [reg:pageno] [\addff{textfigures}\italic]<br />
<br />
\defineregister [entity] [style=reg:heada,pagestyle=normal,n=3]<br />
\defineregister [object] [style=reg:headb,pagestyle=reg:pageno,n=2]<br />
<br />
\defineprocessor [relevant] [style=italic]<br />
\defineprocessor [weird] [style=italic,color=red]<br />
\defineprocessor [striking] [style=bold,color=blue]<br />
<br />
\starttext<br />
<br />
\placeentity \blank[3*big] \placeobject \page<br />
<br />
\dorecurse{3}{<br />
Text before.<br />
\page Text \entity {foo} text.<br />
Text \object {striking->bar} text.<br />
Text \entity {baz+foo} text.<br />
Text \object {foo+bar} text.<br />
\page Text \entity[relevant->] {weird->foo} text.<br />
\page Text \entity {weird->bar} text.<br />
Text \object[weird->] {foo} text.<br />
Text \object {baz} text.<br />
\page Text \entity[weird->foo] {foo} text.<br />
\page Text \entity[weird->] {baz} text.<br />
Text \object {baz} text.<br />
Text \object {bar+baz} text.<br />
Text \entity[weird->] {baz} text.<br />
Text \entity {baz+miranda} text.<br />
Text \entity {baz+xyzzy} text.<br />
Text \object {foo} text.<br />
\page Text \entity {weird->foo} text.<br />
Text \object[striking->] {bar+baz} text.<br />
Text \object {foo} text.<br />
Text \entity[relevant->] {baz+xyzzy} text.<br />
\page Text \entity[weird->foo] {foo} text.<br />
Text \object {bar+xyzzy} text.<br />
Text \object {baz} text.<br />
Text \object {foo} text.<br />
Text \entity[weird->] {baz+xyzzy+meh} text.<br />
\page Text \entity[weird->] {weird->foo} text.<br />
Text \object[striking->] {foo} text.<br />
Text \object {xyzzy} text.<br />
Text \entity {baz+xyzzy} text.<br />
Text after.<br />
}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== MkII ==<br />
<br />
=== General Setup ===<br />
The interface for register styling is {{cmd|setupregister}}.<br />
For settings that apply to the register as a whole use the two-argument<br />
version:<br />
<br />
<texcode><br />
\defineregister[thing][stuff]<br />
\setupregister[thing][<br />
style=boldslanted, %% headings<br />
textstyle=bold, %% items<br />
pagestyle=slanted, %% page numbers<br />
]<br />
</texcode><br />
<br />
Here we first initialize a register ''thing''.<br />
Then we assign a different<br />
[[Style_Alternatives|style]]<br />
to each of the three elements:<br />
the option ''style'' refers to index section headings (letters), which<br />
will be typeset in bold slanted;<br />
''textstyle'' means the item (indexed string, here bold);<br />
finally, ''pagestyle'' sets the page number references (slanted).<br />
<br />
=== Individiual Entries ===<br />
Better granularity regarding the formatting of individual entries can<br />
be achieved through the ''three-argument'' version of<br />
{{cmd|setupregister}}.<br />
Its second argument is an identifier by means of which a sub-style can<br />
be applied later.<br />
<br />
<texcode><br />
\setupregister[thing][important] [textstyle=bold, pagestyle=boldslanted]<br />
\setupregister[thing][nonsense] [textstyle=\tfxx, pagestyle=\tfd]<br />
</texcode><br />
<br />
This creates the substyles ''important'' and ''nonsense'' for the<br />
register ''thing''.<br />
To apply a sub-style, it has to be specified when an entry is added to<br />
the register.<br />
If we wanted to highlight an entry as important, we would call the<br />
macro {{cmd|thing|link=no}} as follows:<br />
<br />
<texcode><br />
text before \thing{important::entry} text after<br />
</texcode><br />
<br />
Note the double colon (<tt>::</tt>) that serves as delimiter between<br />
style directive (left hand side) and entry text (right).<br />
To highlight the page number instead:<br />
<br />
<texcode><br />
text before \thing[important::]{entry} text after<br />
</texcode><br />
<br />
Note that the '''<tt>::</tt> is non-optional'''!<br />
If the double colon is omitted, ''important'' would instead refer to<br />
the string used for register sorting.<br />
Of course, both elements can be styled at once:<br />
<br />
<texcode><br />
text before \thing[important::]{nonsense::entry} text after<br />
</texcode><br />
<br />
This produces an entry whose text is highlighted according to the<br />
definition of ''nonsense'' with a pagenumber styled as ''important''.<br />
<br />
The syntax for an MkII-style register entry has the schematic:<br />
<br />
<pre><br />
\<registercmd> [<pagestyle>::<sortkey>] {<textstyle>::<category>+<entry>}<br />
</pre><br />
<br />
where only <code><entry></code> is mandatory.<br />
<br />
=== Example ===<br />
<br />
A complete working example demonstrating the highlighting capabilities:<br />
<br />
<texcode><br />
\defineregister[thing][things]<br />
%%% 2-arg<br />
\setupregister[thing][<br />
style=boldslanted,<br />
textstyle=normal,<br />
pagestyle=slanted,<br />
]<br />
<br />
%%% 3-arg<br />
\setupregister[thing][important] [textstyle=bold, pagestyle=boldslanted]<br />
\setupregister[thing][nonsense] [textstyle=\tfxx, pagestyle=\tfd]<br />
<br />
<br />
\starttext<br />
Ordinary entries: \thing{one}\thing{two}<br />
<br />
Just a \thing {important::three}test. %% text -> “important”<br />
Yet another \thing {nonsense::four}test. %% text -> “nonsense”<br />
Again, nothing but a \thing [important::] {five}test. %% page -> “important”<br />
Old story: this is a \thing [important::] {important::five}test. %% both -> “important”<br />
Get it? A \thing [important::] {important::six}test. %% both -> “important”<br />
Plain and simple: \thing [nonsense::] {nonsense::seven}test. %% both -> “nonsense”<br />
<br />
\placething<br />
\stoptext<br />
</texcode><br />
category>+<br />
/context><br />
<br />
==== Colorful Setup ====<br />
<br />
=More Registers=<br />
<br />
<cmd>index</cmd> is only one special case of <cmd>register</cmd>. You can define as much different registers as you like:<br />
<br />
<cmd>defineregister</cmd><tt>[singular name][plural name]</tt>, e.g. <br />
<texcode><br />
\defineregister[mouse][mice]<br />
\setupregister[mouse][style=\ss]<br />
<br />
\mouse{rat}<br />
<br />
\placemouse<br />
</texcode><br />
<br />
(Don't know if the plural form is used anywhere...)<br />
<br />
=Tricks=<br />
<br />
* <cmd>startregister</cmd><tt>[index][mymouse]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse]</tt>: to mark several pages for the same entry; becomes e.g. "mouse 12--16". Note that if you have two or more of these ranges, you need them to have different <tt>[key]</tt> values to stop the system treating them as part of a great big range. So, use <cmd>startregister</cmd><tt>[index][mymouse1]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse1]</tt> and then <cmd>startregister</cmd><tt>[index][mymouse2]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse2]</tt> to get two independent ranges in the list. <cmd>startregister</cmd> takes four arguments, of which two are mandatory: <cmd>startregister</cmd><tt>[NAME_OF_REGISTER]{ENTRY_NAME}</tt>. The other arguments are <tt>[KEY_FOR_RANGE]</tt> and <tt>[KEY_FOR_SORTING]</tt>. To give an example: <cmd>startregister</cmd><tt>[index][levi][Levi-Strauss]{Lévi|-|Strauss}</tt>. This will start a range with the key <tt>levi</tt> which will put the entry "Lévi-Strauss" in the register "index" (the "normal" register) and sort it under "Levi-Strauss." To mark the end of the range, you write <cmd>stopregister</cmd><tt>[index][levi]</tt>.<br />
* Automatically collapse page ranges: <cmd>placeindex[compress=yes]</cmd><br />
* <cmd>writetoregister</cmd> (sometimes needed to avoid macro expansion issues)<br />
* A register per chapter: <cmd>placeregister</cmd><tt>[index][criterium=chapter]</tt><br />
* Place a word in text ''and'' index: <tt>\def\Tindex#1{\index{#1}#1}</tt> -- Please someone enhance this to get space correction, [] sorting etc.!<br />
* The name that you will get in the head of \completeregister can be set with: \setupheadtext[register=My new index]<br />
* Get uppercase-letter heads: <cmd>setupregister</cmd><tt>[index][n=2,command=\Word,style=normal]</tt><br />
* The headers in the registers (subsequent letters of the alphabet) can be disabled by <cmd>setupregister</cmd><tt>[register][indicator=no]</tt>; the vertical spaces between the entry groups for subsequent letters is governed by the parameter <tt>before</tt> in the same command (default: <tt>\blank</tt>, change to <tt>before={}</tt> to get no additional space).<br />
<br />
=Coupled Registers=<br />
<br />
This is a special feature for documents that are only used on screen: Make a word clickable to jump to the index, the first or last occurrence.<br />
<br />
Enable it with <cmd>setupregister</cmd><tt>[index][coupling=yes]</tt>.<br />
Substitute <cmd>index</cmd> with <cmd>coupledindex</cmd> and enjoy!<br />
<br />
=Impact on vertical spacing=<br />
<br />
In some situations, placing an <cmd>index</cmd> (or related command) might affect vertical spacing and the page-breaking mechanism. In those situations it is advisable to wrap the command in a <cmd>doflushatpar</cmd> as shown below (needs a ConTeXt version dated after 14th Dec 2005):<br />
<br />
<texcode><br />
\starttext<br />
\section{Tufte}<br />
\dorecurse{4}{\input tufte \par}<br />
\section{Knuth}<br />
\doflushatpar{\index{Knuth}}<br />
\input knuth \par<br />
\stoptext<br />
</texcode><br />
<br />
This will stop bad-page breaking between the section title and the following para, for example.<br />
<br />
==Technical note==<br />
<br />
The above command is defined as follows:<br />
<br />
<texcode><br />
\long\def\doflushatpar#1%<br />
% {\dogotopar{\dontleavehmode#1}} % this one can introduce empty lines<br />
{\dogotopar{#1\ifvmode\nobreak\fi}} % while this one can mess up vertical space<br />
</texcode><br />
<br />
Note the two possible definitions, and the pitfalls with each one. If you are still having trouble with specific <cmd>index</cmd> commands, try using the alternative definition. When they are used in the right context, these three possible ways of placing an index term (the plain <cmd>index</cmd>, or it wrapped in one of the two possible <cmd>doflushatpar</cmd>s, should solve any problem.</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Command/setupdelimitedtext&diff=20784Command/setupdelimitedtext2012-09-24T21:41:41Z<p>Mbork: Added info about repeat and middle keys</p>
<hr />
<div>{{Reference<br />
|name=setupdelimitedtext<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd"><!--<br />
-->\setupdelimitedtext<!--<br />
--><span class="first">[''name'']</span><!--<br />
--><span class="second" style="color:red">[''n'']</span><!--<br />
--><span class="third">[...,...=...,...]</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[''name'']</td><br />
<td>''name of the delimitedtext to set up''</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd" styles="color:red">[''n'']</td><br />
<td>''(optional) nesting level to set up<br /> <br />
(1 = outermost)''</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> location </td><br />
<td> margin text paragraph: ''function unknown'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> spacebefore </td><br />
<td> ''dimension: space above delimitedtext fragment'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> spaceafter </td><br />
<td> ''dimension, spacebefore by default: space below delimitedtext fragment'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> style </td><br />
<td> '''normal''' bold italic, ''etc''</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> color </td><br />
<td> ''color'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> leftmargin </td><br />
<td> ''dimension: distance to edge of the page's left margin area'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> rightmargin </td><br />
<td> ''dimension, leftmargin by default'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> indentnext </td><br />
<td> '''yes''' no </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> before </td><br />
<td> ''command'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> after </td><br />
<td> ''command'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> left </td><br />
<td> ''text'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> middle </td><br />
<td> ''text'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> right </td><br />
<td> ''text'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> level=0, </td><br />
<td> ''unknown, 0 by default'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> repeat </td><br />
<td> '''no''' yes </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> method </td><br />
<td> ''unknown'' </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
Set up the appearance of a delimitedtext environment defined earlier with {{cmd|definedelimitedtext}}. {{cmd|quotation}} and {{cmd|quote}} are delimitedtexts, too, so you can also set up those with this command; but for those you can also use the special commands {{cmd|setupquotation}} and {{cmd|setupquote}}.<br />
<br />
Most of the parameters are self-explanatory, but two things should be borne in mind:<br />
<br />
* Nearly all of the parameters apply only if the new kind of text is invoked with <code>\startmydelimitedtext</code>: if one uses <code>\mydelimitedtext{...}</code>, only <code>left</code> and <code>right</code> have any effect.<br />
<br />
* <code>leftmargin</code> contains the distance to the actual left margin, not to the edge of the body text. If the new delimitedtext inherits from <code>quotation</code>, the text will be indented a bit with respect to the body text; if you want to line them up, set the <code>leftmargin</code> to <code>\leftmargindistance</code> rather than to <code>0pt</code>.<br />
<br />
== Example ==<br />
<context mode="mkiv" source="yes"><br />
\definedelimitedtext[mydt]<br />
\setupdelimitedtext[mydt][left=\leftguillemot,right=\rightguillemot]<br />
<br />
\quotation{Clancy of the Overflow}, by Banjo Paterson<br />
<br />
\startmydt<br />
And an answer came directed in a manner unexpected, and I<br />
think the same was written with a thumbnail dipped in tar;<br />
't was his shearing-mate who wrote it, and verbatim I will quote it:<br />
\quotation{Clancy's gone to Queensland droving, and we don't know where he are.}<br />
\stopmydt<br />
</context><br />
<br />
== Multiparagraph quotations ==<br />
In English typography there is a custom of opening each paragraph in a multiparagraph quotation with a "repeated" opening quotation sign. This behavior may be turned on using the <code>repeat</code> switch and <code>middle</code> key, for example:<br />
<br />
<texcode><br />
\setupquotation[repeat=yes, middle=“] % or equivalently<br />
\setupdelimitedtext[quotation][repeat=yes, middle=“]<br />
</texcode><br />
<br />
== See also ==<br />
* {{cmd|definedelimitedtext}}<br />
* {{cmd|setupquotation}}<br />
* {{cmd|setupquote}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Delimited text|setupdelimitedtext]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Framed&diff=13343Framed2011-08-29T09:39:31Z<p>Mbork: /* More offset parameters */</p>
<hr />
<div>< [[Visuals]] |<br />
<br />
<br />
{{todo|the page devoted to all kinds of framed stuff}}<br />
<br />
= How to achieve specific results =<br />
<br />
== Preventing hyphenation ==<br />
<br />
One can prevent hyphenation inside a frame by passing <code>nothypenated</code> option to <code>align</code>. It is also a good idea to add <code>verytolerant</code> and <code>strectch</code> options.<br />
<br />
<context source="yes"><br />
\startcombination[2*2]<br />
{\framed<br />
[width=5cm,<br />
align={flushleft}]<br />
{\input ward \endgraf}}<br />
{flushleft}<br />
{\framed<br />
[width=5cm,<br />
align={flushleft,nothyphenated,verytolerant}] % maybe also stretch<br />
{\input ward \endgraf}}<br />
{flushleft,\crlf nothyphenated, \crlf verytolerant}<br />
{\framed<br />
[width=5cm,<br />
align={flushright,nothyphenated,verytolerant}] % maybe also stretch<br />
{\input ward \endgraf}}<br />
{flushright,\crlf nothyphenated, \crlf verytolerant}<br />
{\framed<br />
[width=5cm,<br />
align={width,nothyphenated,verytolerant}] % maybe also stretch<br />
{\input ward \endgraf}}<br />
{width,\crlf nothyphenated, \crlf verytolerant}<br />
\stopcombination<br />
</context><br />
<br />
== Specify the width no longer than needed ==<br />
<br />
I want to specify the maximum width of a frame. If the size of the box is smaller than the maximum width, I want a tight box. This can be done using the <code>autowidth=force</code> option to framed.<br />
<br />
<context source="yes"><br />
\defineframed<br />
[tightframed][width=5cm,autowidth=force,align=middle]<br />
<br />
\tightframed{Small}<br />
<br />
\tightframed{A really really long line that is split at 5cm}<br />
<br />
</context><br />
<br />
== Ruled Frames ==<br />
<br />
<cmd>framed</cmd> allows you to specify specific edges to be ruled.<br />
As an alternative to <code>frame=on</code> (the default), one can specify<br />
<code>topframe=on</code>, etc.<br />
Note that, as the default is to draw a complete frame,<br />
it is necessary to either specify the state (on/off) for all four edges<br />
or include the keyword <code>frame=off</code>.<br />
<br />
<context source="yes"><br />
\framed[frame=off,topframe=on,leftframe=on]{A fancy title}<br />
</context><br />
<br />
The thickness of the frame rule can be specified using <code>rulethickness=</code><br />
<br />
<context source="yes"><br />
\framed[frame=off,leftframe=on,rulethickness=2pt]{\tfa\bf A fancy title}<br />
</context><br />
<br />
== Rounded Corners ==<br />
<br />
<cmd>framed</cmd> allows you to have round corners with <code>corner=round</code>. There are also other possibilities if you want round corners but not at all places by giving an appropriate number to <code>corner=...</code>. This example is taken from [[source:core-rul.tex | core-rul.tex]] and each frame is typeset using<br />
<br />
<texcode><br />
\framed[corner=....,frame=on]{...}<br />
</texcode><br />
<br />
<context><br />
\dontleavehmode\framed<br />
[corner=0,frame=on,<br />
]{\tttf corner=\twodigits\recurselevel}%<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse {1} {4}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse {5} {8}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse {9}{12}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{13}{16}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{17}{20}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{21}{24}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{25}{28}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
<br />
</context><br />
<br />
* You can only fill the frame with a background color if the corner shape is closed. Otherwise, the backgroundcolor option will be silently ignored.<br />
<br />
<br />
== Coloring frame background and framed text ==<br />
<br />
First you have to turn on colors with <cmd>setupcolors</cmd><tt>[state=start]</tt>. Then you can define the background and foreground (=text) colors:<br />
<br />
<texcode>\framed[background=color,backgroundcolor=....,foreground=color,foregroundcolor=...]{...}</texcode><br />
<br />
If you want to make the frame itself disappear, add a <tt>frame=off</tt> to the setups.<br />
<br />
{|<br />
|<context><br />
\setupcolors[state=start]<br />
\framed<br />
[background=color,backgroundcolor=darkblue,<br />
foreground=color,foregroundcolor=white]<br />
{\ssx \bf Bold white on dark blue}<br />
</context><br />
|<texcode><br />
\setupcolors[state=start]<br />
\framed<br />
[background=color,backgroundcolor=darkblue,<br />
foreground=color,foregroundcolor=white]<br />
{\ssx \bf Bold white on dark blue}<br />
</texcode><br />
|-<br />
|<context><br />
\setupcolors[state=start]<br />
\framed<br />
[background=color,backgroundcolor=yellow,<br />
frame=off]<br />
{\tfx Who needs highlighter pens, anyway?}<br />
</context><br />
|<texcode><br />
\framed<br />
[background=color,backgroundcolor=yellow,<br />
frame=off]<br />
{\tfx Who needs highlighter pens, anyway?}<br />
</texcode><br />
|-<br />
|<context><br />
\setupcolors[state=start]<br />
\framed<br />
[frame=on, corner=0, frameoffset=10pt,<br />
framecolor=black,background=color,<br />
backgroundcolor=darkgreen, backgroundoffset=10pt,<br />
foreground=color,foregroundcolor=white]<br />
{\tfxx \bf Rounded corners with offset}<br />
</context><br />
|For filling frames with offset you have to add options <code>frameoffset=..., backgroundoffset=...</code><br />
<texcode><br />
\framed<br />
[frame=on, corner=0, frameoffset=10pt,<br />
framecolor=black,background=color,<br />
backgroundcolor=darkgreen, backgroundoffset=10pt, <br />
foreground=color,foregroundcolor=white]<br />
{\tfxx \bf Rounded corners with offset}<br />
</texcode><br />
|}<br />
<br />
See the [[Colors]] section for more information on available colors and color usage.<br />
<br />
== Shaded background for part of a displayed equation ==<br />
<br />
To highlight part of a formula, you can give it a gray background using <cmd>mframed</cmd>:<br />
<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
\def\graymath{\mframed[frame=off,<br />
background=color,<br />
backgroundcolor=gray,<br />
backgroundoffset=3pt]}<br />
<br />
\startformula<br />
\ln (1+x) =\, \graymath{x - {x^2\over2}} \,+ {x^3\over3}-\cdots.<br />
\stopformula<br />
</context><br />
<br />
The <cmd>,</cmd> add a tiny bit of space to prevent the gray background from crowding the equals and plus sign.<br />
<br />
== Inline Frames ==<br />
<br />
The command <cmd>inframed</cmd>, similar to <cmd>framed</cmd>,<br />
differs in the definition of the baseline:<br />
<br />
<context source="yes"><br />
\framed[frame=off,width=10em,align=flushleft]{%<br />
Notice the difference between<br />
\framed{framed} and \inframed{inframed},<br />
especially considering its effect on linespacing...<br />
}<br />
</context><br />
<br />
== Dotted Frames ==<br />
<br />
Using MetaPost:<br />
<br />
<texcode><br />
\startuniqueMPgraphic{Label}<br />
path p; p := (0,0) -- (OverlayWidth,0) -- (OverlayWidth, OverlayHeight) -- (0, OverlayHeight) -- (0,0);<br />
draw p withpen pencircle scaled 1pt dashed withdots;<br />
setbounds currentpicture to boundingbox OverlayBox;<br />
\stopuniqueMPgraphic<br />
\defineoverlay[Label][\useMPgraphic{Label}]<br />
\def\DotPicture#1#2#3%<br />
{%<br />
\placefigure[][#3]{#2}%<br />
{%<br />
\framed[align={flushleft, low},%<br />
frame=off,%<br />
height=3in,%<br />
width=broad]%<br />
{%<br />
\externalfigure[#1]%<br />
[width=3in,%<br />
background=Label,%<br />
backgroundoffset=1ex]%<br />
}%<br />
}%<br />
}%<br />
\def\DotText#1%<br />
{%<br />
\framed[frame=off,%<br />
background=Label,%<br />
location=low]%<br />
{%<br />
#1<br />
}%<br />
}%<br />
\starttext<br />
<br />
\DotPicture{sample/cow.pdf}{All your base are belong to us}{SampleRef}%<br />
<br />
AAA \DotText{BBB} CCC \DotText{DDD}<br />
\stoptext<br />
</texcode><br />
[[File:dotted_frame_mpost.png|650px]]<br />
<br />
Using TikZ:<br />
<br />
<context source="yes"><br />
\usemodule[tikz]%<br />
\tikzstyle{block}=[rectangle,draw=black,text centered,style=dotted,inner sep=0pt]<br />
\def\Picture#1#2#3%<br />
{<br />
\placefigure[left][#3]{#2}%<br />
{%<br />
\tikzpicture%<br />
\node[block](init){\externalfigure[#1][width=3in]};%<br />
\endtikzpicture%<br />
}%<br />
}%<br />
\starttext<br />
\Picture{sample/cow.pdf}{All your base are belong to us}{SampleRef}<br />
\stoptext<br />
</context><br />
<br />
= Width broad and local =<br />
Sometimes <tt>width</tt> must be adapted to a "local" <tt>\hsize </tt><br />
(the actual text area used by TeX to determine line breaks).<br />
For example:<br />
<context source='yes'><br />
\setuppapersize[A7,landscape][A7,landscape]<br />
\setupbodyfont[8pt,ss]<br />
\starttext<br />
\framed[width=broad]{}<br />
\startnarrower[left]<br />
\framed[width=broad]{}<br />
\dontleavehmode\framed[width=broad]{}<br />
\dontleavehmode\framed[width=local]{}<br />
\stopnarrower<br />
\blank<br />
\hsize.5\hsize<br />
\framed[width=broad]{}<br />
\startnarrower[left]<br />
\framed[width=broad]{}<br />
\dontleavehmode\framed[width=broad]{}<br />
\dontleavehmode\framed[width=local]{}<br />
\stopnarrower<br />
\stoptext<br />
</context><br />
<br />
Here we use <tt>\setlocalhsize</tt> after <tt>\startitemize</tt> to setup the localhsize:<br />
<context source="yes"><br />
\setuppapersize[A7,landscape][A7,landscape]<br />
\setupbodyfont[8pt,ss]<br />
\setupcolors[state=start]<br />
\setupframed[framecolor=blue]<br />
\showframe<br />
\starttext<br />
\framed[width=\hsize,align=middle]{width=hsize}<br />
\startitemize<br />
\setlocalhsize<br />
\item \framed[width=\hsize,align=middle] {width=hsize}<br />
\item \framed[width=broad,align=middle] {width=broad}<br />
\item \framed[width=local,align=middle] {width=local}<br />
\stopitemize<br />
\stoptext<br />
</context><br />
<br />
=Spacing between frame and text=<br />
<br />
<tt>\framed</tt> comes with two different types of offsets:<br />
one for the frame itself and another for the its content.<br />
The parameters <tt>frameoffset</tt> and <tt>backgroundoffset</tt><br />
were already explained above in the section [[#Coloring frame background and framed text]].<br />
<br />
In addition, the parameter [strut=no] allows removal of the initial strut when framing text that is [[Verbatim with line breaks]].<br />
<br />
==Content offsets==<br />
Beyond those there is another four dimensions that enable you to control <br />
the safety distance of a <tt>\framed</tt>’s content by orientation.<br />
Horizontally, <tt>loffset</tt> governs the left, <tt>roffset</tt> the right<br />
offset;<br />
the same goes for <tt>boffset</tt> for the bottom and <tt>toffset</tt> for <br />
the top distance.<br />
Their effects are explored in the following example (MkIV only).<br />
<br />
==Example==<br />
<texcode><br />
\def\offsetframe[#1]{%<br />
{\framed[<br />
#1=1em,<br />
align=normal,<br />
width=5.3cm,<br />
height=5.3cm,<br />
]{\tfx\input ward }<br />
}{\it#1}<br />
}<br />
<br />
\starttext<br />
\startcombination[2*2]<br />
\offsetframe[loffset]<br />
\offsetframe[roffset]<br />
\offsetframe[toffset]<br />
\offsetframe[boffset]<br />
\stopcombination<br />
\stoptext<br />
</texcode><br />
<br />
==More offset parameters==<br />
Also, you can set up <nowiki>offset</nowiki>, which sets up all the <nowiki>[lrtb]offset</nowiki> parameters.<br />
<br />
Here's a method to define a new parameter, call it <nowiki>hoffset</nowiki>, which sets up <nowiki>[lr]offset</nowiki> at the same time:<br />
<texcode><br />
\setupframed<br />
[loffset=\framedparameter{hoffset},<br />
roffset=\framedparameter{hoffset},<br />
hoffset=\zeropoint]<br />
</texcode><br />
<br />
= Similar topics =<br />
* [[Vertically Centered Boxes]]<br />
* [[Overlays]]<br />
* [[Tables Overview]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Enumerations&diff=9271Enumerations2009-02-28T07:55:03Z<p>Mbork: /* Randomizing items */ \nextrandom workaround</p>
<hr />
<div>< [[Structurals]]<br />
<br />
The most basic form of using enumerations in ConTeXt is<br />
<br />
<texcode><br />
\startitemize<br />
\item here we list the points,<br />
\item one after the other.<br />
\stopitemize<br />
</texcode><br />
<br />
The <cmd>startitemize</cmd> command takes optional parameters (see the documentation of <cmd>startitemgroup</cmd> for a complete list), for example a number conversion may be given, with the following predefined types:<br />
<br />
<table><br />
<tr><td><tt>n</tt> or <tt>N</tt></td><td>Usually the default: a numbered list</td></tr><br />
<tr><td><tt>m</tt></td><td>A numbered list, with lowercase (&ldquo;medieval&rdquo;, aka &ldquo;oldstyle&rdquo;) numbers.</td></tr><br />
<tr><td><tt>1</tt> &hellip; <tt>8</tt></td><td>Different kinds of bullets. All items get the same symbol.</td></tr><br />
<tr><td><tt>a</tt></td><td>Items are numbered a., b., c., &hellip;</td></tr><br />
<tr><td><tt>A</tt></td><td>Items are numbered A., B., C., &hellip;</td></tr><br />
<tr><td><tt>AK</tt></td><td>Items are numbered A., B., C., &hellip;, in small caps.</td></tr><br />
<tr><td><tt>r</tt></td><td>Items are numbered in lowercase Roman numerals.</td></tr><br />
<tr><td><tt>R</tt></td><td>Items are numbered in uppercase Roman numerals.</td></tr><br />
<tr><td><tt>KR</tt></td><td>Items are numbered in uppercase Roman numerals, small caps style.</td></tr><br />
</table><br />
<br />
It is also possible to define your own number conversions; see [[User-Defined Enumerations]]. If you have loaded the [[Chinese]] module, you can also use <tt>c</tt> (and some more) for Chinese numbers.<br />
<br />
Additional parameters include<br />
* <tt>continue</tt> (start where the previous itemization was finished, to allow text injections),<br />
* <tt>packed</tt> (less vertical space between items), <br />
* <tt>inmargin</tt> (place enumeration symbols into the margin), and<br />
* <tt>text</tt> (paragraph enumerations, formats the items as a running text).<br />
<br />
To change the general layout of enumerations, there is <cmd>setupitemize</cmd>. It accepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply. There is an example below.<br />
<br />
For finer control, it is advisable to create new types of itemization, using the command <cmd>defineitemgroup</cmd> (which unfortunately seems undocumented). For example, something similar to the LaTeX <tt>itemize</tt> environment can be defined as follows:<br />
<br />
<texcode><br />
\defineitemgroup[ltxitm][levels=5]<br />
%<br />
\setupitemgroup[ltxitm][1][1]<br />
\setupitemgroup[ltxitm][2][2]<br />
\setupitemgroup[ltxitm][3][3,packed]<br />
\setupitemgroup[ltxitm][4][4,packed]<br />
\setupitemgroup[ltxitm][5][5,packed]<br />
%<br />
\starttext<br />
%<br />
\startltxitm<br />
\item Consider<br />
\startltxitm<br />
\item this part<br />
\item and also these subpoints:<br />
\startltxitm<br />
\item one<br />
\item two<br />
\item three<br />
\startltxitm<br />
\item threeandahalf<br />
\stopltxitm<br />
\item four<br />
\stopltxitm<br />
\stopltxitm<br />
\stopltxitm<br />
%<br />
\stoptext<br />
</texcode><br />
<br />
gives<br />
<br />
<context><br />
\defineitemgroup[ltxitm][levels=5]<br />
%<br />
\setupitemgroup[ltxitm][1][1]<br />
\setupitemgroup[ltxitm][2][2]<br />
\setupitemgroup[ltxitm][3][3,packed]<br />
\setupitemgroup[ltxitm][4][4,packed]<br />
\setupitemgroup[ltxitm][5][5,packed]<br />
%<br />
\starttext<br />
%<br />
\startltxitm<br />
\item Consider<br />
\startltxitm<br />
\item this part<br />
\item and also these subpoints:<br />
\startltxitm<br />
\item one<br />
\item two<br />
\item three<br />
\startltxitm<br />
\item threeandahalf<br />
\stopltxitm<br />
\item four<br />
\stopltxitm<br />
\stopltxitm<br />
\stopltxitm<br />
%<br />
\stoptext<br />
</context><br />
<br />
==Changing the Signs==<br />
<br />
For a enumeration like this:<br />
<br />
<context><br />
\starttext<br />
\setupitemize[left=(, right=), margin=4em, stopper=]<br />
\startitemize[a, packed]<br />
\item one item,<br />
\item next item.<br />
\stopitemize<br />
\stoptext<br />
</context><br />
<br />
you must fill <cmd>setupitemize</cmd> like this:<br />
<br />
* you get parentheses by <tt>left=(, right=)</tt><br />
* <tt>margin</tt> is from left margin to start of item text<br />
* <tt>stopper</tt> is the dot (or whatever) after the "number"<br />
<br />
<texcode><br />
\setupitemize[left=(, right=), margin=4em, stopper=]<br />
\startitemize[a]<br />
\item one item,<br />
\item next item.<br />
\stopitemize<br />
</texcode><br />
<br />
You find more about <cmd>setupitemize</cmd> at <cmd>defineitemgroup</cmd>.<br />
<br />
<br />
==Alternate Multicolumn Format==<br />
Hans posted a solution to the list for a multicolumn enumeration that counts across then down, instead of down then across. When he posted it (Dec 21, 2005), he said the joinedup option does not work, but he would fix that. This is a version without the tufte and zapf text<br />
<br />
<texcode><br />
\starttext<br />
<br />
Some previous sentence before the list<br />
<br />
\startitemize[columns,n,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
<br />
And the text continues after the list<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\starttext<br />
<br />
Some previous sentence before the list<br />
<br />
\startitemize[columns,n,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
<br />
And the text continues after the list<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
== Whitespace around itemize ==<br />
<br />
This is the way how you can set spacing before and after itemize when working with<br />
<texcode><br />
\setupwhitespace[big]<br />
</texcode><br />
<br />
An option '''nowhite''' comes in handy:<br />
<br />
<texcode><br />
paragraph before<br />
<br />
\startitemize[joinedup,nowhite,after]<br />
\item first<br />
\item second<br />
\stopitemize<br />
<br />
paragraph after<br />
</texcode><br />
<br />
These are all the four possible combinations of whitespace settings that you might want to use:<br />
<br />
<br />
<context><br />
\setuplayout[scale=0.8,width=9cm]<br />
\setupwhitespace[big]<br />
\definesymbol[1][$\triangleright$]<br />
\startcolumns<br />
{\bf joinedup:} \startitemize[joinedup] \item test \item test \stopitemize after \par<br />
{\bf joinedup,nowhite:} \startitemize[joinedup,nowhite] \item test \item test \stopitemize after \column<br />
{\bf joinedup,nowhite,before:} \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize after \par<br />
{\bf joinedup,nowhite,after:} \startitemize[joinedup,nowhite,after] \item test \item test \stopitemize after<br />
\stopcolumns<br />
</context><br />
<br />
== Randomizing items ==<br />
It is possible to make ConTeXt randomize the items in enumerations; this can come handy when, e.g., typesetting tests. You have to add a <tt>random</tt> option to <cmd>startitemize</cmd>. There are two caveats:<br />
# You have to say <cmd>startitem</cmd> ... <cmd>stopitem</cmd> instead of <cmd>item</cmd> ... .<br />
# Somehow the first item does not get randomized. (I learned from the mailing list - thanks, Aditya! - that adding a <cmd>nextrandom</cmd> somewhere earlier helps.)<br />
Example:<br />
<br />
<context source="yes"><br />
\nextrandom<br />
\startitemize[random]<br />
\startitem A \stopitem<br />
\startitem B \stopitem<br />
\startitem C \stopitem<br />
%\startitem F \stopitem<br />
\stopitemize<br />
</context></div>Mborkhttps://wiki.contextgarden.net/index.php?title=Enumerations&diff=9268Enumerations2009-02-27T11:53:40Z<p>Mbork: Randomizing items</p>
<hr />
<div>< [[Structurals]]<br />
<br />
The most basic form of using enumerations in ConTeXt is<br />
<br />
<texcode><br />
\startitemize<br />
\item here we list the points,<br />
\item one after the other.<br />
\stopitemize<br />
</texcode><br />
<br />
The <cmd>startitemize</cmd> command takes optional parameters (see the documentation of <cmd>startitemgroup</cmd> for a complete list), for example a number conversion may be given, with the following predefined types:<br />
<br />
<table><br />
<tr><td><tt>n</tt> or <tt>N</tt></td><td>Usually the default: a numbered list</td></tr><br />
<tr><td><tt>m</tt></td><td>A numbered list, with lowercase (&ldquo;medieval&rdquo;, aka &ldquo;oldstyle&rdquo;) numbers.</td></tr><br />
<tr><td><tt>1</tt> &hellip; <tt>8</tt></td><td>Different kinds of bullets. All items get the same symbol.</td></tr><br />
<tr><td><tt>a</tt></td><td>Items are numbered a., b., c., &hellip;</td></tr><br />
<tr><td><tt>A</tt></td><td>Items are numbered A., B., C., &hellip;</td></tr><br />
<tr><td><tt>AK</tt></td><td>Items are numbered A., B., C., &hellip;, in small caps.</td></tr><br />
<tr><td><tt>r</tt></td><td>Items are numbered in lowercase Roman numerals.</td></tr><br />
<tr><td><tt>R</tt></td><td>Items are numbered in uppercase Roman numerals.</td></tr><br />
<tr><td><tt>KR</tt></td><td>Items are numbered in uppercase Roman numerals, small caps style.</td></tr><br />
</table><br />
<br />
It is also possible to define your own number conversions; see [[User-Defined Enumerations]]. If you have loaded the [[Chinese]] module, you can also use <tt>c</tt> (and some more) for Chinese numbers.<br />
<br />
Additional parameters include<br />
* <tt>continue</tt> (start where the previous itemization was finished, to allow text injections),<br />
* <tt>packed</tt> (less vertical space between items), <br />
* <tt>inmargin</tt> (place enumeration symbols into the margin), and<br />
* <tt>text</tt> (paragraph enumerations, formats the items as a running text).<br />
<br />
To change the general layout of enumerations, there is <cmd>setupitemize</cmd>. It accepts an integer as its first parameter to denote for which level of itemization the subsequent settings should apply. There is an example below.<br />
<br />
For finer control, it is advisable to create new types of itemization, using the command <cmd>defineitemgroup</cmd> (which unfortunately seems undocumented). For example, something similar to the LaTeX <tt>itemize</tt> environment can be defined as follows:<br />
<br />
<texcode><br />
\defineitemgroup[ltxitm][levels=5]<br />
%<br />
\setupitemgroup[ltxitm][1][1]<br />
\setupitemgroup[ltxitm][2][2]<br />
\setupitemgroup[ltxitm][3][3,packed]<br />
\setupitemgroup[ltxitm][4][4,packed]<br />
\setupitemgroup[ltxitm][5][5,packed]<br />
%<br />
\starttext<br />
%<br />
\startltxitm<br />
\item Consider<br />
\startltxitm<br />
\item this part<br />
\item and also these subpoints:<br />
\startltxitm<br />
\item one<br />
\item two<br />
\item three<br />
\startltxitm<br />
\item threeandahalf<br />
\stopltxitm<br />
\item four<br />
\stopltxitm<br />
\stopltxitm<br />
\stopltxitm<br />
%<br />
\stoptext<br />
</texcode><br />
<br />
gives<br />
<br />
<context><br />
\defineitemgroup[ltxitm][levels=5]<br />
%<br />
\setupitemgroup[ltxitm][1][1]<br />
\setupitemgroup[ltxitm][2][2]<br />
\setupitemgroup[ltxitm][3][3,packed]<br />
\setupitemgroup[ltxitm][4][4,packed]<br />
\setupitemgroup[ltxitm][5][5,packed]<br />
%<br />
\starttext<br />
%<br />
\startltxitm<br />
\item Consider<br />
\startltxitm<br />
\item this part<br />
\item and also these subpoints:<br />
\startltxitm<br />
\item one<br />
\item two<br />
\item three<br />
\startltxitm<br />
\item threeandahalf<br />
\stopltxitm<br />
\item four<br />
\stopltxitm<br />
\stopltxitm<br />
\stopltxitm<br />
%<br />
\stoptext<br />
</context><br />
<br />
==Changing the Signs==<br />
<br />
For a enumeration like this:<br />
<br />
<context><br />
\starttext<br />
\setupitemize[left=(, right=), margin=4em, stopper=]<br />
\startitemize[a, packed]<br />
\item one item,<br />
\item next item.<br />
\stopitemize<br />
\stoptext<br />
</context><br />
<br />
you must fill <cmd>setupitemize</cmd> like this:<br />
<br />
* you get parentheses by <tt>left=(, right=)</tt><br />
* <tt>margin</tt> is from left margin to start of item text<br />
* <tt>stopper</tt> is the dot (or whatever) after the "number"<br />
<br />
<texcode><br />
\setupitemize[left=(, right=), margin=4em, stopper=]<br />
\startitemize[a]<br />
\item one item,<br />
\item next item.<br />
\stopitemize<br />
</texcode><br />
<br />
You find more about <cmd>setupitemize</cmd> at <cmd>defineitemgroup</cmd>.<br />
<br />
<br />
==Alternate Multicolumn Format==<br />
Hans posted a solution to the list for a multicolumn enumeration that counts across then down, instead of down then across. When he posted it (Dec 21, 2005), he said the joinedup option does not work, but he would fix that. This is a version without the tufte and zapf text<br />
<br />
<texcode><br />
\starttext<br />
<br />
Some previous sentence before the list<br />
<br />
\startitemize[columns,n,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
<br />
And the text continues after the list<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\starttext<br />
<br />
Some previous sentence before the list<br />
<br />
\startitemize[columns,n,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
\startitemize[continue,columns,joinedup]<br />
\item one<br />
\item two<br />
\stopitemize<br />
<br />
And the text continues after the list<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
== Whitespace around itemize ==<br />
<br />
This is the way how you can set spacing before and after itemize when working with<br />
<texcode><br />
\setupwhitespace[big]<br />
</texcode><br />
<br />
An option '''nowhite''' comes in handy:<br />
<br />
<texcode><br />
paragraph before<br />
<br />
\startitemize[joinedup,nowhite,after]<br />
\item first<br />
\item second<br />
\stopitemize<br />
<br />
paragraph after<br />
</texcode><br />
<br />
These are all the four possible combinations of whitespace settings that you might want to use:<br />
<br />
<br />
<context><br />
\setuplayout[scale=0.8,width=9cm]<br />
\setupwhitespace[big]<br />
\definesymbol[1][$\triangleright$]<br />
\startcolumns<br />
{\bf joinedup:} \startitemize[joinedup] \item test \item test \stopitemize after \par<br />
{\bf joinedup,nowhite:} \startitemize[joinedup,nowhite] \item test \item test \stopitemize after \column<br />
{\bf joinedup,nowhite,before:} \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize after \par<br />
{\bf joinedup,nowhite,after:} \startitemize[joinedup,nowhite,after] \item test \item test \stopitemize after<br />
\stopcolumns<br />
</context><br />
<br />
== Randomizing items ==<br />
It is possible to make ConTeXt randomize the items in enumerations; this can come handy when, e.g., typesetting tests. You have to add a <tt>random</tt> option to <cmd>startitemize</cmd>. There are two caveats:<br />
# You have to say <cmd>startitem</cmd> ... <cmd>stopitem</cmd> instead of <cmd>item</cmd> ... .<br />
# Somehow the first item does not get randomized.<br />
<br />
Example:<br />
<br />
<context source="yes"><br />
\startitemize[random]<br />
\startitem A \stopitem<br />
\startitem B \stopitem<br />
\startitem C \stopitem<br />
\startitem D \stopitem<br />
\startitem E \stopitem<br />
%\startitem F \stopitem<br />
\stopitemize<br />
</context></div>Mborkhttps://wiki.contextgarden.net/index.php?title=User:Mbork&diff=9027User:Mbork2008-11-05T20:40:35Z<p>Mbork: coming back to one-column in itemizations</p>
<hr />
<div>My name is Marcin Borkowski. Here is the link to my personal webpage (mostly in Polish, sorry;)), in case you are curious about me: http://atos.wmid.amu.edu.pl/~mbork/cgi-bin/wiki.cgi/About_me.<br />
<br />
== ConTeXt problems ==<br />
Since I am a ConTeXt beginner, I have ''lots'' of problems using it. I'm putting the unsolved ones here since this is easier to find than in the list archives. (Also, maybe someone will help;)?)<br />
=== Multicolumn itemizations ===<br />
Some of them are connected with multicolumn itemizations, which seem to be somehow broken. Maybe someone knows what's wrong with this? The <code>[intro]</code> option doesn't work.<br />
<texcode><br />
\starttext<br />
\dorecurse{12}{%<br />
This is some intro (\recurselevel).<br />
\startitemize[n,packed,joinedup,columns,two,intro]<br />
\dorecurse{8}{\item This is an item.}<br />
\stopitemize<br />
}%<br />
\stoptext<br />
</texcode><br />
It works neither in MkII nor in MkIV, though the output is wrong in two different ways (at least in the online ConTeXt as of 2008-11-05).<br />
<br />
Also, is it possible to insert manually a column break in multicolumn itemizations? (This is needed e.g. when some of the items are taller than the other (math formulae!) and I get e.g. 3+1 items in two columns instead of 2+2)<br />
<br />
And another problem: how to "come back" to one-column? I mean, when I have two-column itemizations throughout the document and I want to have ''one'' one-column one (what a syntax;)!), how can I do it? This won't work (neither in MkII nor in MkIV):<br />
<texcode><br />
\setupitemize[1][n,intro]<br />
\setupitemize[2][a,paragraph,intro,columns,two][stopper=)]<br />
<br />
\defineitemgroup[onecolumnitemize]<br />
\setuponecolumnitemize[2][a,paragraph,intro][stopper=:]<br />
<br />
\starttext<br />
\startitemize<br />
\item Item one<br />
\item Sub-itemize:<br />
\startitemize<br />
\item sub-one<br />
\item sub-two<br />
\item sub-three<br />
\item sub-four<br />
\stopitemize<br />
\item Sub-itemize with one column:<br />
\startonecolumnitemize<br />
\item A<br />
\item B<br />
\item C<br />
\stoponecolumnitemize<br />
\stopitemize<br />
\stoptext<br />
</texcode></div>Mborkhttps://wiki.contextgarden.net/index.php?title=User:Mbork&diff=9026User:Mbork2008-11-05T10:42:27Z<p>Mbork: /* Multicolumn itemizations */ motivation (& typos)</p>
<hr />
<div>My name is Marcin Borkowski. Here is the link to my personal webpage (mostly in Polish, sorry;)), in case you are curious about me: http://atos.wmid.amu.edu.pl/~mbork/cgi-bin/wiki.cgi/About_me.<br />
<br />
== ConTeXt problems ==<br />
Since I am a ConTeXt beginner, I have ''lots'' of problems using it. I'm putting the unsolved ones here since this is easier to find than in the list archives. (Also, maybe someone will help;)?)<br />
=== Multicolumn itemizations ===<br />
Some of them are connected with multicolumn itemizations, which seem to be somehow broken. Maybe someone knows what's wrong with this? The <code>[intro]</code> option doesn't work.<br />
<texcode><br />
\starttext<br />
\dorecurse{12}{%<br />
This is some intro (\recurselevel).<br />
\startitemize[n,packed,joinedup,columns,two,intro]<br />
\dorecurse{8}{\item This is an item.}<br />
\stopitemize<br />
}%<br />
\stoptext<br />
</texcode><br />
It works neither in MkII nor in MkIV, though the output is wrong in two different ways (at least in the online ConTeXt as of 2008-11-05).<br />
<br />
Also, is it possible to insert manually a column break in multicolumn itemizations? (This is needed e.g. when some of the items are taller than the other (math formulae!) and I get e.g. 3+1 items in two columns instead of 2+2)</div>Mborkhttps://wiki.contextgarden.net/index.php?title=User:Mbork&diff=9025User:Mbork2008-11-05T10:40:03Z<p>Mbork: problems - multicolumn itemizations</p>
<hr />
<div>My name is Marcin Borkowski. Here is the link to my personal webpage (mostly in Polish, sorry;)), in case you are curious about me: http://atos.wmid.amu.edu.pl/~mbork/cgi-bin/wiki.cgi/About_me.<br />
<br />
== ConTeXt problems ==<br />
Since I am a ConTeXt beginner, I have ''lots'' of problems using it. I'm putting the unsolved ones here since this is easier to find than in the list archives. (Also, maybe someone will help;)?)<br />
=== Multicolumn itemizations ===<br />
Some of them are connected with multicolumn itemizations, which seem to be somehow broken. Maybe someone knows what's wrong with this? The [intro] option doesn't work.<br />
<texcode><br />
\starttext<br />
\dorecurse{12}{%<br />
This is some intro (\recurselevel).<br />
\startitemize[n,packed,joinedup,columns,two,intro]<br />
\dorecurse{8}{\item This is an item.}<br />
\stopitemize<br />
}%<br />
\stoptext<br />
</texcode><br />
It works neither in MkII nor in MkIV, though the output is wring in two different ways (at least in the online ConTeXt as of 2008-11-05).<br />
<br />
Also, is it possible to insert manually a column break in multicolumn itemizations?</div>Mborkhttps://wiki.contextgarden.net/index.php?title=FAQ&diff=9014FAQ2008-10-27T00:06:27Z<p>Mbork: /* Can I use some simpler biography method? */ typo</p>
<hr />
<div>{{todo|This FAQ needs to have a lot of things worked on. To avoid clutter from repeated TODO tags, just note missing answers with "...", and put notes about missing information in parentheses.}}<br />
<br />
=== What is ConTeXt? ===<br />
:It is a document production system based on Donald Knuth's [[http://www.tug.org/ TeX]]. It is a set of high-level macros written in the (somewhat arcane) TeX language, and these macros simplify the task of designing layouts, making hyperlinks, etc.<br />
<br />
=== Is there a hello-world document? ===<br />
:Yes. See [[First Document]] and [[Hello world]].<br />
<br />
=== Is ConTeXt free (open source) software? ===<br />
:Yes. See the [[Read Me]] page for details.<br />
<br />
=== How do I install ConTeXt? ===<br />
<br />
:See [[Installation]]<br />
<br />
=== Does ConTeXt support Unicode? ===<br />
:Yes. It supports Unicode (utf-8) input, with the <cmd>enableregime</cmd><tt>[utf-8]</tt> command. See also [[Encodings and Regimes]] (This needs a bit of elaboration!) If you use [[XeTeX]], Unicode should work by default.<br />
<br />
=== Why does <code>\startalignment[right]</code> or <code>\framed[align=right]{some text}</code> align my text left instead of right and vice versa? ===<br />
:This is for backward compatibility with older versions; see [[Right and left]]. Hans was originally thinking of "ragged right" and "ragged left" alignment. Use '''flushleft''' and '''flushright''' instead.<br />
<br />
=== What are the differences between ConTeXt and LaTeX? ===<br />
<br />
:The main difference between the two, in my opinion, is a philosophical one: LaTeX was created with the idea of separating content and presentation to such an extent that the typical author would write their content and then use a style file created by someone else to provide the visual presentation. Thus, the proliferation of style files and related things.<br />
<br />
:ConTeXt, on the other hand, retained the idea of separating content and presentation, but was created with the idea of being used for books, where each book tends to have a different layout, and so the expected "end user" is the person doing all the layout. Thus, it's designed to provide a vast amount of flexibility for layout in a way that can be fairly easily defined without needing to write a package (or go find one that's already written).<br />
<br />
:To some extent, modern LaTeX has become a lot more like ConTeXt's intent, with a large quantity of packages, and classes like "memoir" that are designed to give the end user a large amount of control of the visual presentation. Thus, the difference is more one of focus and arrangement -- ConTeXt is all "of a piece" and most things are built in and designed as a complete set, whereas with LaTeX it's generally the case that when you want to do something different, you need to find the right package, and sometimes find that there are three that almost do what you want and none that are quite right (but, then, that also means that there are usually choices for how to do things, which can be good.)<br />
<br />
:Another difference is that IMO, ConTeXt is a lot easier to program in. It was designed a fair bit later than LaTeX, for much faster computers, and thus includes a lot of things that make it load and run slower but make programming a lot easier. <br />
<br />
:Author: Brooks Moses on c.t.t. usenet<br />
<br />
=== What are the advantages of ConTeXt over LaTeX? ===<br />
<br />
:ConTeXt is a macro package that’s far more advanced than LaTeX. You can enhance LaTeX with third party packages, but not all macro packages work together with each other. ConTeXt is an integrated, powerful and flexible macro package for which you seldom need third party packages. ConTeXt also has been used to create large and complex on-screen documents, including hyperlinks, on screen buttons, forms, cross-document links, and so on.<br />
<br />
:Source: ''LaTeX in proper ConTeXt'' (by Berend de Boer)<br />
<br />
=== How can I convert a document into RTF or HTML? ===<br />
<br />
:Hot topic on the mailing list!<br />
<br />
:There's currently no converter such as LaTeX2html available for ConTeXt. If you're ready to pay a price and put some more effort in your document, the best way is to use XML and produce PDF out of it with ConTeXt and HTML using XSLT.<br />
<br />
:[http://archive.contextgarden.net/thread/20050921.151245.b6a6f87e.en.html ConTeXt to RTF Conversion]<br />
<br />
=== What about the other way around? ===<br />
<br />
:[http://archive.contextgarden.net/thread/20050926.213139.45057948.en.html DOC/RTF to ConTeXt via XML]<br />
<br />
<br />
=== Can I change to Computer Modern's LaTeX font? ===<br />
<br />
I see diferences in screen between default fonts in ConTeXt (latin modern) and LaTeX (computer modern). Can I swicth to latex default font?. I think it's more stetical<br />
: No.<br />
: ''(I mean - of course you can; you only need to modify a few type-xxx.tex files and replace lm with cm in the source. But that solution is not/will not be supported officially.)''<br />
:: Is there any tutorial for doing it?<br />
::: ''No. There are no tutorials for the things that one is not supposed to mess with. Take a look at how things are done in those files and replace any occurrence of lm with cm.''<br />
<br />
=== Can I use some simpler bibliography method? ===<br />
<br />
I see that the method of [[http://wiki.contextgarden.net/Bibliography adding references in ConTexT]] is like bibtex in latex. Is there any simple methood like build-in latex method (\thebibliography)?<br />
: Perhaps [[http://wiki.contextgarden.net/Simple_Bibliography Simple bibliography (in simple bibliography)]]?<br />
<br />
=== XML: please tell me more about it ===<br />
<br />
=== How do I make a presentation? ===<br />
<br />
:You don't need any special package (like prosper or seminar in LaTeX) to make a presentation. In contrast to LaTeX, changing the document size, changing colors, adding hyperlinks, ... appears to be extremely simple in ConTeXt. See [[Presentations]] for more specific topics.<br />
<br />
=== <code>\setupindenting[medium]</code> doesn't work? ===<br />
<br />
:This does work, but the effect is not what you expect. Without <code>yes</code>, you have now set up the default size, but you have not turned paragraph indenting on. You have to execute <code>\setupindenting[yes]</code> before it starts actually indenting your paragraphs.<br />
<br />
=== Does $$...$$ work for display math, like in (La)TeX? ===<br />
:No; the spacing above and below the equation will be wrong, and maybe other aspects too. Instead use <cmd>startformula</cmd> and <cmd>stopformula</cmd>.<br />
<br />
=== How do I get a numbered equation? ===<br />
:Add <cmd>placeformula</cmd> before the <cmd>startformula</cmd>.<br />
<br />
=== How can I get a horizontal space with a defined width, so as ex. "\hspace{3em}" or "\hspace*{3em}" in LaTeX? ===<br />
:A horizontal space can be inserted with the TeX-Primitive<cmd>hspace〈dimension〉</cmd> or with the ConTeXt command <cmd>hspace[identifier]</cmd>.<br />
<br />
=== How can I get the lowercase (medieval, oldstyle figures) numbers in a document? ===<br />
The mediaeval numbers can be inserted locally by "\os". I would prefer a global setting of them but I don't know how to do it.<br />
<br />
=== How transcribe this LaTeX macro to ConTEXt? ===<br />
Could you please advice me, how transcribe this macro, controlling that no last line of a paragraph is shorter than the paragraph indenting?<br />
<br />
<texcode><br />
\parfillskip=\hsize<br />
\advance\parfillskip by -1.5\parindent<br />
\advance\parfillskip by 0pt minus \parfillskip<br />
\advance\parfillskip by 0pt minus -1em<br />
</texcode></div>Mborkhttps://wiki.contextgarden.net/index.php?title=System_Macros/Branches_and_Decisions&diff=9005System Macros/Branches and Decisions2008-10-18T10:03:40Z<p>Mbork: /* <cmd>doifnextcharelse</cmd> */ typo</p>
<hr />
<div>< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops_and_Recursion|Loops and Recursion]] ><br />
<br />
===<cmd>doifnextcharelse</cmd>===<br />
When Pragma ADE started using TeX in the late eighties, their first experiences with programming concerned a simple shell around LaTeX. The commands probably used most at Pragma ADE are the itemizing ones. One of those initial shell commands took care of an optional argument, that enabled the specification of the item symbol to be used. Without understanding anything they were able to locate a LaTeX macro that could be used to inspect the next character.<br />
<br />
It is that macro that the ancester of the next one presented here. It executes one of two actions, dependant of the next character. Disturbing spaces and line endings, which are normally interpreted as spaces too, are skipped.<br />
<br />
<texcode><br />
\doifnextcharelse {char} {then ...} {else ...}<br />
</texcode><br />
<br />
===<cmd>doifundefined</cmd>, <cmd>doifdefined</cmd>, etc.===<br />
<br />
The standard way of testing if a macro is defined is comparing its meaning with another undefined one, aptly named <code>\undefined</code>. To guarantee correct working of this set of macros, <code>\undefined</code> may '''never''' be defined by a user!<br />
<br />
<texcode><br />
\doifundefined {string} {...}<br />
\doifdefined {string} {...}<br />
\doifundefinedelse {string} {then ...} {else ...}<br />
\doifdefinedelse {string} {then ...} {else ...}<br />
\doifalldefinedelse {commalist} {then ...} {else ...}<br />
</texcode><br />
<br />
===<cmd>doif</cmd>, <cmd>doifnot</cmd>, <cmd>doifelse</cmd>===<br />
Programming in TeX differs from programming in procedural languages like Modula. This means that one --- well, let me speek for myself --- tries to do the things in the well known way. Therefore the next set of <code>\ifthenelse</code> commands were between the first ones we needed. A few years later, the opposite became true: when programming in Modula, I sometimes miss handy things like grouping, runtime redefinition, expansion etc. While Modula taught me to structure, TeX taught me to think recursive.<br />
<br />
<texcode><br />
\doif {string1} {string2} {...}<br />
\doifnot {string1} {string2} {...}<br />
\doifelse {string1} {string2} {then ...}{else ...}<br />
</texcode><br />
<br />
These macros test string equality of the (expanded) first two arguments.<br />
<br />
===<cmd>doifempty</cmd>, <cmd>doifnotempty</cmd>, <cmd>doifemptyelse</cmd> ===<br />
We complete our set of conditionals with:<br />
<br />
<texcode><br />
\doifempty {string} {...}<br />
\doifnotempty {string} {...}<br />
\doifemptyelse {string} {then ...} {else ...}<br />
</texcode><br />
<br />
This time, the string is not expanded. Remember to expand it yourself where needed.<br />
<br />
===<cmd>doifinset</cmd>, <cmd>doifnotinset</cmd>, <cmd>doifnotinsetelse</cmd>===<br />
We can check if a string is present in a comma separated set of strings. Depending on the result, some action is taken.<br />
<br />
<texcode><br />
\doifinset {string} {string,...} {...}<br />
\doifnotinset {string} {string,...} {...}<br />
\doifinsetelse {string} {string,...} {then ...} {else ...}<br />
</texcode><br />
<br />
The second argument is the comma separated set of strings. If the first string expands 'empty', it is considered to be '''always''' in the set. The comma separated set is not expanded.<br />
<br />
===<cmd>doifcommon</cmd>, <cmd>doifnotcommon</cmd>, <cmd>doifnotcommon</cmd> ===<br />
Probably the most time consuming tests are those that test for overlap in sets of strings.<br />
<br />
<texcode><br />
\doifcommon {string,...} {string,...} {...}<br />
\doifnotcommon {string,...} {string,...} {...}<br />
\doifcommonelse {string,...} {string,...} {then ...} {else ...}<br />
</texcode><br />
<br />
===<cmd>doifsamestringselse</cmd>,<cmd>doifsamestring</cmd>,<cmd>doifnotsamestring</cmd>===<br />
<br />
The next comparison macro converts the arguments into<br />
expanded strings. This command can be used to compare for<br />
instance <code>\jobname</code> with a name stored in a macro.<br />
<br />
===<cmd>doifinstringelse</cmd>,<cmd>doifincsnameelse</cmd>===<br />
<br />
We can check for the presence of a substring in a given sequence of characters.<br />
<br />
<texcode><br />
\doifinstringelse {substring} {string} {then ...} {else ...}<br />
</texcode><br />
<br />
The next alternative proved to be upto twice as fast on tasks like checking reserved words in pretty verbatim typesetting. This is mainly due to the fact that passing (expanded) strings is much slower that passing a macro.<br />
<br />
<texcode><br />
\doifincsnameelse {substring} {\string} {then ...} {else ...}<br />
</texcode><br />
<br />
Where <code>\doifinstringelse</code> does as much expansion as possible, the latter alternative does minimal (one level) expansion.<br />
<br />
===<cmd>doifnumberelse</cmd>===<br />
The next macro executes a command depending of the outcome of a test on numerals.It checks only the first character of string.<br />
<br />
<texcode><br />
\doifnumberelse {string} {then ...} {else ...}<br />
</texcode><br />
<br />
The macro accepts <code>123</code>, <code>abc</code>, <code>{}</code>, <code>\anumber</code> and <code>\the\count...</code>.<br />
<br />
The definition of this macro is extremly ugly, or extremely beautiful, depending on how you feel about TeX macro expansion. It is the first of only a few that will actually appear in this series of articles, I promise.<br />
<br />
<texcode><br />
\long\def\doifnumberelse#1%<br />
{\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space<br />
\expandafter\secondoftwoarguments<br />
\else<br />
\expandafter\firstoftwoarguments<br />
\fi}<br />
</texcode><br />
<br />
===<cmd>doifassignmentelse</cmd>===<br />
<br />
A lot of ConTeXt commands take optional arguments, for<br />
instance:<br />
<br />
<texcode><br />
\dothisorthat[alfa,beta]<br />
\dothisorthat[first=foo,second=bar]<br />
\dothisorthat[alfa,beta][first=foo,second=bar]<br />
</texcode><br />
<br />
Although a combined solution is possible, we prefer a<br />
seperation. The next command takes care of propper<br />
handling of such multi-faced commands.<br />
<br />
<texcode><br />
\doifassignmentelse {...} {then ...} {else ...}<br />
</texcode><br />
<br />
<br />
< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops and Recursion|Loops & Recursion]] ><br />
<br />
[[Category:System Macros]]<br />
[[Category:ConTeXt programming]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=System_Macros/Branches_and_Decisions&diff=9004System Macros/Branches and Decisions2008-10-18T10:03:26Z<p>Mbork: /* <cmd>doifundefined</cmd>, <cmd>doifdefined</cmd>, etc. */ typo</p>
<hr />
<div>< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops_and_Recursion|Loops and Recursion]] ><br />
<br />
===<cmd>doifnextcharelse</cmd>===<br />
When Pragma ADE started using TeX in the late eighties, their first experiences with programming concerned a simple shell around LaTeX. The commands probably used most at Pragma ADE are the itemizing ones. One of those initial shell commands took care of an optional argument, that enabled the specification of the item symbol to be sued. Without understanding anything they were able to locate a LaTeX macro that could be used to inspect the next character.<br />
<br />
It is that macro that the ancester of the next one presented here. It executes one of two actions, dependant of the next character. Disturbing spaces and line endings, which are normally interpreted as spaces too, are skipped.<br />
<br />
<texcode><br />
\doifnextcharelse {char} {then ...} {else ...}<br />
</texcode><br />
<br />
===<cmd>doifundefined</cmd>, <cmd>doifdefined</cmd>, etc.===<br />
<br />
The standard way of testing if a macro is defined is comparing its meaning with another undefined one, aptly named <code>\undefined</code>. To guarantee correct working of this set of macros, <code>\undefined</code> may '''never''' be defined by a user!<br />
<br />
<texcode><br />
\doifundefined {string} {...}<br />
\doifdefined {string} {...}<br />
\doifundefinedelse {string} {then ...} {else ...}<br />
\doifdefinedelse {string} {then ...} {else ...}<br />
\doifalldefinedelse {commalist} {then ...} {else ...}<br />
</texcode><br />
<br />
===<cmd>doif</cmd>, <cmd>doifnot</cmd>, <cmd>doifelse</cmd>===<br />
Programming in TeX differs from programming in procedural languages like Modula. This means that one --- well, let me speek for myself --- tries to do the things in the well known way. Therefore the next set of <code>\ifthenelse</code> commands were between the first ones we needed. A few years later, the opposite became true: when programming in Modula, I sometimes miss handy things like grouping, runtime redefinition, expansion etc. While Modula taught me to structure, TeX taught me to think recursive.<br />
<br />
<texcode><br />
\doif {string1} {string2} {...}<br />
\doifnot {string1} {string2} {...}<br />
\doifelse {string1} {string2} {then ...}{else ...}<br />
</texcode><br />
<br />
These macros test string equality of the (expanded) first two arguments.<br />
<br />
===<cmd>doifempty</cmd>, <cmd>doifnotempty</cmd>, <cmd>doifemptyelse</cmd> ===<br />
We complete our set of conditionals with:<br />
<br />
<texcode><br />
\doifempty {string} {...}<br />
\doifnotempty {string} {...}<br />
\doifemptyelse {string} {then ...} {else ...}<br />
</texcode><br />
<br />
This time, the string is not expanded. Remember to expand it yourself where needed.<br />
<br />
===<cmd>doifinset</cmd>, <cmd>doifnotinset</cmd>, <cmd>doifnotinsetelse</cmd>===<br />
We can check if a string is present in a comma separated set of strings. Depending on the result, some action is taken.<br />
<br />
<texcode><br />
\doifinset {string} {string,...} {...}<br />
\doifnotinset {string} {string,...} {...}<br />
\doifinsetelse {string} {string,...} {then ...} {else ...}<br />
</texcode><br />
<br />
The second argument is the comma separated set of strings. If the first string expands 'empty', it is considered to be '''always''' in the set. The comma separated set is not expanded.<br />
<br />
===<cmd>doifcommon</cmd>, <cmd>doifnotcommon</cmd>, <cmd>doifnotcommon</cmd> ===<br />
Probably the most time consuming tests are those that test for overlap in sets of strings.<br />
<br />
<texcode><br />
\doifcommon {string,...} {string,...} {...}<br />
\doifnotcommon {string,...} {string,...} {...}<br />
\doifcommonelse {string,...} {string,...} {then ...} {else ...}<br />
</texcode><br />
<br />
===<cmd>doifsamestringselse</cmd>,<cmd>doifsamestring</cmd>,<cmd>doifnotsamestring</cmd>===<br />
<br />
The next comparison macro converts the arguments into<br />
expanded strings. This command can be used to compare for<br />
instance <code>\jobname</code> with a name stored in a macro.<br />
<br />
===<cmd>doifinstringelse</cmd>,<cmd>doifincsnameelse</cmd>===<br />
<br />
We can check for the presence of a substring in a given sequence of characters.<br />
<br />
<texcode><br />
\doifinstringelse {substring} {string} {then ...} {else ...}<br />
</texcode><br />
<br />
The next alternative proved to be upto twice as fast on tasks like checking reserved words in pretty verbatim typesetting. This is mainly due to the fact that passing (expanded) strings is much slower that passing a macro.<br />
<br />
<texcode><br />
\doifincsnameelse {substring} {\string} {then ...} {else ...}<br />
</texcode><br />
<br />
Where <code>\doifinstringelse</code> does as much expansion as possible, the latter alternative does minimal (one level) expansion.<br />
<br />
===<cmd>doifnumberelse</cmd>===<br />
The next macro executes a command depending of the outcome of a test on numerals.It checks only the first character of string.<br />
<br />
<texcode><br />
\doifnumberelse {string} {then ...} {else ...}<br />
</texcode><br />
<br />
The macro accepts <code>123</code>, <code>abc</code>, <code>{}</code>, <code>\anumber</code> and <code>\the\count...</code>.<br />
<br />
The definition of this macro is extremly ugly, or extremely beautiful, depending on how you feel about TeX macro expansion. It is the first of only a few that will actually appear in this series of articles, I promise.<br />
<br />
<texcode><br />
\long\def\doifnumberelse#1%<br />
{\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space<br />
\expandafter\secondoftwoarguments<br />
\else<br />
\expandafter\firstoftwoarguments<br />
\fi}<br />
</texcode><br />
<br />
===<cmd>doifassignmentelse</cmd>===<br />
<br />
A lot of ConTeXt commands take optional arguments, for<br />
instance:<br />
<br />
<texcode><br />
\dothisorthat[alfa,beta]<br />
\dothisorthat[first=foo,second=bar]<br />
\dothisorthat[alfa,beta][first=foo,second=bar]<br />
</texcode><br />
<br />
Although a combined solution is possible, we prefer a<br />
seperation. The next command takes care of propper<br />
handling of such multi-faced commands.<br />
<br />
<texcode><br />
\doifassignmentelse {...} {then ...} {else ...}<br />
</texcode><br />
<br />
<br />
< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops and Recursion|Loops & Recursion]] ><br />
<br />
[[Category:System Macros]]<br />
[[Category:ConTeXt programming]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Math&diff=8974Math2008-10-10T10:32:07Z<p>Mbork: /* Math Fonts */ blackboard bold added</p>
<hr />
<div>< [[Main Page]] | [[Math with newmat]] | [[MathML]] | [[Math_structures]]><br />
<br />
== Introduction ==<br />
TeX was designed for ease of typesetting books that contained mathematics. As ConTeXt is built on top of TeX, it inherits all those features. In addition to these, ConTeXt adds lot of macros to make the typesetting of mathematics easier.<br />
<br />
There are two kind of '''math modes''' --- inline math and display math. Mathematical expressions that are written with the running text are called inline math; while mathematical expressions that break the flow of the text (such as formulas or equations) are called display math. TeX takes care of proper spacing around expressions and provides macros to typeset most mathematical constructs.<br />
Complicated expressions can be built by working in steps---break down the expression into sub-expressions, build the sub-expressions and then combine them to get the complicated expression.<br />
<br />
The basics of typesetting math in ConTeXt is explained here. <br />
<br />
=== Note to Plain TeX Users ===<br />
ConTeXt is plain TeX compatible. So, if you have any old document written in plain TeX, it will work with ConTeXt. This does not mean that you will get pixel by pixel identical output with ConTeXt. For inline math, everything that you learnt for plain TeX is also true for ConTeXt. However, display math is significantly different. '''Do not use <code>$$ .... $$</code>''' to write display math formulas in ConTeXt, since you will not get the correct spacing around the formulas. Instead use <br />
<br />
<texcode><br />
\startformula ... \stopformula<br />
</texcode><br />
<br />
See [[Math/Display]] for more details on how to use display math in ConTeXt.<br />
<br />
=== Note to AMSTeX/LaTeX Users ===<br />
ConTeXt offers almost all the features that are present in AMSTeX and LaTeX. However, ConTeXt syntax is different. See this [http://dl.contextgarden.net/myway/context-latex-math.pdf My Way] for how to 'translate' from amsmath syntax to ConTeXt syntax. [[LaTeX_Math_in_ConTeXt]] gives some brief ideas on how to get the LaTeX syntax to run in ConTeXt.<br />
<br />
== The details ==<br />
<br />
=== The basics ===<br />
* [[Math/basic | How to input math]] (binary relations, greek letters, subscripts and superscripts)<br />
* Accents<br />
* underbrace, overbrace<br />
* Fractions, Binomials, genfrac, continued fractions.<br />
* Delimiters (big, bigg, left, middle, right)<br />
* Integrals and Sums<br />
* ([[Math/functions|Log like]]) functions<br />
* dots<br />
* cases, matrices, bordermatrix<br />
* Arrows (see [http://dl.contextgarden.net/myway/matharrows.pdf Math Arrows])<br />
* [[Vectors]]<br />
<br />
=== Display Math ===<br />
* [[Math/Display | Formula, formula number]]<br />
* [[Multiline equations]] (see [http://dl.contextgarden.net/myway/mathalign.pdf Using \mathalign and friends])<br />
* Math sub-alignment<br />
<br />
==Math [[Fonts]]==<br />
* [[Bold Math]]<br />
* [http://homepage.mac.com/atl/tex/EulerContext.pdf Euler in ConTeXt (using Euler math font)] by Adam Lindsay<br />
* [[rsfs]] Using Ralph Smith's Formal Script<br />
* [[Doublestroke]] Using Double Stroke Font<br />
* [[Blackboard bold]]<br />
* [[Product integral]] symbol<br />
<br />
== Other Methods ==<br />
* There are two different math modules on [http://dante.ctan.org/tex-archive/macros/context/contrib/maths/ CTAN], [[Math with nath|nath]] and [[Math with amsl|amsl]]. And there's a [[Math with newmat|new math]] module in the distribution.<br />
* Context now has inbuilt support for [[Multiline equations]]<br />
* It is also possible to use most [[LaTeX Math in ConTeXt|LaTeX equations in ConTeXt]] with a relatively small set of supporting definitions.<br />
* The "native" ConTeXt way of math is [[MathML]], an application of [[XML]] - rather verbose but mighty.<br />
<br />
==Science==<br />
* Esp. for physics there’s the [[Units]] module.<br />
* Additions to [[MathML]] are PhysML and ChemML.<br />
* [[Chemistry]]<br />
* There's a module for chemical structure formulae: [[Chemistry|PPCHTeX]] (works also with LaTeX).<br />
<br />
==Number Formatting==<br />
There's a special command, <cmd>digits</cmd>, and a own manual about formatting numbers, see [http://www.pragma-ade.com/general/magazines/mag-0003.pdf Pasting digits together]<br />
<br />
<br />
[[Category:Math]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Blackboard_bold&diff=8972Blackboard bold2008-10-08T11:58:21Z<p>Mbork: Page creation</p>
<hr />
<div>'''Blackboard bold''' is probably the most common way of denoting the "standard" number sets: the natural numbers, the integers and so on. In AMS-LaTeX, you use the <code>\mathbb{...}</code> command to obtain them; the ConTeXt way is the <code>\blackboard{...}</code> command. Also, the following commands are defined:<br />
* <code>\naturalnumbers</code><br />
* <code>\integers</code><br />
* <code>\rationals</code><br />
* <code>\reals</code><br />
* <code>\complexes</code><br />
<br />
as well as <code>\primes</code> for blackboard bold P.<br />
<br />
See also [[Doublestroke]] for an alternative to the msbm font.<br />
<br />
[[Category:Math]]<br />
[[Category:Fonts]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Doublestroke&diff=8971Doublestroke2008-10-08T11:49:42Z<p>Mbork: Created a link to "Blackboard bold]]</p>
<hr />
<div>< [[Main Page]] | [[Math with newmat]] | [[MathML]] | [[Multiline equations]]><br />
<br />
== Using double stroke font ==<br />
<br />
Computer Modern and Latin Modern use the msbm font family for [[Blackboard bold|blackboard bold]]. msbm look very dull and usually black board bold should be avoided in math. However, there are certain cases where one needs something ''fancier'' than math bold. The [http://ctan.org/tex-archive/fonts/doublestroke doublestroke fonts] offer one such alternative. This is how these can be used with ConTeXt. Note that since we are using doublestroke fonts as the blackboard font, there is really no need to use the blackboard fonts separately. So, the mb math family is reused.<br />
<br />
<context source="yes"><br />
<br />
\loadmapfile[dstroke.map]<br />
<br />
\starttypescript [math] [modern,computer-modern,latin-modern,ams] [size]<br />
\definebodyfont [17.3pt,14.4pt,12pt][mm]<br />
[mb=dsrom12 sa 1]<br />
\definebodyfont [11pt,10pt,9pt] [mm]<br />
[mb=dsrom10 sa 1]<br />
\definebodyfont [8pt,7pt,6pt,5pt,4pt] [mm]<br />
[mb=dsrom8 sa 1]<br />
\stoptypescript<br />
<br />
\definetypeface [modern] [mm] [math] [modern] [ams] [encoding=texnansi]<br />
<br />
\setupbodyfont[reset,modern,10pt]<br />
<br />
<br />
\definefamilysynonym [default] [doublestroke] [mb]<br />
<br />
\def\dstroke {\fam\purefamily {doublestroke}}<br />
<br />
\def\doublestroke#1{{\dstroke#1}}<br />
<br />
The expectation of a random variable $X$ is given by $\doublestroke{E}\{X\}$. <br />
<br />
The indicator function is given by<br />
\startformula<br />
\doublestroke{1}(x=a) = \startcases<br />
\NC 1 \NC if $x=a$ \NR<br />
\NC 0 \NC if $x \ne a$ \NR<br />
\stopcases<br />
\stopformula<br />
<br />
<br />
</context><br />
<br />
<br />
[[Category:Math]]<br />
[[Category:Fonts]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Old:_A_Beginner%27s_Guide_to_Using_Fonts_in_Mark_IV&diff=8931Old: A Beginner's Guide to Using Fonts in Mark IV2008-09-22T14:21:06Z<p>Mbork: removed redundant space</p>
<hr />
<div>This page tries to describe how to use preinstalled (with the [[ConTeXt Minimals]]) typescripts with [[Mark IV|ConTeXt MkIV]]. It does ''not'' explain how this works; for this, consult [http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf|the new manual chapter on fonts] or documents cited in [[Fonts]]. (These things are not easy. You have been warned!)<br />
<br />
Note that this page is ''in preparation''---these things are difficult and I don't understand them fully. Some of the fonts mentioned below don't work for me; I hope to clear this soon.<br />
<br />
I assume here that we have a working ConTeXt Mark IV installation, for example ConTeXt Minimals. In particular, we have LM fonts, the TeX Gyre collection and some other ones.<br />
<br />
== Available typescripts ==<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).</div>Mborkhttps://wiki.contextgarden.net/index.php?title=French_spacing&diff=8896French spacing2008-09-02T22:41:57Z<p>Mbork: New page: In English, the space after some punctuation (most notably after period) is wider than a usual one; this is a standard behaviour of ConTeXt when typesetting in English. If you want to dis...</p>
<hr />
<div>In English, the space after some punctuation (most notably after period) is wider than a usual one; this is a standard behaviour of ConTeXt when typesetting in English. If you want to disable it, in plain TeX or LaTeX you would call <code>\frenchspacing</code>. In ConTeXt, you may say <texcode>\setuplanguage[en][spacing=packed]</texcode> instead.</div>Mborkhttps://wiki.contextgarden.net/index.php?title=From_LaTeX_to_ConTeXt&diff=8895From LaTeX to ConTeXt2008-09-02T22:39:09Z<p>Mbork: /* Text Formatting */</p>
<hr />
<div>< [[Main Page]] ><br />
<br />
General hints for converting from LaTeX to Context can be found in the [http://www.berenddeboer.net/tex/LaTeX2ConTeXt.pdf LaTeX in proper ConTeXt] manual, by [http://www.berenddeboer.net/ Berend de Boer]<br />
<br />
This page offers specific advice on a number of special things that you may be doing with LaTeX, but are not so obvious to do with ConTeXt.<br />
<br />
=== Document and Page Layout ===<br />
* [[Document Titles]]: Title blocks, as in the standard LaTeX article.<br />
* [[LaTeX Thanks|The thanks command]] adds footnoted information, usually to author blocks.<br />
* [[Article Abstracts]]: Abstracts from the standard LaTeX article or report.<br />
* [[KOMA-scrartcl Type Area]]: An interesting automated type-area setup.<br />
* [[Unnumbered Sections]]: Section and subsection headings without numbers.<br />
* [[Flush bottom]]<br />
* [[Vertically Centered Boxes]]: Centering parboxes and tables in a line of text.<br />
<br />
=== Text Formatting ===<br />
* [[Bold small caps]]<br />
* [[Bold typewriter]]: Bold versions of the <tt>cmtt</tt> family of monospaced fonts.<br />
* [[Verbatim with line breaks]]<br />
* [[ISO-8859-15]]: Using the ISO Latin-9 (Western European) character encoding for input.<br />
* [[Description]]<br />
* The microtype package has its analogue in [[Protrusion]]<br />
* So-called (by plain TeX and LaTeX) [[French spacing]]<br />
<br />
=== Programming ===<br />
* [[Commands with optional arguments]]<br />
<br />
=== Document Metadata ===<br />
* [[PDF-strings]]<br />
<br />
=== Math ===<br />
<br />
* [[LaTeX Math in ConTeXt]]<br />
<br />
<br />
=== Copy-Paste text between LaTeX and ConTeXt ===<br />
<br />
It is sometimes useful to have the same source for a latex document and context presentation (or context document and latex presentation). However, the commands used by both are very different. Can someone describe some definations in context that implement the core functionality of latex commands like \section et al, \textbf et al, \bfseries et al and \begin \end pairs?<br />
{{Howto}}<br />
<br />
''<code>\section</code> works the same way as in LaTeX, for mathematics take a look into [[LaTeX Math in ConTeXt]], use <code>\bf</code> instead of <code>\textbf</code> for both LaTeX and ConTeXt (or <code>\def\textbf#1{{\bf #1}}</code>) and as a general rule: use as many plain TeX macros as possible instead of LaTeX-specific macros. <code>\begin ... \end</code> only works for math as far as I know. See also other documents listed above or ask on the mailing list.''<br />
<br />
<!--<br />
* [[LaTeX&ConTeXt/Introduction|Introduction]]<br />
* [[LaTeX&ConTeXt/Basic Latex|Basic Latex]]<br />
* [[LaTeX&ConTeXt/Math Environments|Math Environments]]<br />
Also, many of the macros on the [[LaTeX Math in ConTeXt]] page are equally useful in ConTeXt formulas.<br />
--><br />
<br />
<br />
A Vietnamese version of <i>LaTeX in proper ConTeXt</i> is available at [http://vnoss.org/docs/LaTeX2ConTeXt-vi.pdf VnOSS].<br />
<br />
<br />
== Functionality of Latex Packages in Context ===<br />
* [[Latex Packages]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Old:_A_Beginner%27s_Guide_to_Using_Fonts_in_Mark_IV&diff=8883Old: A Beginner's Guide to Using Fonts in Mark IV2008-08-28T10:55:02Z<p>Mbork: deleted the sentence about type-otf; some more explanation at the beginning</p>
<hr />
<div>This page tries to describe how to use preinstalled (with the [[ConTeXt Minimals]]) typescripts with [[Mark IV|ConTeXt MkIV]]. It does ''not'' explain how this works; for this, consult [http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf|the new manual chapter on fonts] or documents cited in [[Fonts]]. (These things are not easy. You have been warned!)<br />
<br />
Note that this page is ''in preparation''---these things are difficult and I don't understand them fully. Some of the fonts mentioned below don't work for me; I hope to clear this soon.<br />
<br />
I assume here that we have a working ConTeXt Mark IV installation, for example ConTeXt Minimals. In particular, we have LM fonts, the TeX Gyre collection and some other ones.<br />
<br />
== Available typescripts ==<br />
* Latin Modern (the default)<br />
* Postscript (typescript name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif) ('''didn't work for me!''')<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Concrete (ts name: <code>concrete</code>; only serif) ('''didn't work for me!''')<br />
* Kurier (ts name: <code>kurier</code>) ('''didn't work for me!''')<br />
* Antykwa Półtawskiego ('''didn't work for me!''')<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, turns Heros as sans)<br />
* Heros (ts name: <code>helvetica</code>; only sans; needs <code>\ss</code> to be turned on)<br />
* Bonum (ts name: <code>bookman</code>; only serif) ('''didn't work for me!''')<br />
* Schola (ts name: <code>schoolbook</code>) ('''didn't work for me!''')<br />
* Adventor ('''didn't work for me!''')<br />
* Cursor (ts name: <code>courier</code>; don't confuse with Kursor!) ('''didn't work for me!''')<br />
* Chorus (ts name: <code>chancery</code>) ('''didn't work for me!''')<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).</div>Mborkhttps://wiki.contextgarden.net/index.php?title=User:Mbork&diff=8881User:Mbork2008-08-28T09:41:03Z<p>Mbork: My page</p>
<hr />
<div>My name is Marcin Borkowski. Here is the link to my personal webpage (mostly in Polish, sorry;)), in case you are curious about me: http://atos.wmid.amu.edu.pl/~mbork/cgi-bin/wiki.cgi/About_me</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=8880Fonts - Old Content2008-08-28T09:37:40Z<p>Mbork: added a "beginner's guide..."</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
Font handling in ConTeXt is “strange” for LaTeX users. It’s a system of abstraction and aliases, complex and mighty… But there’s help. If you happen to use [[XeTeX]], then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]). If you want to keep using [[pdfTeX]], read on:<br />
<br />
* '''The ConTeXt way of using fonts are [[TypeScripts]].'''<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.nl/fonttest.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://homepage.mac.com/atl/tex/ Adam Lindsay's page] focuses on typography (OpenType, Unicode etc.), esp. on MacOS X<br />
* [http://home.salamander.com/~wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[otfinstall|otfinst - a sample ruby script for using OpenType fonts in ConTeXt]]<br />
* [[Understanding how fonts work in ConTeXt]]<br />
* [[A Beginner's Guide to Using Fonts in Mark IV]]<br />
<br />
=Basic Hints=<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
=Configuration=<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee about [http://havenrock.com/textips/bookfonts.html virtual fonts]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
= Available Free Fonts =<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= NonFree Font Support =<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
=Hints by Language=<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabic and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
[[Category:Fonts]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Old:_A_Beginner%27s_Guide_to_Using_Fonts_in_Mark_IV&diff=8879Old: A Beginner's Guide to Using Fonts in Mark IV2008-08-28T09:36:36Z<p>Mbork: How to use preinstalled fonts in MkIV in an easy way</p>
<hr />
<div>This page tries to describe how to use different typescripts with ConTeXt MkIV. It does ''not'' explain how this works; for this, consult [http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf|the new manual chapter on fonts] or documents cited in [[Fonts]]. (These things are not easy. You have been warned!)<br />
<br />
Note that this page is ''in preparation''---these things are difficult and I don't understand them fully. Some of the fonts mentioned below don't work for me; I hope to clear this soon.<br />
<br />
I assume here that we have a working ConTeXt Mark IV installation, for example [[ConTeXt Minimals]]. In particular, we have LM fonts, the TeX Gyre collection and some other ones.<br />
<br />
== Available typescripts ==<br />
* Latin Modern (the default)<br />
* Postscript (typescript name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif) ('''didn't work for me!''')<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Concrete (ts name: <code>concrete</code>; only serif) ('''didn't work for me!''')<br />
* Kurier (ts name: <code>kurier</code>) ('''didn't work for me!''')<br />
* Antykwa Półtawskiego ('''didn't work for me!''')<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, turns Heros as sans)<br />
* Heros (ts name: <code>helvetica</code>; only sans; needs <code>\ss</code> to be turned on)<br />
* Bonum (ts name: <code>bookman</code>; only serif) ('''didn't work for me!''')<br />
* Schola (ts name: <code>schoolbook</code>) ('''didn't work for me!''')<br />
* Adventor ('''didn't work for me!''')<br />
* Cursor (ts name: <code>courier</code>; don't confuse with Kursor!) ('''didn't work for me!''')<br />
* Chorus (ts name: <code>chancery</code>) ('''didn't work for me!''')<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescriptfile[type-otf]<br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line loads the file type-otf.tex with necessary definitions. The second one seems to order ConTeXt to "install" the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Understanding_how_fonts_work_in_ConTeXt_-_Old_Content&diff=8877Understanding how fonts work in ConTeXt - Old Content2008-08-28T08:38:52Z<p>Mbork: A link to a page on fonts with MkIV for beginners</p>
<hr />
<div>At the beginning, this page said:<br />
<br />
::This page is a draft (currently kind of a personal notebook) which I hope will evolve into some kind of ::beginner's guide to understanding what's going on in ConTeXt as far as fonts are concerned. Currently I ::can hardly understand anything about it, but I keep on asking on the mailing list;) ::(http://archive.contextgarden.net/thread/20080304.225545.5990b35d.en.html) and I'm going to post the ::answers here.<br />
<br />
Now things have changed; I dropped the topic (I guess it was a bit too difficult for me). I'm leaving the rest of this page unchanged in case it is helpful for someone (below the next paragraph).<br />
<br />
Recently, two things have changed. First, a [http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf|new chapter on fonts] for the manual has been written; it is easier to read than the previous one, although still obscure in some places (at least for me). Second (and more important), I asked another question on the mailing list, concerning TeX-Gyre support in [[Mark IV]]. I think the answer deserves a new wiki page (or am I wrong?), so I post it here: [[A Beginner's Guide to Using Fonts in Mark IV]]. The idea is that the page says ''how'' to easily use fonts (or rather typescripts) in Mark IV, so that you just take a ready-to-use recipe from there and paste it into your document.<br />
<br />
Most of the following material comes from the answers I got on the mailing list and/or the documentation (mfonts.pdf). Since crediting people for each and every answer would be cumbersome, I'd like to thank here all of you that helped me understand ConTeXt (especially Hans, of course).<br />
<br />
Please correct any errors you spot on this page! I'm a ConTeXt newbie and write here what I guess is right, but I might as well be wrong. Don't rely on any information marked with a question sign! (Still, I hope I'll get it more or less right...)<br />
<br />
--[[User:Mbork|Mbork]] 15:28, 5 March 2008 (CET)<br />
<br />
== How to typeset in, say, Palatino ==<br />
<br />
<context source="yes"><br />
\usetypescriptfile[type-gyr]<br />
\usetypescript[palatino][qx]<br />
\setupbodyfont[palatino,10pt]<br />
<br />
\starttext<br />
Hello world, I'm Palatino!<br />
\stoptext<br />
</context><br />
<br />
<cmd>usetypescriptfile</cmd> loads a given file ([[source:type-gyr.tex|type-gyr.tex]] in this case). This file usually contains definitions of ''typescripts''. The core typescript files (such as [[source:type-tmf.tex|type-tmf.tex]], [[source:type-one.tex|type-one.tex]] in pdTeX or [[source:type-otf.tex|type-otf.tex]] in LuaTeX/XeTeX, ...) are already preloaded, so you would usually need this only to load your own definitions. <code>\usetypescriptfile[type-gyr]</code> will soon become obsolete (TeX Gyre will be the default).<br />
<br />
<cmd>usetypescript</cmd> kind of "selects" (?) the specified typescript from that file. It takes up to three parametres and their rôles are still cryptic to me...<br />
<br />
== Defining typescripts ==<br />
One of the keys for defining typescripts is clever usage of the <cmd>definefontsynonym</cmd> command. It takes 2 or three parameters. Example from mfonts.pdf:<br />
<texcode>\definefontsynonym[Serif][Times-Roman]<br />
\definefontsynonym[Times-Roman][tir][encoding=texnansi]</texcode><br />
<br />
The first case - with two arguments - makes <code>Serif</code> kind of an "alias" (?) for <code>Times-Roman</code>. Both names are completely independent of name of the font file. This is clever, since instead of fiddling with font file names one can say <code>Times-Roman</code> and just don't care where it resides on tbe disk. Or even better: one can say <code>Serif</code> and don't care whether the final version of the document will use Times, Palatino or Latin Modern.<br />
<br />
The second one makes <code>Times-Roman</code> an "alias" (?) for font stored in the file called <code>tir</code> (probably with some extension?). The third argument specifies the encoding (it might be qx, for instance, or something else) and possibly another options, like <code>features=smallcaps</code> (for opentype fonts). Encoding is used by pdfTeX only - XeTeX and LuaTeX both use Unicode (Mojca - thanks for this point!). Other possibilities include <code>mapping</code> and <code>handling</code>, but don't ask me about these;).</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Understanding_how_fonts_work_in_ConTeXt_-_Old_Content&diff=8478Understanding how fonts work in ConTeXt - Old Content2008-03-05T14:28:06Z<p>Mbork: some typescripts mumbo-jumbo</p>
<hr />
<div>This page is a draft (currently kind of a personal notebook) which I hope will evolve into some kind of beginner's guide to understanding what's going on in ConTeXt as far as fonts are concerned. Currently I can hardly understand anything about it, but I keep on asking on the mailing list;) (http://archive.contextgarden.net/thread/20080304.225545.5990b35d.en.html) and I'm going to post the answers here.<br />
<br />
Most of the following material comes from the answers I got on the mailing list and/or the documentation (mfonts.pdf). Since crediting people for each and every answer would be cumbersome, I'd like to thank here all of you that helped me understand ConTeXt (especially Hans, of course).<br />
<br />
Please correct any errors you spot on this page! I'm a ConTeXt newbie and write here what I guess is right, but I might as well be wrong. Don't rely on any information marked with a question sign! (Still, I hope I'll get it more or less right...)<br />
<br />
--[[User:Mbork|Mbork]] 15:28, 5 March 2008 (CET)<br />
<br />
== How to typeset in, say, Palatino ==<br />
<br />
<context source="yes"><br />
\usetypescriptfile[type-gyr]<br />
\usetypescript[palatino][qx]<br />
\setupbodyfont[palatino,10pt]<br />
<br />
\starttext<br />
Hello world, I'm Palatino!<br />
\stoptext<br />
</context><br />
<br />
<cmd>usetypescriptfile</cmd> loads a given file (<code>type-gyr.tex</code> in this case). This file usually contains definitions of ''typescripts''. <cmd>usetypescript</cmd> kind of "selects" (?) the specified typescript from that file. It takes up to three parametres and their rôles are still cryptic to me...<br />
<br />
== Defining typescripts ==<br />
One of the keys for defining typescripts is clever usage of the <cmd>definefontsynonym</cmd> command. It takes 2 or three parameters. Example from mfonts.pdf:<br />
<texcode>\definefontsynonym[Serif][Times-Roman]<br />
\definefontsynonym[Times-Roman][tir][encoding=texnansi]</texcode><br />
<br />
The first case - with two arguments - makes <code>Serif</code> kind of an "alias" (?) for <code>Times-Roman</code>. Both names are completely independent of name of the font file. This is clever, since instead of fiddling with font file names one can say <code>Times-Roman</code> and just don't care where it resides on tbe disk. Or even better: one can say <code>Serif</code> and don't care whether the final version of the document will use Times, Palatino or Latin Modern.<br />
<br />
The second one makes <code>Times-Roman</code> an "alias" (?) for font stored in the file called <code>tir</code> (probably with some extension?). The third argument specifies the encoding (it might be qx, for instance, or something else) and possibly another options, like <code>features=smallcaps</code> (for opentype fonts). Encoding is used by pdfTeX only - XeTeX and LuaTeX both use Unicode (Mojca - thanks for this point!). Other possibilities include <code>mapping</code> and <code>handling</code>, but don't ask me about these;).</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Understanding_how_fonts_work_in_ConTeXt_-_Old_Content&diff=8477Understanding how fonts work in ConTeXt - Old Content2008-03-04T23:37:14Z<p>Mbork: using palatino</p>
<hr />
<div>This page is a draft which I hope will evolve into some kind of beginner's guide to understanding what's going on in ConTeXt as far as fonts are concerned. Currently I can hardly understand anything about it, but I keep on asking on the mailing list;) (http://archive.contextgarden.net/thread/20080304.225545.5990b35d.en.html) and I'm going to post the answers here.<br />
<br />
Most of the following material comes from the answers I got on the mailing list. Since crediting people for each and every answer would be cumbersome, I'd like to thank here all of you that helped me understand ConTeXt (especially Hans, of course). --[[User:Mbork|Mbork]] 00:37, 5 March 2008 (CET)<br />
<br />
== How to typeset in Palatino ==<br />
<br />
<context source="yes"><br />
\usetypescriptfile[type-gyr]<br />
\usetypescript[palatino][qx]<br />
\setupbodyfont[palatino,10pt]<br />
<br />
\starttext<br />
Hello world, I'm Palatino!<br />
\stoptext<br />
</context></div>Mborkhttps://wiki.contextgarden.net/index.php?title=Understanding_how_fonts_work_in_ConTeXt_-_Old_Content&diff=8476Understanding how fonts work in ConTeXt - Old Content2008-03-04T23:19:14Z<p>Mbork: page initialization</p>
<hr />
<div>This page is a draft which I hope will evolve into some kind of beginner's guide to understanding what's going on in ConTeXt as far as fonts are concerned. Currently I can hardly understand anything about it, but I keep on asking on the mailing list;) and I'm going to post the answers here. [[User:Mbork|Mbork]] 00:19, 5 March 2008 (CET)</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=8475Fonts - Old Content2008-03-04T23:17:05Z<p>Mbork: understanding how the fonts work in ConTeXt</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
Font handling in ConTeXt is “strange” for LaTeX users. It’s a system of abstraction and aliases, complex and mighty… But there’s help. If you happen to use [[XeTeX]], then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]). If you want to keep using [[pdfTeX]], read on:<br />
<br />
* '''The ConTeXt way of using fonts are [[TypeScripts]].'''<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.nl/fonttest.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://homepage.mac.com/atl/tex/ Adam Lindsay's page] focuses on typography (OpenType, Unicode etc.), esp. on MacOS X<br />
* [http://home.salamander.com/~wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[otfinstall|otfinst - a sample ruby script for using OpenType fonts in ConTeXt]]<br />
* [[Understanding how fonts work in ConTeXt]]<br />
<br />
=Basic Hints=<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
=Configuration=<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee about [http://havenrock.com/textips/bookfonts.html virtual fonts]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
= Available Free Fonts =<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= NonFree Font Support =<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
=Hints by Language=<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabian and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
[[Category:Fonts]]</div>Mborkhttps://wiki.contextgarden.net/index.php?title=Including_pages_from_PDF_documents&diff=8471Including pages from PDF documents2008-03-01T11:38:31Z<p>Mbork: typo</p>
<hr />
<div>[http://source.contextgarden.net/tex/context/base/page-imp.tex page-imp.tex] defines some handy macros for handling import of existing PDF documents.<br />
<br />
To include only a specific page from a PDF document you can write<br />
<texcode><br />
\externalfigure[file.pdf][page=1,width=...]<br />
</texcode><br />
<br />
or<br />
<br />
<texcode><br />
\startTEXpage<br />
\externalfigure[file.pdf][page=1,width=...]<br />
\stopTEXpage<br />
</texcode><br />
which is equal to<br />
<texcode><br />
\startpagefigure[file.pdf][page=1,...]\stoppagefigure<br />
</texcode><br />
<br />
This one inserts the first 30 pages of the document and adds a blank page after the first and the third page.<br />
<br />
<texcode><br />
\insertpages[file.pdf][1,3][n=30,width=18cm]<br />
</texcode><br />
<br />
If you want to insert a couple of pages use this:<br />
<br />
<texcode><br />
\filterpages[file.pdf][1,3,4:6][width=18cm]<br />
</texcode><br />
to insert pages 1, 3, 4, 5 and 6 or<br />
<texcode><br />
\filterpages[file.pdf][even][width=18cm] % even/odd<br />
</texcode><br />
to insert even/odd pages up to the page 30. (See also Taco's hack in [[Processing Lists]] for handling ranges of numbers or [http://archive.contextgarden.net/thread/20050704.222033.bbadb15a.en.html this] thread in the mailing list.)<br />
<br />
Yet another alternative is<br />
<texcode><br />
\copypages[file.pdf][n=30,scale=950]<br />
</texcode><br />
to insert the first 30 pages scaled down to 95%.<br />
<br />
== Printing Slides from a presentation ==<br />
<br />
If you want to make a 2*3 matrix from all the slides in the document you can use the following example:<br />
<br />
<texcode><br />
\setuppapersize<br />
[A4][A4] % or [A4,landscape][A4,landscape]<br />
<br />
\setuplayout<br />
[header=0pt,footer=1cm,<br />
backspace=1cm,topspace=1cm,<br />
width=middle,height=middle]<br />
<br />
\setupfootertexts<br />
[presentation---\currentdate\space---\space\pagenumber]<br />
<br />
\starttext<br />
\combinepages[slides][nx=2,ny=3,frame=on]<br />
\stoptext<br />
</texcode><br />
<br />
== Slicing the pages ==<br />
<br />
The opposite of combining the pages together is to slice them in pieces.<br />
<br />
This will make 3*3 pages out of your document (well, it depends on proportions).<br />
<br />
<texcode><br />
\starttext<br />
\slicepages[slice1.pdf][n=3]<br />
\stoptext<br />
</texcode><br />
<br />
== Adding comments to pages ==<br />
<br />
<texcode><br />
\setuppagecomment[state=start,location=right]<br />
<br />
\startpagecomment<br />
\input knuth<br />
\stoppagecomment<br />
</texcode><br />
<br />
{{todo|prepare a graphics for each example}}<br />
<br />
[[Category:PDF]]</div>Mbork