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, December 6, 2012

tlmgr and Debian variants

It's quite frustrating knowing that your working Linux distro does not have tlmgr and needs you to install the vanilla TexLive instead, as discussed here

It should be as easy as Python's easy_install and Ruby's gem install way..

Tuesday, December 4, 2012

Transcribing Doodled Equations to LaTeX (and MathML)

Here’s another useful website to bookmark: Web Equations lets you doodle a mathematical equation, then transcribes it into LaTeX or MathML. And it’s fast, too!

Sunday, December 2, 2012

Quick Diagrams with SmartDiagrams

It all started with a question on TeX.SX: Namely, is there any quick way to draw diagrams from a list of items, similar to the ‘Smart Art’ feature in PowerPoint 2010?

It wasn’t long before the package smartdiagram was born as a response, using TikZ to do the actual drawings. The basic syntax is:

\smartdiagram[diagram type]{list of comma-separated items}

Here are some examples (based on material from here):

\smartdiagram[circular diagram]{Assess,Plan,Implement,Renew}

\smartdiagram[flow diagram]{Assess,Plan,Implement,Renew}
\smartdiagram[buggle diagram]{Planning Cycle,Assess,Plan,Implement,Renew}

If you happen to be preparing a Beamer presentation, replacing the \smartdiagram command with \smartdiagramanimated will result in an automatically ‘animated’ diagram, with each item in the list appearing one at a time as you advance through the slides:

See the manual for other digram types and customisation options (colours, shapes, sizes, etc).

Monday, November 12, 2012

Seems Texlive 2012 is in Ubuntu 12.10/Linux Mint 14

najmi@mint:~$ dpkg -l|grep texlive
ii  texlive                                     2012.20120611-4                           all          TeX Live: A decent selection of the TeX Live packages

Been stuck on 2009 version ever since. 
Good news.

Wednesday, October 17, 2012

Drawing xkcd-style Plots and Diagrams with LaTeX

The title says it all! This was asked recently on TeX.SX, and this answer from percusse has the scoop.  The main idea is to use decorations for the lines in TikZ. Here’s his output (requires LuaLaTeX or XeLaTeX to use the font):

Monday, October 8, 2012

Updates for mmuthesis and umalayathesis

Just a quick note that updated classes of mmuthesis and umalayathesis has been uploaded at my website.


Based on feedback from a MMU student who submitted her thesis recently, IPS now requires that the Publications List be categorised in to Journal Articles and Conference Proceedings, and that text in the appendices should be 10pt. Please read the updated user manual on how to prepare the Publication List under the new scheme.


Bug fixes of some spacing of appendices entries in the ToC, as well as adjusting the overall line spacing to conform with the expected output by IPS. Font of the cover page now uses Arial Narrow look-alike.

Saturday, October 6, 2012

New uumthesis LaTeX Class and LyX Layout

On request, I have created a LaTeX class and LyX layout for writing Universiti Utara Malaysia theses. Credit goes to Dr. Mohd. Hasbullah bin Omar for getting the output endorsed by UUM’s Graduate Office.

The uumthesis LaTeX class, LyX layout, sample files and user manual can be downloaded from my website. Happy LaTeXing to UUMians!

Monday, October 1, 2012

Giraffe Chapter uses Beamer too

My research area is on malware detection, so I usually follow the Giraffe Chapter talks and their slides.

Slides #1 in Kuala Lumpur, Malaysia[PDF]
Slides #2, dated 2012 for CCC [PDF]

I personally met the speaker when he came to KL in 2009, but of course the discussion was not whether he's using Beamer or not. It's just a tool :)

Friday, August 24, 2012

Putting Dates in Watermarks

It’s been rather a long time sine I last posted anything as I’ve been working on my thesis and article… sorry!

Theses and articles typically go through many versions, ding-dong to-and-fro between supervisors and co-authors. Some people keep track of the version number (or date-last-modified) by giving each draft a different file name. Personally, though, I tend to get inconsistent with the file naming, especially when it's 2:30am. So I figured it might work better for me if the date-last-modified was printed in the PDF of the thesis/article draft itself.

One could always put the date in the header or footer, but there might already be some content in those regions. Besides, it's probably not a good idea to mess with the formattings for a journal article. Instead, I put \today in a watermark, so the date would get updated I compile my draft:


The colour, lightness, font and other attributes of the watermark are configurable. I also used the datetime package to configure the date formatting. Here’s how the output looks like (a page from my thesis draft):

