Difference between revisions of "Detailed Example"

From ConTeXt wiki
Jump to navigationJump to search
m (moved Hello world to Detailed Example: More descriptive title)
(2 intermediate revisions by 2 users not shown)
Line 331: Line 331:
== Compiling ==
To compile the file, go to command line and run
{{Getting started navbox}}
texexec Hello-world.tex
If you get an error like "I can't find the format file `cont-en.fmt'!", try using following instead:
context Hello-world.tex
However, it's always better to use texexec. To solve the above problem, first run
texexec --make --all
and then proceed with
texexec Hello-world.tex
[[Category:Sample documents]]
[[Category:Sample documents]]

Latest revision as of 04:22, 22 May 2015


Here is a skeleton document that illustrates several features of ConTeXt:

File:Hello-world.pdf is the PDF file the 2006.12.27 version of ConTeXt produced.


File:Hello-world.tex is the source (to save copying and pasting from the source below).

% "Hello world!" document for the ConTeXt typesetting system
% === History ===
% 2006-12-29  Sanjoy Mahajan  <sanjoy@mit.edu>
%     * Created
% This document is the public domain (no copyright).

\setupcolors[state=start]       % otherwise you get greyscale

% for the document info/catalog (reported by 'pdfinfo', for example)
\setupinteraction[state=start,  % make hyperlinks active, etc.
  title={Hello world!},
  subtitle={A ConTeXt template},
  author={Sanjoy Mahajan},

% useful urls
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]

% for US paper; the sensible default is [A4][A4] (A4 typesetting,
% printed on A4 paper)
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,
  height=middle, width=middle]
% uncomment the next line to see the layout
% \showframe

% headers and footers
\setupfootertexts[\date\hfill \ConTeXt\ template]
\setuppagenumbering[location={header,right}, style=bold]

\setupbodyfont[11pt]            % default is 12pt

  before={\bigskip\bigskip}, after={}]
  after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}

\setupitemize[inbetween={}, style=bold]

% set inter-paragraph spacing
% comment the next line to not indent paragraphs
\setupindenting[medium, yes]


\title{Hello, world!}

Here is a hello-world template document to illustrates a few \ConTeXt\
features.  Have fun.  You can find a lot more information at
\from[wiki]; the preceding text should be colored and clickable, and
clicking it should take you to the wiki.

\subject{A list}

Here is an example of a list.

\startitemize[a]                % tags are lowercase letters
\item first
\item second
\item third


An equation can be typeset inline like $e^{\pi i}+1=0$, or as a
displayed formula:
\int_0^\infty t^4 e^{-t}\,dt = 24.
% don't use $$...$$ (the plain TeX equivalent)
You can also have numbered equations:
\int_0^\infty t^5 e^{-t}\,dt = 120.
And you can refer to them by name. I called the previous equation {\tt
factorial-example}, and it is equation \in[eq:factorial-example].
\ConTeXt\ figures out the number for you.  And with interaction turned
on, you can click on the equation number to get to the equation.

\subject{Text with figures}

Now text with a few figures.  The first figure goes on the right, with
the paragraph flowing around it.


\input tufte

The next figure will go inline, like a displayed formula:
\input tufte

Here's another reference to the numbered equation -- equation
\in[eq:factorial-example] on \at{page}[eq:factorial-example], so that
you can test clicking on it or on the page reference.

% most plain TeX commands work

\framed[corner=round, width=\textwidth,height=1in,
{This document is in the public domain, so that you can improve it, share
it, and otherwise do what you want with it.  
Suggestions are welcome.  You can send them to me
at \from[sanjoy] (Sanjoy Mahajan).}



This documents looks like this: