Difference between revisions of "Help:Context"

From Wiki
Jump to navigation Jump to search
m (Gray backgrounds is better backgrounds)
Line 22: Line 22:
 
\setupcolors [state=start]
 
\setupcolors [state=start]
 
\framed [background=color,
 
\framed [background=color,
         backgroundcolor=green,
+
         backgroundcolor=gray,
 
         offset=0.5cm ]{hello world!}
 
         offset=0.5cm ]{hello world!}
 
</context>
 
</context>
Line 29: Line 29:
 
\setupcolors [state=start]
 
\setupcolors [state=start]
 
\framed [background=color,
 
\framed [background=color,
         backgroundcolor=green,
+
         backgroundcolor=gray,
 
         offset=0.5cm ]{hello world!}
 
         offset=0.5cm ]{hello world!}
 
</context>
 
</context>
Line 44: Line 44:
 
\setupcolors [state=start]
 
\setupcolors [state=start]
 
\framed [background=color,
 
\framed [background=color,
         backgroundcolor=green,
+
         backgroundcolor=gray,
 
         offset=0,5cm ]{hello world!}
 
         offset=0,5cm ]{hello world!}
 
</context>
 
</context>
Line 51: Line 51:
 
\setupcolors [state=start]
 
\setupcolors [state=start]
 
\framed [background=color,
 
\framed [background=color,
         backgroundcolor=green,
+
         backgroundcolor=gray,
 
         offset=0.5cm ]{hello world!}
 
         offset=0.5cm ]{hello world!}
 
</context>
 
</context>

Revision as of 11:41, 19 October 2012

The <context> ... </context> tags process their ConTeXt contents on the fly and include the result on the page as an image. Whitespace is cropped out. The following attributes may be set:

  • source=yes displays the source before the output.
  • text="some text" places 'some text' between the source and the output.
  • mode=mkiv ensures Mark IV is used instead of the default Mark II.

Quotation marks around attribute strings are only required if the attribute contains non-alphabetic characters.

For some reason, examples using the default A4 paper size usually end up blown up twice as large. If this happens, include \setuppapersize[A5] in your example, and everything will display at its proper size again. This has the added advantage that the resulting image will never be too large for this wiki's main column.

Examples

Plain example

Wiki markup Wiki display
<context>
\setupcolors [state=start]
\framed [background=color,
         backgroundcolor=gray,
         offset=0.5cm ]{hello world!}
</context>

source=yes

Wiki markup Wiki display
<context source="yes" text="produces">
\setupcolors [state=start]
\framed [background=color,
         backgroundcolor=gray,
         offset=0,5cm ]{hello world!}
</context>
\setupcolors [state=start]
\framed [background=color,
         backgroundcolor=gray,
         offset=0.5cm ]{hello world!}

produces

mode=mkii and mode=mkiv

By default, the wiki compiles examples using MkII. You can specify that you want to use MkIV by adding the option mode=mkiv to the tag. Because MkII examples are visually indistinguishable from MkIV examples, it is good practice to start MkIV examples with a comment % mode=mkiv.

Wiki markup Wiki display
<context source=yes>
% mode=mkii
Version: \contextversionnumber
</context>
Version: \contextversionnumber
<context mode=mkiv source=yes>
% mode=mkiv
Version: \contextversionnumber
</context>
% mode=mkiv
Version: \contextversionnumber

Displaying multiple pages

\setuppapersize[A10, landscape][A8, landscape]

\setuppaper[nx=2, ny=2]     % arrange pages 2 by 2 (must come before \setuparranging[XY])
\setuparranging[XY]         % arrange pages n by n (across, then down)
\setuppagenumbering[location=footer] % page numbers are always useful
\showframe[edge]            % Draw line around each page. Prevents overzealous cropping

one \page[yes]
two \page[yes]
three \page[yes]
four