Difference between revisions of "Modes"

From Wiki
Jump to navigation Jump to search
(added font example)
m (Minor cleanup.)
Line 1: Line 1:
< [[The ConTeXt Way]]
+
< [[The ConTeXt Way]] | [[Inside ConTeXt]] | [[Project structure]] >
 
 
< [[Project structure]]
 
  
 
Often you'd like to publish different versions of a document, say a presentation and a handout or a student's and a teacher's version.
 
Often you'd like to publish different versions of a document, say a presentation and a handout or a student's and a teacher's version.
Line 7: Line 5:
 
ConTeXt supports such filtering with its '''modes''':
 
ConTeXt supports such filtering with its '''modes''':
  
<pre>
+
<texcode>
 
ConTeXt is a great TeX macro package.
 
ConTeXt is a great TeX macro package.
 
\startmode[handout] % The following text will only appear in the handout
 
\startmode[handout] % The following text will only appear in the handout
 
It’s based on PlainTeX like the better known LaTeX.
 
It’s based on PlainTeX like the better known LaTeX.
 
\stopmode
 
\stopmode
</pre>
+
</texcode>
  
<pre>
+
<texcode>
 
\startnotmode[print]
 
\startnotmode[print]
 
Here's a link to my homepage: \url[...]
 
Here's a link to my homepage: \url[...]
 
\stopnotmode
 
\stopnotmode
</pre>
+
</texcode>
 +
 
 +
<texcode>
 +
\doifmode[answers]{The answer to the homework is 42.}
 +
</texcode>
 +
 
 +
<texcode>
 +
\doifmodeelse[draft]{Draft Version}{Final Version}
 +
</texcode>
  
 
<tt>...mode</tt> and <tt>...notmode</tt> let you filter your content sufficient in most cases.
 
<tt>...mode</tt> and <tt>...notmode</tt> let you filter your content sufficient in most cases.
Line 54: Line 60:
  
 
And run with one of the following:
 
And run with one of the following:
 +
<pre>
 
  texexec --pdf --mode=palatino filename
 
  texexec --pdf --mode=palatino filename
 
  texexec --pdf --mode=times    filename
 
  texexec --pdf --mode=times    filename
 +
</pre>

Revision as of 06:38, 5 September 2005

< The ConTeXt Way | Inside ConTeXt | Project structure >

Often you'd like to publish different versions of a document, say a presentation and a handout or a student's and a teacher's version.

ConTeXt supports such filtering with its modes:

ConTeXt is a great TeX macro package.
\startmode[handout] % The following text will only appear in the handout
It’s based on PlainTeX like the better known LaTeX.
\stopmode
\startnotmode[print]
Here's a link to my homepage: \url[...]
\stopnotmode
\doifmode[answers]{The answer to the homework is 42.}
\doifmodeelse[draft]{Draft Version}{Final Version}

...mode and ...notmode let you filter your content sufficient in most cases. You can also give several modes like \startmode[handout,print].

Modes are also a convenient way to comment out sections (typical: "obsolete" mode).

You can typeset the different modes like:

texexec myfile --mode=handout --result=handout.pdf

You don't need the --result, but otherwise you'd get the same filename for both modes.

Modes are extremely powerful when applied to text. However, they can be applied to configuration problems as well. A user wanted to generate different versions of the same file with different fonts:

\startmode[palatino]
   \usetypescript[adobekb][8r]
   \usetypescript[palatino][8r]
   \setupbodyfont[palatino,12pt]
\stopmode

\startmode[times]
   \usetypescript[adobekb][8r]
   \usetypescript[postscript][8r]
   \setupbodyfont[postscript,12pt]
\stopmode

\starttext
\input knuth
\showfontstrip
\stoptext

And run with one of the following:

 texexec --pdf --mode=palatino filename
 texexec --pdf --mode=times    filename