Tuesday, July 10, 2012

Off topic : Congratulations Dr Joey/Rizal Nor!

One of our bloggers (he was actually the one who encouraged me to use LaTeX for writing) recently successfully defended his PhD dissertation at the Kent State University, Ohio, United States. And he'll be coming back to Malaysia soon!!! (to my office, we're in the same department).

Here is his thesis.. enjoy.

Congratulations again, Joey!
As far as I understood his thesis was written with LaTeX and use tikz package.. need him to verify this.

Friday, June 22, 2012

LaTeX and Graphics Contest

LaTeX-Community has teamed up with Packt Publishing to hold a LaTeX and Graphics contest, where participants can write about anything related to graphics. There are 10 superb contributions, jam-packed with lots of things to take away. Readers can now vote/share/like/blog/comment on the entries, while the judges deliberate over the 2 winners.

My entry is about a technique for efficiently creating visually non-repeating tiled pattern backgrounds, while using only small-sized graphics files, which I’ll cross-post here eventually I suppose, after the contest has ended.

Monday, June 18, 2012


Ever since I knew how to use Beamer, I try to use it every wherever I could (including my progress presentation to my supervisor). Been doing that since 2009. But as forgetful as I am, I usually save my .tex file to be recycled for the next presentation. Some of my slides are available online. You know it's written with Beamer when looking at the template so...

Some slides:
here, here and here.. and the rest you can see from my uploads.. not a big thing just usual stuffs.

Sunday, June 3, 2012

More Ways to Typeset CJK

Rather a long time ago, I wrote about how to typeset CJK (Chinese, Japanese and Korean) in pdfLaTeX, using the CJK and ctex packages. However, the font choices are rather limited. With CJK, you have only the wadalab (3 Japanese fonts) and arphic (2 Simplified Chinese fonts, 2 Traditional Chinese fonts) packages and 1 Korean font. If you have access to Windows fonts, the ctex packages further configures 6 Chinese fonts shipped with Windows for use in pdfLaTeX (may also work with dvi output, but I didn’t test).

More Fonts in XƎLaTeX: xeCJK

If you’re willing to use XƎLaTeX, the xeCJK package makes it a breeze to typeset CJK, using any font (TTF or OTF) installed on your operating system. The following uses Chinese fonts typically found on a Mac:


% Sets font for Roman text.
% There are also \setsansfont, \setmonofont.
% See fontspec documentation.


% Traditional Chinese typesetting has no "bold" nor "italic".
% 黑体 ("blackbody") and 楷体 ("regular script") fonts are
% used instead.

\setCJKsansfont{Hiragino Sans GB}


The fonts are identified by their names as displayed in your OS' font manager application. Here’s the output:

More Fonts in pdfLaTeX: zhmCJK

If you absolutely need to use pdfLaTeX instead of XƎLaTeX, the new zhmCJK package is useful for introducing more CJK font choices into you documents. It’s not included in MikTeX nor TeXLive, however; so you will have to download it from CTAN and install manually: read the instructions carefully.

The zhmCJK packages make use of the premise that all CJK fonts share the same metrics (note that this is not true for Japanese half-width characters! Use ptex if you have serious needs for Japanese typesetting), and can therefore create the NFSS font definition and actual font mappings dynamically. The consequence is that zhmCJK can use TrueType CJK fonts to generate PDF output with pdfTeX or with the dvipdfmx driver. Here’s an example:

\setCJKmainfont[BoldFont=simhei.ttf, ItalicFont=simkai.ttf]{HanNomA.ttf}


You will need to pass the file name of the TTF font, which must have no space characters and only ASCII characters. And for LaTeX to find the TTF files, you need to do one of the following:
  • Set OSFONTDIR in texmf.cnf
  • Move or symlink the TTF file in TEXMF/fonts/truetype
  • Move or symlink the TTF file in the same directory as your document.

Monday, May 21, 2012

A New LaTeX User’s Testimonial

Last week I received an e-mail from Bahareh Pahlevanzadeh, a graduate student at Universiti Sains Malaysia, describing her happiness at discovering LaTeX and my usmthesis class/template for writing her thesis.

Your mileage may vary, but I was a bit surprised when she expressed her opinion that

When it comes to getting my writing organised, I found LaTeX, especially with the USMthesis class template, to be actually very user-friendly.

Well I don’t know about you, but I think I can count on one hand the number of times I’ve heard/read in person the words “very user-friendly” being used to describe LaTeX!

You can read more about Bahareh’s experience here.

Saturday, May 12, 2012

Apple's Keynote Beamer Themes for The Poor

If you don't have Keynote in your Mac, or does not even own any Apple's hardware, perhaps considering this theme, click here

Tuesday, April 24, 2012

LaTeX Template Website

Just read from an article here regarding Vel's effort on putting template on a single page. You can check out Vel's initiative from this page.

Tuesday, April 17, 2012

TeX4ht Options

CV Radhakrishnan (CVR) has posted a list of TeX4ht options, the most comprehensive I have seen yet.

TeX4ht is a very powerful piece of software for converting LaTeX to other formats, such as (X)HTML and ODT. Unfortunately, the documentation was never truly complete, and the inner workings of the system can be hard to grasp and understand. The original creator, Eitan Gurari passed on unexpectedly in 2009. CVR and Karl Berry has since taken over the maintenance of TeX4ht.

As a side note, if you have an existing LaTeX document that you need to convert to other formats, TeX4ht is the most robust system that I have come across, i.e. it works with almost any LaTeX packages that are used in your document. (See this link for other LaTeX-to-whatever conversion tools.)

On the other hand, if you’re just starting to write your document from scratch, with a view to exporting to different output formats later, you might be better off using DocBook or pandoc instead. I personally prefer the markdown syntax in pandoc and exporting to LaTeX later for further editing.

Saturday, March 24, 2012

Reaction to Bad Kerning

Methinks this is one syndrome likely to afflict LaTeX users as well as designers. Everyone who’ve felt this way whenever you see a badly kerned sign, say “Aye”!

Saturday, March 17, 2012

Working collaboratively.. which one you prefer?

I found out this website, perhaps from an event organizer whom advising on the usage of MS Word over LaTeX.

Perhaps somebody out there could point out if there is any business entity that does the same business but in the other way around - using LaTeX

Converting an EndNote Database to BibTeX

During a recent LaTeX introductory workshop, many participants said that they’re very much looking forward to using LaTeX for their future writings, but mentioned that there didn’nt seem to be an obvious way of porting their existing EndNote bibliography libarary into BibTeX format.

EndNote does have an “Export BibTeX” filter, but it doesn’t seem to generate satisfactory BibTeX files. After some googling, I found Bevan Weir’s customised export filter, which does a much better job than EndNote’s default. I modified his filter file a little bit more, and was able to convert an EndNote bibliography library to BibTeX with the following steps.

I tested this with EndNote X5 on the Mac, with JabRef 2.7, but they should also work with Windows versions. %ENDNOTE% refers to the path where EndNote is installed on your system.

  1. Put BibTeX_Export_LLT.ens (download) in %ENDNOTE%/Styles/ .
  2. Start EndNotes, and load your library.
  3. Make sure the new style is listed:
    Edit > Output Styles > Open Style Manager
    Make sure BibTeX_Export_LLT is checked.
  4. File > Export
    Make sure Save File as Type is set to Text Only, and Output Style is set to BibTeX_Export_LLT.
  5. Save your file and check that it has a .bib extension.
  6. Open the exported .bib in JabRef. There will be a whole bunch of errors about corrupted or empty BibTeX keys; don’t worry. Just click OK.
  7. Ctrl+A to select all the BibTeX entreis, Tools > Autogenerate BibTeX keys.
  8. Check through the BibTeX entries, especially those highlighted red, to check and correct any crucial information loss.

And hopefully the converted bibliography file is now usable enough.

Tuesday, March 6, 2012

‘Funny Drawings’ with pst-fun

I learned of the pst-fun package today from an answer at TeX.SX, which provides convenience commands for some ‘fun’ drawings in PStricks. Time for some quick fun then!


\begin{pspicture}(-1, -2)(13,10)
\rput (2.5,7) {\psBird[Branch]}
\rput (10,-1.5) {\psscalebox{-1 1}{\psKangaroo[fillcolor=red!30!yellow]{5.75}}}
\rput {-50} (6,0) {\psBird}

Compile with latex, or xelatex if you want a PDF output. And the output looks like this:

…and I really should get back to work now!

Tuesday, February 28, 2012

LaTeX Training & Consultancy

I’ve recently started offering LaTeX training and consultancy services as a freelancer (between writing up my thesis and parenting). So if you happen to be sourcing for a trainer, or need a consultant for LaTeX-related typesetting or design, feel free to have a look at my webpage and contact me.

Thanks to the other blog authors for letting me post this here. I’m doing this T&C as a personal attempt, so please address your gripes just to me (Lian Tze) if you have any issues with my services, and not to the other authors here.

Thursday, February 9, 2012

Creating an Online Academic Portfolio with LaTeX and TeX4ht

This was originally asked on TeX.SX, the requirements being:

Any one know of a good script to turn a bibtex file into a nice academic portfolio that:
  • links to electronic versions where known (from url or doi)
  • works with local files (e.g. with bibdesk's format or otherwise)
  • automatically creates a thumbnail of the first page
  • and generally produces a polished web page suitable for showing off your work?

Well, I maintain my own online publication list by generating the HTML code from my BibTeX, using BibLaTeX, Biber and TeX4ht. So my answer to the above question was a quick modification of my own workflow, adding Ghostscript to the mix to generate thumbnail images of the papers. The output looks like this: (The publication lists can be split according to their types)

(BibLaTeX is a complete reimplementation of the bibliographic facilities provided by LaTeX in conjunction with BibTeX. It’s very flexible, and many find it easier to deal with compared to the BST language. Biber is the replacement of the BibTeX binary, for users of BibLaTeX.)

The source codes can be downloaded here as a .zip file. Further elaborations follow.

The Bibliography File

Back to the task at hand. First we have the BibTeX file, the content of which is pretty much the norm, except that I used the custom BibLaTeX field to hold the local PDF file name. My publications.bib contains entries like:

author = {Lim, Lian Tze and Ranaivo-Malan\c{c}on, Bali and Tang, Enya Kong},
title = {Low Cost Construction of a Multilingual Lexicon from Bilingual Lists},
journal = {Polibits},
year = {2011},
volume = {43},
pages = {45--51},
url = {http://polibits.gelbukh.com/2011_43/43-06.htm},
usera = {LLT-polibits.pdf}

The LaTeX Source File

Next is the portfolio.tex file, in which I set up a hook at every bibliography item to include the first page of the file pointed to by usera. I've also added a bibmacro called string+hyperlink, to make the publication title link to the url or doi field if these are available, as shown in this answer.




\section{My Academic Portfolio}
\printbibliography[title={Conference Proceedings},type={inproceedings}]


TeX4ht Configuration File

I then set up a TeX4ht personal configuration file, called portfolio.cfg (included in the .zip file). It contains some simple CSS, and tells TeX4ht to convert the first page of the local PDFs into PNGs using ghostscript. (So yes you will need to have ghostscript installed for this to work.)

Generating the HTML

Right, now we can run the following commands:

$  htlatex portfolio "portfolio"
$  biber portfolio
$  htlatex portfolio "portfolio"

And you should then get portfolio.html, which you can further embellish with more CSS. Well that was fun!

Friday, January 20, 2012

Mail-Merge Batch Generating Documents with datatool Package

If you aren’t aware of the possibility before this, you read the title right, it’s possible to do mail-merging in LaTeX with e.g. the versatile datatool package. This makes LaTeX quite a handy Swiss knife in a pinch.

The example scenario: you need to produce a batch of letters, name cards, or certificates really quickly. Let’s say certificates of appreciation for some long-serving employees. The recipients list has most probably been compiled by someone, as a spreadsheet like this:

Now all spreadsheet applications should be able to export the worksheet as a comma-separated values (CSV) plain text file, so we have namelist.csv with the following contents:

Name,ID,Gender,Years in Service
Abdul Ali,382473856,M,15
Francesca Joestar,461276432,F,10
Chan Ker Mei,463724631,F,5
Hikaru Yagami,154954739,M,10

The datatool package can then load namelist.csv as a simple database, which each line being a record, consisting of fields delimited by commas. By default, the field names are given by the first line of the .csv file. After assigning macros to the field names, we can then use the macros to insert ‘mail merge’ fields into a LaTeX document.

Here’s a quick example, using the wallpaper package and an external image (image courtesy of fromoldbooks.org) for the decorative frame:

% Use scrartcl to allow larger base font size

\usepackage{wallpaper} % For background image frame

% Load database 'names' from file 'namelist.csv'

% Set old-border.jpg as background image

% For each record (line) in database 'names'
% Assign field values by name to macros
{\name=Name, \ID=ID, \gender=Gender, \yr={Years in Service}}{

    {\LARGE\bfseries Certificate of Appreciation}\par
    We thank\par
    % Insert '\name' field
    % Insert '\ID' field
    {\large (ID: \ID)}\par
    for having been with\par
    {\large XYZ Company}\par
    % Insert '\yr' field
    {for \emph{\LARGE\yr} glorious years}\par
    % Test '\gender' field and insert him/her, his/her
    We commend \DTLifeq{\gender}{M}{him}{her} on
    \DTLifeq{\gender}{M}{his}{her} excellent service.\par
    Managing Director\par
    (MD's Name)\par


And voilà, the output document has 4 pages, each containing the certificate for a recipient listed in namelist.csv.

Just for fun, here’re the same certifates using ornaments from the adforn font package. For more flamboyant ornaments, see the webomints fonts (installable via getnonfreescripts) or the psvectorian package.

The .tex source codes can be downloaded here.

datatool has many more macros for testing field values and even arithmetics. Other accompanying packages in the bundle, such as datapie, dataplot and databar, even lets you draw charts from .csv files via TikZ/PGF, so do check out the documentation.

Now I’m off to my holidays! Happy Chinese New Year to everyone, and may the Year of the Dragon brings only good tidings for you!

Thursday, January 12, 2012

Use of LaTeX in Industry

A question on TeX.SX about “How is LaTeX used in industry and what are some examples?” has garnered over 6k views since posted yesterday. I had mentioned during my MOSC talk that LaTeX would be very useful in scenarios where some printable content has to be batch-generated or on-the-fly, and now some actual real life examples are given in the answers.

For example, this website allows users to query transportation timetables and returns the results as a pdfTeX-generated PDF:

And here’s another schedule generated by another German transportation website (PDF):

If you read the other answers, you’ll see what and how LaTeX is used in other companies (besides academic publishers). For example, this answer by Peter Flynn:

As a LaTeX consultancy, we have produced classes and styles for many organisations, including companies, government departments, and non-profits. A London auction house uses LaTeX to generate invoices; an electronic systems training company uses LyX and LaTeX to create their course workbooks and white papers; a Dublin printer uses LaTeX for pharmaceutical labelling; a local government organisation uses TeX to generate the Register of Voters; a professional scientific association uses LaTeX for its regular series of technical reports; and of course we use it internally for client reports, newsletters, and invoicing.

Monday, January 9, 2012

Latex on Mobile Smart Devices

I believe most of us got a smartphone which you may use for surfing, taking pictures, emails and playing games. But somehow you might as well use your tablet or perhaps phone (let say, as big as Samsung Galaxy Note) for your productivity tasks.

Since I am more into Android devices (the reason is, most Apple stuffs are pricey, and I could get several Android devices with the price), I managed to find some applications which allow the users to do their Latex activity. 

I found VerbTex[APK file], which uses Verbosus, (which, unfortunately means, you need an internet access to send your Tex file for compilation). 

Also, I found this for the iPad. I am not sure whether it compiles natively or work like VerbTex. But throughout my readings on the page, nothing being mentioned on sending the compilation over the network (perhaps it could be compiled natively?)

How about you, tell us about your "mobile latexing" experience!

Sunday, January 8, 2012

Text-to-Path Conversion with Ghostscript

So you’ve prepared some PDF material with LaTeX, which you’re going to send to the printing company.

If they’ using the PDF as it is, fine and dandy. But if they need to import the PDF into, say, Illustrator for some further processing, you might be in some kind of a fix if the fonts you used (in LaTeX) aren’t easily obtainable as TTF OTF forms.

One solution is to convert all texts into paths before submitting the PDF to the printers. I don’t have Illustrator, so I tried Inkscape instead. Now Inkscape does have a convert-text-to-path function, but for the texts to display properly in Inkscape in the first place, I’d still need the TTF OTF files. Inkscape cannot make use of fonts embedded in the PDF to import the text as paths directly. Not very helpful, then.

Fortunately, suv gave this workaround using Ghostscript:

As a workaround, you can use Ghostscript to convert text in a PDF (or EPS/PS) file to outlines. It requires to convert the PDF to an intermediary PS file, and then back to PDF (thus losing PDF features not supported by PostScript, like transparency).
E.g. use a shell script, containing a command similar to this one:

$ gs -sDEVICE=pswrite -dNOCACHE \
-sOutputFile=- -q -dbatch -dNOPAUSE \
-dQUIET "$1" -c quit | ps2pdf - \
"`echo $1 | cut -f1 -d'.'`"-nofont.pdf

So long as your file does not contain any transparency, the script works just fine, and you can submit the file*-nofont.pdf to your printer. And of course, expect some increase in file size.