Difference between revisions of "Verbatim text"
Jump to navigation
Jump to search
m (A little bit of rearrangement.) |
|||
Line 8: | Line 8: | ||
=Interesting features= | =Interesting features= | ||
+ | |||
+ | Unlike LaTeX's <code>verbatim</code> environment, ConTeXt's typing environments have quite a range of built-in options for formatting the verbatim text. | ||
+ | |||
+ | == Embedded formatting commands == | ||
+ | |||
The <tt>option=commands</tt> setting allows the usage of ConTeXt commands inside verbatim text, as in this example: | The <tt>option=commands</tt> setting allows the usage of ConTeXt commands inside verbatim text, as in this example: | ||
<texcode> | <texcode> | ||
Line 30: | Line 35: | ||
\stopC | \stopC | ||
</context> | </context> | ||
+ | |||
+ | == Tabbing == | ||
The tab character normally corresponds to one character, as can be seen above. That value can be adjusted, using the following code (available in the 2005.06.01 version and later): | The tab character normally corresponds to one character, as can be seen above. That value can be adjusted, using the following code (available in the 2005.06.01 version and later): | ||
Line 57: | Line 64: | ||
</context> | </context> | ||
− | == | + | == Syntax highlighting in color == |
− | |||
− | |||
<texcode> | <texcode> | ||
Line 106: | Line 111: | ||
</context> | </context> | ||
− | [[User:Taco|Taco]] posted this solution in the discussion on the [http://archive.contextgarden.net/message/20050825.112308.db696b94.en.html mailing list]: | + | == Defining your own set of colors == |
+ | |||
+ | Sometimes you may be not quite satisfied with the default colors used in the built-in syntax highlighting. [[User:Taco|Taco]] posted this solution in the discussion on the [http://archive.contextgarden.net/message/20050825.112308.db696b94.en.html mailing list]: | ||
<texcode> | <texcode> |
Revision as of 06:18, 28 August 2005
< Visuals | Verbatim with line breaks >
Contents
Displayed text
In-line text
Interesting features
Unlike LaTeX's verbatim
environment, ConTeXt's typing environments have quite a range of built-in options for formatting the verbatim text.
Embedded formatting commands
The option=commands setting allows the usage of ConTeXt commands inside verbatim text, as in this example:
\definetyping[C][option=commands] \startC #includeint main(){ return 0; /BTEX{\em unreachedCode;}/ETEX } \stopC
Tabbing
The tab character normally corresponds to one character, as can be seen above. That value can be adjusted, using the following code (available in the 2005.06.01 version and later):
\definetyping[C][tab=3] % for older ConTeXt versions: \chardef\spacespertab=3 \startC int func(int a){ if(a > 4) return 0; else return 10; } \stopC
Syntax highlighting in color
\setupcolors[state=start] \setuptyping[option=color] \starttext \startXML ... your XML code ... \stopXML \stoptext
Defining your own set of colors
Sometimes you may be not quite satisfied with the default colors used in the built-in syntax highlighting. Taco posted this solution in the discussion on the mailing list:
\setupcolors[state=start] \setuptyping[option=color] % define the colors to fit your document style \definecolor[MYcolorone] [r=.8,g=.5,b=.5] \definecolor[MYcolortwo] [r=.8,g=.5,b=.2] \definecolor[MYcolorthree][r=.8,g=.5,b=.8] \definecolor[MYcolorfour] [r=.8,g=.2,b=.5] % define a palete using these four colors \definepalet[MYcolors] [prettyone=MYcolorone, prettytwo=MYcolortwo, prettythree=MYcolorthree, prettyfour=MYcolorfour] % XML code will be typeset with the palette you just defined \definepalet[XMLcolorpretty] [MYcolors] % the name is magic ! \starttext \startXML ... your XML code ... \stopXML \stoptext
This results in: