# Mark IV

## Introducing Mark IV

Mark IV is the name of the LuaTeX-aware part of ConTeXt; that is, when you use ConTeXt over the LuaTeX engine instead of PDFTeX or XeTeX. You run it with

context filename


There are fundamental differences between Mark IV and Mark II that you should be aware of. Many parts of ConTeXt have been redesigned from scratch making extensive use of the Lua programming language. And that is besides the heavy use of LuaTeX-only features in MkIV. As a result, there are a few intentional incompatibilities between the two ConTeXt versions. See MkIV Differences for these details.

The first public beta has been released on the 6th of August, 2007. Currently the easiest way to try it out is to install ConTeXt Standalone.

It takes advantage of the amazing capabilities of LuaTeX and opens up a whole new world of possibilities, in particular with fonts.

In the distribution the MkIV files have suffix 'mkiv'. There are also files with suffix 'mkvi' and more will follow. The most significant difference is that these files use a different (and still somewhat experimental) syntax.

### Mark VI

Mark VI is identical to Mark IV in every respect, except that when you define a new macro you can give parameters names instead of numbers. This make programming a great deal more pleasant. For example, instead of

\def\colortext[#1]#2%
{\color[#1]{#2}}


you can write

\def\colortext[#color]#text%
{\color[#color]{#text}}


To use Mark VI, add the comment % macros=mkvi as the first line of your file, or save the file with a .mkvi extension.

## Installation and maintenance

The Mark IV code needs to be configured before it is usable. This page explains how to do that.

## Troubleshooting

The environment variable TEXINPUTS has to be empty or unset. If not, you can get errors about "file/module/whatever not found".

TEXINPUTS can *always* be a problem and really should not be used at all any more. It is a historical environment variable from the nineties, and it overrules just about every path in a modern texmf tree.

If you need something special, use TEXMFLOCAL or TEXMFPROJECT instead.

## Sample code

Here are some examples of cool stuff you can do with Mark IV.

### Lua core

The first thing you will want to test are the lua functions. Try

\ctxlua{a = 1.5 ; b = 1.8 ; c = a*b ; tex.print(c) ;}


or the equivalent:

\startlua
a = 1.5
b = 1.8
c = a*b
tex.print(c)
\stoplua


You can also do more elaborate calculations with the lua math library:

\ctxlua{tex.print("$\string\\sqrt{2} = " .. math.sqrt(2) .. "$")}


Note that the above works with any flavour of LuaTeX; nothing is actually ConTeXt-specific (except for \ctxlua and \startlua/\stoplua).

### Fonts and typescripts

This is detailed in Fonts in LuaTeX.

### More sample code

Other examples of Lua(TeX) code are to be found on Luigi's user page as well as http://luatex.bluwiki.com/