I’ve chosen to study a TeX, and finally choose ConTeXt because it uses LuaTeX engine that can support Chinese with less pain than using LaTeX as well as someone is complaining about XeTeX may output a lower quality. I don’t know who’s true, but according to my own perception, ConTeXt Minimals with LuaTex may be the best choice, so I start this category of blog to track my course studing it.
Today, I am trying to install it and output my first result file.

Installation is quite easy:

mkdir ~/usr/context && cd ~/usr/context
wget http://minimals.contextgarden.net/setup/first-setup.sh

It will call rsync and use ruby to achieve this, so make sure they are installed on system.

sh first-setup.sh

This will give you a dev-shot of ConTeXt Minimals, if a stable version is needed, run the following instead:

sh first-setup.sh --context=current

I continue with the dev version. Note, every time we want do an update of the program or move it somewhere else, we need to run the command above to make all things work.
If we don’t have a connective Internet available but still want to change the directory, we may run the following command in the context/ folder with tex/ under it:

mtxrun --verbose --script ./bin/mtx-update.lua --update --make --force --engine=all --context=beta --texroot=$PWD/tex $@

Next, make sure there are fonts needed installed, on my system it’s /usr/share/fonts, with wqy-zenhei and wqy-microhei as my Chinese fonts and others like DejaVu and Droid as English fonts.
We need to refresh the system’s font cache before continue, otherwise some fonts won’t work.

sudo fc-cache -f

Then add the system’s font directory to setuptex, which file is placed at ~/usr/context/tex/setuptex in my installation, add the following line at the end of file:

export OSFONTDIR=/usr/share/fonts

Reload font cache for ConTeXt:

mtxrun --script fonts --reload

Generate a list of usable fonts:

mtxrun --script fonts --list --all > font-names.txt

First row represents the font name we will use in our tex file, second is descriptions like font name in true life, the third line is the path to the font file in system.
Finally source the setuptex file to make this environment sensible for current console:

source ~/usr/context/tex/setuptex

Now, we’ve finished setting up a environment that can work.
The easiest example may be like this:

Hello world!

Have another test with Chinese:


First line assign “uming” as “arplumingcn”, that is “uming” will be used in the following of this file to represent the “arplumingcn”, which is the name of this font that we can see in the first row of former generated font-names.txt.
Second line tell the program we are starting the text, and the next line tell it we are choosing font “uming” for following text. And the last line tell it the text is finished.
I save the file as hello.tex, and use this command to produce the result:

context hello

also we can use hello.tex, but like other Tex environment, ConTeXt knows that it is processing a TeX file so the suffix can be omitted safely.
The the program print many things to our console and finally stopped with several hello.* files in our working directory, and hello.pdf is lying there.