Difference between revisions of "Verbatim text"

From Wiki
Jump to navigation Jump to search
m
(Clarified wording, added examples.)
Line 8: Line 8:
  
 
=Interesting features=
 
=Interesting features=
Using ConTeXt-commands inside verbatim text:
+
The <tt>option=commands</tt> setting allows the usage of ConTeXt commands inside verbatim text, as in this example:
 
<texcode>
 
<texcode>
 
\definetyping[C][option=commands]
 
\definetyping[C][option=commands]
Line 20: Line 20:
 
</texcode>
 
</texcode>
  
Adjusting size of tabulator (since 2005.06.01):
+
<context>
 +
\definetyping[C][option=commands]
 +
\startC
 +
#include <stdio.h>
 +
int main(){
 +
return 0;
 +
/BTEX{\em unreachedCode;}/ETEX
 +
}
 +
\stopC
 +
</context>
 +
 
 +
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):
 
<texcode>
 
<texcode>
\definetyping[C][tab=4]
+
\definetyping[C][tab=3]
 
% for older ConTeXt versions: \chardef\spacespertab=3
 
% for older ConTeXt versions: \chardef\spacespertab=3
 
\startC
 
\startC
Line 33: Line 44:
 
\stopC
 
\stopC
 
</texcode>
 
</texcode>
 +
 +
<context>
 +
\definetyping[C][tab=3]
 +
\startC
 +
int func(int a){
 +
if(a > 4)
 +
return 0;
 +
else
 +
return 10;
 +
}
 +
\stopC
 +
</context>

Revision as of 00:52, 4 August 2005

< Visuals

Displayed text

\starttyping, \typebuffer

In-line text

Interesting features

The option=commands setting allows the usage of ConTeXt commands inside verbatim text, as in this example:

\definetyping[C][option=commands]
\startC
#include 
int main(){
	return 0;
	/BTEX{\em unreachedCode;}/ETEX
}
\stopC

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