Changes

Jump to navigation Jump to search
1,677 bytes added ,  21:19, 17 July 2014
no edit summary
< [[Main Page]] | [[Hello world|Detailed example]] >
 ConTeXt is a ''[http://en.wikipedia.org/wiki/Markup_language markup laguage]'' used to primarily create PDF files. To use ConTeXt, create a text file (typically with a <code>.tex</code> extension) with ConTeXt markup and ''compile'' the file by running the command <code>context filename</code>. This creates a PDF file. This page explains how to create your very first ConTeXt document. == First, make steps == Make sure that ConTeXt is installed on your system. To check that, go to the command line and type
<pre>context --version</pre>
== Create a ConTeXt file ==
Open a [[Text Editors|text editor]], type the following content, and save the file as <code>hello.tex</code>:
<texcode>\starttext
\startsection[title={Testing ConTeXt}]
This is my {\em first } ConTeXt document.
\stopsection
\stoptext</texcode>
 
Words starting with a backslash (such as <code>\starttext</code>) are called '''command sequence''' or '''macros'''. The macros
 
<texcode>\starttext
....
\stoptext</texcode>
 
mark the content to be typeset. The material before <code>\starttext</code> (called ''preamble'') is used to change the style of the output; any material after <code>\stoptext</code> is ignored.
 
The macros
 
<texcode>\startsection[title={...}]
...
\stopsection</texcode>
 
mark the title and the content of a section.
 
The macro <code>{\em ...}</code> is a [[Font Switching| font switch]] that emphasizes the content (by showing it in slanted font).
 
== Compile the ConTeXt file ==
Open the generated <tt>hello.pdf</tt> PDF file using a [http://en.wikipedia.org/wiki/List_of_PDF_software#Viewers PDF viewer]. It should look as follows:
<context mode="mkiv">
% Draw a white frame so that the page is not truncated.
% But it does not seem to work :(
\setupbackgrounds[pagetext][frame=on,framecolor=white]
\starttext
\startsection[title={Testing ConTeXt}]
This is my {\em first } ConTeXt document.
\stopsection
\stoptext
</context>
Note that the section has been numbered, the section number and the section title appear in a slightly larger fonts, and the emphasized word comes out in a slanted font.
 
== Modifying the output style ==
&rarr; It is possible to change the style of the output by using appropriate ''setup'' commands in the preamble. For example, to make the section titles bold and to use italic (rather than slanted) font for emphasized words, use <context mode="mkiv" source="yes" text="which gives">\setuphead[section][style=\bfa]\setupbodyfontenvironment[default][Hello world | Detailed exampleem=italic\starttext\startsection[title={Testing ConTeXt}] This is my {\em first} ConTeXt document.\stopsection\stoptext</context>
{{Getting started navbox}}

Navigation menu