Featured Post

We've moved to tex.my!

It’s been great writing on Blogger.com, but we’ve decided to move to a new platform, thanks to some valuable help from a great, great friend...

Thursday, August 26, 2010

Writing Systems and Calligraphy of the World

This post has nothing to do with LaTeX, but if you’ve enjoyed using LaTeX, I think you’ll enjoy reading about this very well-researched write-up about the various writing systems (scripts) (Part 1) (Part 2). Simply beautiful.

Friday, August 20, 2010

Tamil and Hindi Support in LaTeX

Doing a post on typesetting Tamil and Hindi is only natural after sorting out Jawi and CJK! Just after I managed to get them working using the itrans package and the devanagari fonts, this exact question was asked on the TeX-LaTeX Stack Exchange site, to which I posted what worked for me. So this post is essentially a re-write of my answers there.

(These instructions are LaTeX-only; I’ve not dabbled much in XƎLaTeX.)

Installation on Ubuntu (TeXLive)

This one’s easy. Grab the itrans and itrans-fonts packages for Tamil, and also the texlive-lang-indic package for the Hindi fonts via synaptic (or apt-get).

Installation on Windows XP (MikTeX)

Grab the devanagari package using MikTeX’s Package Manager. As for itrans, since it’s not packaged properly in MikTeX, so we’ll need to install it manually. Download itrans53-win32.zip from CTAN. After unzipping the contents (say C:\itrans53\), assuming <texmf> being your local TEXMF tree,

  • Move the contents of the lib folder into <texmf>\tex\latex\itrans
  • Move the contents of the fonts folder into the appropriate locations, i.e.
    • *.mf in <texmf>\fonts\source\itrans
    • *.afm in <texmf>\fonts\afm\itrans
    • *.tfm in <texmf>\fonts\tfm\itrans
    • *.pfb, *.pfa, *.pfm in &lt;texmf&gt;\fonts\type1\itrans
    • *.ttf in <texmf>\fonts\truetype\itrans
    • *.fd in <texmf>\tex\latex\itrans
  • Refresh the file name database (e.g. via MikTeX Options/Settings)

Using itrans

itrans doesn’t let you type in Tamil or Hindi (or Marathi, Sanskrit, Telugu and Gujarati) directly, rather you have to key in the ASCII transcription, then process it with itrans from the command prompt, then run (pdf)latex on the resultant file.

Say I have the following file indic-pre.tex:

\documentclass[11pt]{article}
\usepackage[preprocess]{itrans}

\newfont{\tmlb}{wntml12}
\newfont{\tmls}{wntml10}
\newfont{\devnf}{dvng10 scaled \magstep1}
#tamilifm=wntml.ifm
#tamilfont=\tmlb
#hindiifm=dvng.ifm
#hindifont=\devnf

\begin{document}
Thank you!
{#tamil na^nRi #endtamil}
{#hindi dhanyavaad #endhindi}
\end{document}

Process it with itrans: (Windows MikTeX users need to change path to itrans53\bin to evoke itrans.exe

$ itrans -i indic-pre.tex -o indic.tex

Then run (pdf)latex on indic.tex, which is of course the file to edit if you have further text to add. Here's the output of that little file:



Hold on! How’d you know you needed to type na^nRi etc?

I peeked at the transliteration map files ☺. For example, tamil.ps for the Tamil transliteration, dvng.ps for the Hindi (devanagari) transliteration, etc. If your LaTeX set up doesn’t install these files by default, you can download the package source .zip and look in the doc folder. The .itx files are sample source .tex files that generated the .ps files.

Wednesday, August 4, 2010

New (La)TeX Q&A Site

I’m sure many people have looked up Stack Overflow for programming-related Q&A. Well there’s now a similar community-driven LaTeX-specific Q&A site: TeX, LaTeX and Friends. Here’ a short snippet from the site FAQ (my own emphasis):

What kind of questions can I ask here?
TeX - LaTeX - Stack Exchange is for expert users of TeX, LaTeX and other related typesetting systems. Please do look around to see if your question has already been asked (and maybe even answered!) before you ask.

What kind of questions should I not ask here?
Avoid asking questions that are subjective, argumentative, or require extended discussion. This is not a discussion board, this is a place for questions that can be answered!

After just 7 days in private beta, the site has 323 users and 658 answers to 242 questions. With many (La)TeX experts already onboard answering questions, this is definitely one for the bookmarks (especially if you still can’t get used to comp.text.tex!)

Wednesday, July 28, 2010

MMU Thesis LaTeX Class

I have developed a LaTeX class and template for writing an MMU thesis, complying with the MMU IPS Guide for Preparation of Thesis.

The LaTeX class and template files is available at http://liantze.penguinattack.org/latextypesetting.html#mmuthesis. Hopefully this will be helpful to MMU students!

Tuesday, July 6, 2010

April Fool came late this year

River Valley TV has posted the video of Donald Knuth’s “earth-shattering” announcement at the TUG 2010 Conference about a “successor to TeX” that he’s been “secretly working on”.

Utterly hilarious, in which Prof Knuth parodies almost every single recent software and technology trends. And taking lots of “inspirations” from the c.t.t. newsgroup posts methinks. ;-) (Gotta love the transparencies too. Really takes me back to my undergrad days...)

As many have commented on the Web, “April Fool came late/early” for TeXies!

Wednesday, June 30, 2010

Another Beamer Thingy: Internet Malicious Miscreants

Tomorrow will be the last day of Malaysian Open Source Conference (MOSC 2010) where in this three days event I got a chance to talk on something which perhaps everybody knows about : Malicious Software and friends.

Anyway, the following is my PDF slides, ready for download here . In future, perhaps I considering drawing diagram using Tikz (again), but this one, maybe with something which I really love to draw.

Monday, June 21, 2010

CJK support in LaTeX

(Oh gosh. This is one post I should have written a loooong time ago.)

Najmi has previous posted about Jawi support on LaTeX. Well then, what about CJK (Chinese, Japanese, Korean) characters?

(The process may be simpler using XƎLaTeX, but I personally use LaTeX more, so this post won’t touch on XƎLaTeX.)

Short snippets

If you need only short CJK snippets, use the CJK package. (While you’re at it, you may as well grab cjk-fonts and wadalab for the fonts.) On Debian-based systems, just grab latex-cjk-all and you should be good. Or if you don’t want the whole package (it’s huge), grab whatever you need for latex-cjk-chinese, latex-cjk-japanese or latex-cjk-korean (and whatever relevant font packages).

Here’s a basic example for Chinese:

\usepackage{CJK}
...
%% if your file is saved as GB simplified encoding
... as we say in Chinese,
\begin{CJK}{GB}{gbsn}子曰:有朋自远方来,不亦乐乎?\end{CJK}

%% if you file is saved as Big5 traditional encoding
... as we say in Chinese,
\begin{CJK}{Bg5}{bsmi}子曰:有朋自遠方來,不亦樂乎?\end{CJK}


But if you're saving as UTF-8 then you need CJKutf8.sty (included in CJK package):

\usepackage{CJKutf8}
...
as we say in Chinese,
\begin{CJK}{UTF8}{gbsn}子曰:有朋自远方来,不亦乐乎?\end{CJK}
or \begin{CJK}{UTF8}{bsmi}子曰:有朋自遠方來,不亦樂乎?\end{CJK}

You have a few font choices (make sure you get the latex-cjk-chinese-arphic-* files!)
  • gbsn (简体宋体, simplified Chinese)
  • gkai (简体楷体, simplified Chinese )
  • bsmi (繁体细上海宋体, traditional Chinese)
  • bkai (繁体标楷体, traditional Chinese)

Japanese and Korean text are typeset much the same way. If you save everything as UTF-8, then it’s just a matter of knowing what fonts to invoke:

\usepackage{CJKutf8}
...
%% Japanese
\begin{CJK}{UTF8}{min}
露の世は 露の世ながら さりながら
\end{CJK}

%% Korean
\begin{CJK}{UTF8}{mj}
편편황조 자웅상의 염아지독 수기여귀
\end{CJK}


The Japanese fonts are from the wadalab packages (latex-cjk-japanese-wadalab-*):
  • min (明朝 Mincho)
  • goth (ゴシック Gothic)
  • maru (丸ゴシック Maru Gothic)

As for Korean, well I’ve only been able to get mj (明朝体 MyongJu) working so far.

Entire Document in Chinese

On the other hand, if your entire document is going to be in Chinese, you might be better off using the ctexart document class (in the ctex package):

\documentclass[UTF8]{ctexart}

\begin{document}

\section{论语}
子曰:有朋自远方来,不亦乐乎?

\end{document}


There is a caveat, though. You’ll need to copy some Windows Chinese font files to your $localtexmf/fonts/truetype/... directory (don’t forget to run texhash!) to use ctex properly (font name in CJK/ctexart in brackets). These are all for simplified Chinese characters:
  • simsun.ttc 宋体 (song, default)
  • simfant.ttf 仿宋 (fs)
  • simkai.ttf 楷书 (kai)
  • simhei.ttf 黑体 (hei)
  • simli.ttf 隶书 (li)
  • simyou.ttf 幼圆 (you)

In any case, for more help on the ctex package and ctexart.cls, you’d best ask for help at the CTEX forum. (Language there is predominantly Mandarin Chinese.) I’m not aware of similar classes for Japanese nor Korean, though.

Pinyin and Ruby

Younger children learning Chinese characters (Hanzi/Kanji/Hanja) would often have the pronunciations annotated alongside/above/beneath the characters. For Chinese pinyin pronunciations, you would invoke

\usepackage{pinyin}
...\dian4 \deng1

to get diàn dēng.

To cite Martin Duerst:
Ruby are small characters used for annotations of a text, at the right side for vertical text, and atop for horizontal text, to indicate the reading (pronounciation) of ideographic characters.
And you can produce them with the ruby package:

\usepackage{CJKutf8,pinyin}
\usepackage[overlap,CJK]{ruby}
...

%% By convention, the pinyin would be *under* the Hanzi
%% so change the \rubysep to move it under

\begin{CJK}{UTF8}{gbsn}
\renewcommand\rubysep{-1.4em}
\ruby{电}{\dian4}\ruby{灯}{\deng1}
\end{CJK}

%% I find the default \rubysep (-0.5ex) too tight, so
%% let's enlarge it a little.

\renewcommand\rubysep{-0.2ex}

%% Shonen manga readers would get the written as
%% rival, pronounced as friend
 reference

%% (CORRECTED June 22)
\begin{CJK}{UTF8}{min}
\ruby{素敵}{ともだち}
\end{CJK}

%% Disclaimer: I'm actually unsure where the
ruby should be placed for Korean Hanja

\begin{CJK}{UTF8}{mj}
\ruby{南}{남}\ruby{宮}{궁}
\end{CJK}

The output of which looks something like this: