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 29, 2011

Happy New Year! Fireworks with TikZ

TEX wizards recently demonstrated how you can draw fireworks with TikZ:

(There’s also an earlier Q&A about drawing Christmas trees.)

Geeky DIY Christmas and New Year cards, anyone? :-)

Monday, October 17, 2011

English Translation of ChinaTeX’s Interview

I’ve finally gotten round to translating ChinaTeX’s interview with me (originally in Chinese) into English. It’s not a word-for-word translation, but I made sure the main points are preserved.

Saturday, October 15, 2011

Fixing the Biolinum Font in Beamer

The libertine package provides LaTeX support to the Linux Libertine and Linux Biolinum fonts. The package release dated 2011-06-06 contains a bug, in which the ex unit value of the san serif font, Linux Biolinum, is not set correctly. This causes problems if the libertine package is used in a beamer presentation:

Notice how the heights of the headline and footline coloured boxes are almost zero. The same thing happens to the itemized and enumerated list markers, too.

A bug report has been filed with the LinuxLibertine project, but it’s still open at the time of writing.

In the meantime, Ulrike Fischer and Robin Fairbairns have provided an interim solution by resetting the ex value in the .fd files. Here’s what I did following their suggestions.

Locate the Biolinum .fd files, which should be in $TEXMF/tex/latex/libertine/ . I usually work with T1 encoding, so I homed in on the files t1fxb.fd, t1fxbf.fd, t1fxbj.fd, t1fxbjo.fd and t1fxbo.fd. (All these files, because sometimes I want the old-style numbers fonts.) I then added the code in red below for each m-n series-shapes:

<-> \fxl@@scale fxbr-t1

I didn’t bother with the \DeclareFontShape of other series-shapes, as the above seems to have fixed the problem for me:

So hopefully this’ll help anyone else who’s run into a similar predicament. Thanks again to Ulrike and Robin for the solution.

Monday, September 26, 2011

ChinaTeX Interview

As you may guess from the name, ChinaTeX is a TeX resources website from China. They’ve done a good job rounding up TeX resources from around the Web, and translating them to Chinese for the benefit of Chinese users. Their latest endeavors over the weekend was to provide video tutorials.

Recently ChinaTeX approached me for an e-mail interview. We talked mainly about how I came to know, love and use LaTeX in book design and typesetting. Thanks for the interview, guys! 有空再来坐坐、交流,谢谢!

Cyberjaya, an MMU Beamer Theme

And here’s Cyberjaya, a Beamer theme based on Multimedia University’s (MMU) colours. (Cyberjaya, Selangor, Malaysia is where MMU’s main campus is located.)

Screenshots and download link:

Brief example using the theme:


\author{This is Me}
\title{This is My Presentation}



\frametitle{First Frame}
My content


Wednesday, September 21, 2011

Gelugor, a USM Beamer Theme

Just last week, I had another Beamer-related inquiry from a postdoctoral fellow at the School of Mathematical Sciences, Universiti Sain Malaysia (USM). Was it possible to have a Beamer theme modelled after USM’s Powerpoint template?

I came up with Gelugor over the weekend. (Gelugor, Penang, Malaysia is the town where USM’s main campus is located.)

Screenshots and download link:

Brief example using the theme:


\author{This is Me}
\title{This is My Presentation}



\frametitle{First Frame}
My content



Skudai, a Beamer Theme for UTM

This all started a couple of months back when Najmi asked me if it was possible to get a Beamer presentation to look like his university's (Universiti Teknologi Malaysia, UTM) Powerpoint template.

The eventual result is Skudai, a UTM Beamer theme. (Skudai is the name of the city town in Johor, Malaysia, where UTM’s main campus is located.)

Screenshots and download link:

A brief example on using the theme:


\author{This is Me}
\title{This is My Presentation}



\frametitle{First Frame}
My content


Monday, September 12, 2011

Converting BibTeX to EndNote format

You might somehow need to submit your research findings in a journal which however, needs you to submit compulsively in Microsoft Words format.

If your institution is subscribing to EndNote, perhaps you might want to install them, at least, in Wine on top of your Linux machine

For easy convertion from *.bib file to EndNote importable format (XML).. use this software, bib2endnote

Fedora Linux for Research Writing

Recently I got a chance to deliver a short talk during Fedora Activity Day 2011 at UCTI, Technology Park, Kuala Lumpur. My talk basically was targeted to undergraduate who (I thought so) attended that slot.

Here goes

Monday, September 5, 2011

Creating Desktop Shortcut for JabRef in Fedora Core 15


This may not *directly* related to LaTeX, but given you are using Fedora and wondering how life may be easier with prepackaged RPM for JabRef, this might assist you a bit. I managed to get it worked on my machine.. so comments are welcomed.

I wrote the tips in my personal blog.. just click here

Monday, August 22, 2011

Barcodes Galore

So you may need to include a barcode on some reports or forms that you’re generating. Or you might want to include a QR code for your organisation’s newsletter or flyer, to indicate a URL, or an event. Or even one for your personal contact details on your business card.

You can, of course, seek out a barcode generator to get a PNG of your barcode to be included in your document. But did you know about the pst-barcode package that’ll do the job nicely?

Example Barcodes

I mentioned the ean13isbn package in a previous post, but that package is only for generating ISBN barcodes. pst-barcode, on the other hand, can generate many different types of barcodes. Some simple examples below, taken from the pst-barcode package documentation. Remember to \usepackage{pst-barcode}.


\psbarcode{^453^178^121^239}{columns=2 rows=10}{pdf417}

\psbarcode{Herbert Voss ^142^164^186}
{rows=48 columns=48 parse}{datamatrix}



Encode Almost Anything with QR Codes

QR barcodes can be used to encode a wide range of data. You can use a camera phones to scan and decode them using a reader application (e.g. ZXing, Kaywa, Qrafter, etc.). (You can also use the ZXing online barcode decoder for testing purposes.) Depending on the decoded data, specific actions will be triggered.

For example, the QR code above encodes the URL of this blog. Scan it with a camera phone, and an Internet browser will open and load this blog automatically.

The following code encodes my contact details as a MeCard. After scanning it, a good barcode reader application will automatically decode the details and prompt you to add my contact details to your address book. (BTW my address and phone number in this barcode is fake.)

% Do not put newlines in the MECARD text
\psbarcode{MECARD:N:Lian Tze,Lim;TEL:+60123456789;EMAIL:liantze\string@gmail.com;ADR:,109 Lorong Oak 47,Taman Oak,Butterworth,Pulau Pinang,13000,Malaysia;URL:http://liantze.penguinattack.org/;;}
{eclevel=M height=2 width=2}{qrcode}

It seems MeCard is used more widely than vCard for QR codes on business cards, but if you want a vCard anyway, here’s the code. vCard does allow you to add a photo, which is nice. Note that you need to represent newline characters with ^^J for the code to compile.

% Line breaks occur only after ^^J%
N:Lian Tze;Lim^^J%
FN:Lim Lian Tze^^J%
ADR:;;109 Lorong Oak 47, Taman Oak;Butterworth;Pulau Pinang;13000;Malaysia^^J%
{eclevel=M height=2 width=2}{qrcode}

You can also add a barcode encoding an iCalendar for an event, e.g. in a newsletter. A good reader app would be able to add the details automatically to your calendar. (Qrafter for the iOS worked for me.)

% Line breaks occur only after ^^J%
SUMMARY:25th Pacific Asia Conference on Language, Information and Computation^^J%
ORGANIZER;CN=Assoc Prof Francis Bond:MAILTO:fcbond@ntu.edu.sg^^J%
LOCATION:Nanyang Technological University, Singapore^^J%
{eclevel=M height=2 width=2}{qrcode}

What If I’m Generating to PDF directly?

If you’re using xelatex, apparently all the pstricks packages work smoothly and you get a flawless PDF.

If you’re using pdflatex, you can still use pst-barcode (and other pstricks packages) with a little extra bit of work. Here’s what your preamble should include:


You will also need to install pdfcrop, available from CTAN; install with your TeXLive/MikTeX package manager). This is actually a Perl script that crops away extra whitespace around each page of a PDF file.

You must add the -shell-escape option when running pdflatex for this to work. What happens is that a ps file is generated and converted to a PDF on-the-fly, then cropped and included in the final output PDF file. Understandably, the whole process may take a bit longer than usual.

Hopefully this’ll help anyone who’s looking to batch generate reports or forms that need a barcode or two!

Saturday, July 16, 2011

Printing Beamer Slides

Every now and then I’d go wild with \pause and \item<+-> in my Beamer presentations, to present information piecewise. (I’m aware that some people disapproves this.) (By the way, the Manhattan theme is a Keynote lookalike.)


\frametitle{First Slide}

\begin{theorem}[Newton's First Law]
Every body remains in a state of constant velocity unless acted upon by an external unbalanced force.
\item<+-> First item in a list
\item<+-> First item in a list
\item<+-> Second item in a list
\item<+-> Second item in a list

For archival and distribution purposes, I usually invoke


to get a PDF file in which all the overlays are “condensed” to their respective single slides.

When it comes to printing the slides for my own reference, though, I often prefer to have the presentations 4-up on an A4 sheet. In addition, the Manhattan themed presentation isn’t really printer-friendly. So I’d instruct Beamer to only use the Manhattan theme in beamer and trans modes; and that it should use some mostly-white theme as well, as placing the slides 4-up on an A4 paper in handout mode (code lifted from the Beamer manual).

% \documentclass[handout]{beamer}
% \documentclass[trans]{beamer}


\pgfpagesuselayout{4 on 1}[a4paper, landscape, border shrink=5mm]
\pgfpageslogicalpageoptions{1}{border code=\pgfstroke}
\pgfpageslogicalpageoptions{2}{border code=\pgfstroke}
\pgfpageslogicalpageoptions{3}{border code=\pgfstroke}
\pgfpageslogicalpageoptions{4}{border code=\pgfstroke}

Running pdflatex while activating the handout mode then gives me this output:

Just remember to process your file twice every time you change the mode, so that all hyperlinks and bookmarks are updated properly.

Tuesday, July 12, 2011

DIA + Lyx

Before I discover DIA, I used Microsoft Visio for schematic drawing to be included into my documents. The schematic drawn has to be exported into a graphic file, in which I prefer .png format. Then only it can be included in .tex document as a graphic.

Then I found DIA. You can search the web for more info on the software itself. In short, it is an open source software Lyx as well. What I found to be helpful is that, DIA has an extension to convert .dia files, where you save the schematic drawing, into graphic files in the format of .png which can be called directly by Lyx.

What I have to do is, draw whatever schematic that I want, save it in .dia format. Then in Lyx, insert the graphic as usual. At the graphic file name field, insert the .dia file name. Lyx will treat that as the graphic file where you can resize etc. similar to any graphic files included using the method. 

Another setting to be done is that to let Lyx know where to fine the DIA extension to convert .dia file to .png file so that Lyx can call it upon generating final document. The setting can be found under menu Tools > Preferences and under File Handling > Converters tab. Under From format pulldown menu, search for DIA and under To format pulldown menu, search for PNG. In Converter field, insert this
dia -e $$o -t png $$i
and click Add button. That is it. Now you can use .dia file directly to include graphic into you document. Happy trying. See you soon.

Sunday, July 10, 2011

Unexplained error

I faced this kind of error before. What I mean by unexplained is that the location of error shown by Lyx does not contain any error. Sometime it is just one word without any LaTeX command at the location. By the way, I should mention for the benefit of newcomer, Lyx will highlight the supposedly error location. In this case of error, the highlight is at random location and you can explain what is the actual error. The unexplained error usually occurs, at least I experienced it, once I include a citation. I use BibTeX to generate reference list. The .bib file is linked to the Lyx file and once a citation is included, BibTeX will run the process of creating the list. Error will occur if the bib database contains error, usually it has an illegal character. You know, citation info can be exported directly from publisher's webpage or even from Google Scholar page. The auto export function is the culprit of the error. Some of the article title or even the name of authors can have illegal characters. Most of it is characters like % and &, which is the command character in LaTeX. So, the errors can be overcomed by making sure that the bib database doesn't have any of this illegal characters. That will it for now. See you soon!
Published with Blogger-droid v1.7.2

Saturday, July 2, 2011

Getting started with Lyx

Well, to get started with Lyx is pretty straight forward. Of course you have to install the software, which you can download from lyx.org. The installation is again, straight forward. No much hassle. Just say yes to all the question. Unless you want to tweak some features.
Basically it is just like using word processor (Microsoft of OpenOffice or LibreOffice). Create a new file, then you are almost ready to go. If you are using source code editor, first command you put in is
Well, you have to do the same with Lyx. The function can be found in menu Document > Settings. Here basically you can do all the setting necessary. You can select the class file from dropdown menu under Document Class tab. By default, there are few classes already installed in Lyx. That includes article, IEEEtran, elsarticle, beamer (if I not mistaken), book etc. If the class is not installed, it will be marked as Unavailable.
To make a class available in Lyx dropdown menu, you have to create the layout file. It will link the class to the ui of Lyx so that it can be shown. Creating a layout file is very easy. Here is the most basic layout file that can work with any class file.
#% Do not delete the line below; configure depends on this
# \DeclareLaTeXClass[classfilename]{name-to-appear-in-dropdown-menu}
input stdclass.inc
With that the class file can already work provided that it is saved with the same file name as the class file name, i.e. the class file is myclass.cls, therefore the layout file should be named, myclass.layout. As simple as that.
To include the layout in the dropdown list, you have to save the layout file in layouts folder in Lyx program folder and reconfigure Lyx through menu Tools > Reconfigure and close and reopen Lyx afterwards. Or, if you don't want it listed, you can just use local layout option (there is a local layout button next to the dropdown menu). However, using this option, you must have the layout file in the same folder as your document file.
If you have zero knowledge of LaTeX, don't worry. Once you have selected the document class, you can start entering document content. On top left corner, just below File menu, there is a dropdown menu with option Standard as default. This is called style picker. Standard is for normal text. Here you can select title, author, section, chapter, section*, theorem etc. depending on what is available in class and defined in layout. To change you text into certain style, you don't have to select text, just simply put the cursor anywhere in the text line, and change the style. Now you can start typing the content.
I think that should be it for now. Next time, we will see how to add more than text in Lyx. Until then, happy LaTeXing.

Thursday, June 30, 2011

Wuerzburg Beamer Theme

I’ve received a few enquiries about the Beamer theme of my MOSC2011 slides. This beautiful, subtle theme is wuerzburg (scroll down to “LaTeX Beamer Themes”), created by Christian Gogolin.

Basic usage and the output:


Depending on your mood, you might want to go for a more ‘polished’ feel:


See the comments in the .sty files for more options.

Saturday, June 25, 2011

WYSIWYM editor

LaTeX users would know that there are two types of editor, source code type and WYSIWYM type.

But first, thank you to Najmi and Lian Tze for inviting me to share something here. It is a great honor to do so. Knowledge kept to oneself has no price but knowledge shared is priceless.

I guess Najmi and Lian Tze can cover the source code editor type since they are way more experienced than me. I started using and learning to use it on a WYSIWYM editor. Lyx to be specific. You can check www.lyx.org or wiki.lyx.org for info on the software itself. With it I started to discover a lot of magnificent thing and I fall in love with LaTeX.

However, now I use less Lyx because I feel it limits my creativity to customize the output document. But nevertheless, I still think that Lyx can provide a soft and smooth transition from other WYSIWYG type word processor.

As like many other open source software, Lyx can be installed on machine running Windows, Linux and MacOS. They have just launch a 2.x.x version in May to mark their 15 years of existence.

In Lyx, apart from class and style files, there are one more file type native to it only called layout file. This file controls the look of your document on the Lyx interface. If you type a chapter heading, you want to to appear center align, bold and blue in color, you control it with layout file. But bear in mind that, what appears on Lyx interface is not necessarily what appeared in the final output document. Because layout and class file are different in nature, although must be same in filename.

Lyx come with some pretty standard group of layout files for some popular class files like IEEETran, Elsarticle, beamer etc. But if you create your own class file, you might want to create you own layout file so that it can be included in Lyx. Without layout file, you can't call the class file.

That is all for now. Next time, how to start using Lyx with zero knowledge of LaTeX. Stay tune!

Thursday, June 23, 2011

Book Review: LaTeX Beginner’s Guide

(Thanks to Packt for the complimentary eBook copy for this review.)

When I read about the publication of the book on various forums and blogs, my interest was definitely piqued: the author, Stefan Kottwitz, is a frequent and helpful contributor/moderator on TEX.SX. On the other hand I wondered if anyone would actually want to buy an introductory book to LaTeX, considering the many free tutorials and eBooks available on the Web (although there are many out-of-date ones, so beware! See some recommended ones at the end of this post).

After a quick flip — erm, clicks with the mouse — through my complimentary eBook copy courtesy of Packt, I felt the answer was a very firm “YES”. First off, this is certainly an up-to-date book with descriptions of recent packages, and warnings about obsolete ones. While the first few chapter headings read like most other beginner’s guide to LaTeX, Kottwitz’s approach of using complete step-by-step examples throughout the book is something seldom seen in other books or tutorials. By that I mean you don’t just get the first few handful of “Hello World” examples, but for much more advanced usage scenarios as well. (BTW, The examples are based on TeXLive and TeXworks.)

Your mileage may vary, but I do feel that such a hand-holding approach (that’s what my training course had been described as) — at least in the early days of learning LaTeX — is very reassuring. Especially so since LaTeX can be rather intimidating for people who have only used WYSIWYG word processors before. Pop quizzes are interspersed throughout the content (answers in the appendix).

The book has 13 chapters on the following topics:
  1. Getting Started with LaTeX
  2. Formatting Words, Lines, and Paragraphs
  3. Designing Pages
  4. Creating Lists
  5. Creating Tables and Inserting Pictures
  6. Cross-Referencing
  7. Listing Content and References
  8. Typing Math Formulas
  9. Using Fonts
  10. Developing Large Documents
  11. Enhancing Your Documents Further
  12. Troubleshooting
  13. Using Online Resources

While the early chapter headings are kind of expected of any beginner’s guides, they do still contain valuable nuggets. For example, the microtype package is introduced in Chapter 2, as is how to define your own macros with \newcommand. Imagine a beginner’s joy at the even more beautiful typesetting afforded by microtype. And the new-found freedom of defining one’s own commands for consistent typesetting of certain materials. Personally I think such tips, introduced at an early stage, would boost beginner’s confidence in using LaTeX.

While some might consider the installation instructions of TeXLive and TeXworks in Chapter 1 as frivolous, I certainly welcome the instructions on how to install extra packages in Chapter 11.

Chapter 3 on designing pages is particularly useful, as this seems to be one of the most frequently asked beginner’s questions these days. (at least, indicated by the fact that the post on setting page sizes and margins being the 5th all-time most favorite post on this blog.)

I also like the mention of getnonfreefonts in the chapter on fonts. Another favorite chapter of mine is that on Troubleshooting, as this is definitely one of the most important skills if one is to use (and learn!) LaTeX. And everyone who’s going to write a thesis or a business report will definitely want to read Chapter 10 on large documents.

Overall, the book does cover everything a beginner should learn about LaTeX, IMHO anyway. My only nitpicks are that the LaTeX logo isn’t typeset ‘properly’ in the text; and that the LaTeXed output images seem a tad blurry in the PDF eBook version. But these are just petty nitpicks, really.

So do I recommend LaTeX Beginner’s Guide for people interested in learning LaTeX? I’d say Yes. This would be a very nice addition to libraries, or as a communal copy in a research lab, so that newly registered graduate students who’re not yet quite busy with their research can spend their first month learning up LaTeX with it. (You can, of course, get your very own copy; I only mention a communal copy as I know some Malaysians — especially poor grad students — might be reluctant to fork out about RM120 for a book. Everyone really should fork out money to buy a good book sometime, though.)

The book is available as a printed copy (£25.19), eBook copy (£16.14), or multi-format (£28.04). Shipping is free if you’re in UK, US, Europe, Brunei, Hong Kong, Indonesia, Japan, Malaysia, Philippines, Korea, Singapore, Thailand, China, Macau and Taiwan — sweet!

Further Reading

Having said all that, you’ll probably want to complement this beginner’s guide with other, more reference-typed books, such as the LaTeX Companion (I don’t know if the books are available separately), as well as some free (often rather shorter) tutorials and eBooks:
  • Getting to Grips with LaTeX. A personal favorite short beginner’s tutorial.
  • The LaTeX WikiBook. A nice quick online reference.
  • LaTeX and Friends. This is truly a very comprehensive up-to-date eBook for reference purposes (but it does not have complete examples as Kottwitz’s book does). I understand that the author is still updating it from time to time.

Monday, June 20, 2011

LaTeX: More Than Just Academic Papers and Theses

Update 2 July 2011: OK source code uploaded per request, see link below.

So my slides for the talk on LaTeX during MOSC2011 are done and available for download. (This version without animations etc. to minimise the file size. Updated and corrected 30 June 2011; Thanks to Stefan Kottwitz, Felipe and Per for pointing out some mistakes.)

As mentioned before, it won’t be a tutorial, rather I plan to give teasers of what LaTeX is capable of beyond the usual journal or conference articles. I have undoubtedly left out many interesting use cases, so please don’t flog me if I haven’t included your favorite package or class! ;-) But do drop me a line and we’ll do a future post on it.

(Update: See this post about the Beamer theme used for the slides.)

Typesetting SI Units

Most people would already have heard of the siunitx package, but in case you haven’t, here’s a small, humble request:

Please use the siunitx package more to typeset your measurements. Please. I beg you. It’s so much easier and makes things look so much more professional.
(Yes, this is going to be a rather ranty post, but don’t worry, I’ll keep it short.)

I mean, just compare the output when using siunitx:


And doing it manually:

$3.563 \times 10^4$ V$^2$ lm$^3$ F$^{-1}$

I rest my case. And if you’re not convinced yet, you can also do lists and ranges of values like this:


So please. Start using siunitx.