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...

Friday, April 22, 2011

Making Leaflets with LaTeX

Just for fun, I thought I’d make some leaflets to accompany my poster presentation during a recent conference. It would be nice if I could reuse materials from my paper and poster, so I sought for a LaTeX solution, and that solution was the leaflet document class. It automatically sets up a layout for 6 small pages on 2 normal-sized paper pages, so that you can print the output PDF out on double pages, then fold it up into a real, er, leaflet.

Here are the thumbnails of my leaflet, and here are the source code. Notice the little mark (highlighted by the red circle) on the second page to guide you in folding the leaflet. Just make sure that you set your PDF viewer to “Do not scale pages” when printing the PDF.


Saturday, April 16, 2011

Using Relative Units in TikZ Drawings

I used to happily create TikZ drawings with pt units, let’s say in a paper using the IEEE style:

\documentclass{IEEEtran}
\usepackage{tikz}
\uaetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\node[text width=60pt] (mor){Morphological Analysis};
\node[text width=35pt,right=12pt of mor] (syn) {Syntactic Analysis};
\draw[-latex] (mor) -- (syn);
\end{tikzpicture}
\end{document}

The output looks good enough, although I did have to try several times getting the text widths right:


But often times I’d want to reuse my TikZ code in other documents, e.g. a Beamer presentation, or my thesis in which I must use Times 11pt. But when I happily copied over my Tikz snippet over, I get:

\documentclass{beamer}
...
\begin{tikzpicture}
...
\end{tikzpicture}
...

\documentclass[11pt]{memoir}
\usepackage{mathptmx}
...
\begin{tikzpicture}
...
\end{tikzpicture}
...

Ouch, it looks like I need to figure out the different text width values in pts by trial and error, for each document I want to include my picture in!

Or do I?

The real issue here is that pt is an absolute unit (1pt = 1/72 inch), so my TikZ node’s text width stays the same while the font metrics is different in each document. Using relative units, like em or ex, would make my life a lot easier.

Let me explain: 1em is the height of the current typeface in the current size, and is a little bit wider than a capital ‘M’. This means the length/width 1em depends on the active font family and size.

And as a rough estimate, a capital ‘M’ is twice as long as a lowercase letter. ‘Morphological’ has 1 ‘M’ and 12 lower case letters, but 3 of these are ‘thin’ letters (‘l’ and ‘i’), so I’d go with 6em rather then 7. Similarly, I’d try 4em for ‘Syntactic Analysis’.

Let’s see the results, using the same TikZ code in all three versions (IEEE paper, beamer and typical thesis):

\documentclass{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\tikzset{every node/.style={draw,align=center}}
\node[text width=6em] (mor){Morphological Analysis};
\node[text width=4em,right=1em of mor] (syn) {Syntactic Analysis};
\draw[-latex] (mor) -- (syn);
\end{tikzpicture}
\end{frame}
\end{document}

\documentclass{beamer}
...
\begin{tikzpicture}
\...
\end{tikzpicture}
...

\documentclass[11pt]{memoir}
\usepackage{mathptmx}
...
\begin{tikzpicture}
...
\end{tikzpicture}
...

There! The text widths would vary relative to the current font families and sizes in use, so I won’t have to fiddle around with pt values for every new document I want to incorporate my existing TikZ code.

Sunday, March 20, 2011

Creating Academic Posters (and Printing Them)

I presented a poster paper at CICLing 2011 in Tokyo (that was the end of February so I wasn’t there during the earthquake, but it seems the organising committee members are all alright, thank heavens) and I naturally created my poster with LaTeX. Here’s a thumbnail of my poster:


I created this A0-sized poster (source code the TikZ drawings and CJK characters are externalised as PDF graphics and the bibliography embedded, so it should be compilable on most LaTeX installations without extra packages) with the beamerposter package, mainly by modifying Rob Hyndman’s style file. (There are other packages for creating posters in LaTeX, see this link for an overview.)

You can download my .sty and a simple sample poster .tex files here. I’ve put the colour themes (ComingClean in the left thumbnail, ConspiciousCreep on the right, inspired by this and this respectively) in their own separate .sty files. ConspiciousCreep is probably not so suitable for an academic poster… but perhaps it could be useful for a not-so-serious occasion.


Note that the sample poster is A1-sized; change the poster size in the .tex file as you require. I also defined a \footimage command that can be used to put whatever material you want in the bottom right hand corner. (I included photos of the authors in my poster not because of vanity, but because the organisers asked us to do so, so that it’d be easier for participants to locate the relevant authors.)

I brought my A0-sized PDF along to a printing shop who happily printed it out on one glorious giant A0-sized synthetic paper material. However, if you have trouble finding a printing shop who can print out these big sizes, you can use the pdfposter utility (available on all major GNU/Linux distros) to process your PDF into smaller-sized tiles. For example, if the input LLTposter-sample.pdf is A1-sized, then

pdfposter -s1 -ma4 LLTposter-sample.pdf a4tiles.pdf

will take the input file LLTposter-sample.pdf, split it into 8 A4 pages and save them in a4tiles.pdf. You can then print out the A4 pages and assemble them back into an A1-sized poster at the conference venue. (-s1 means no resizing of the original poster size, hence A1 as the result.) Enjoy!

Friday, November 26, 2010

Coffee stains on your PDF docs

It's funny and seems pointless, but you may want to play around

Taken from here

Here what I got:



And important point is that, it does not work with pdflatex, use latex compiler instead

(Thanks Toriq for this package. How on earth did you ever came across this package anyway? ;) )

Update: coffee2.sty works with pdflatex, thanks Sharuzzaman and Curutari for pointing that out. I didn't check the current sty after I downloaded the old one.

Wednesday, November 17, 2010

“Why isn’t Arial in my LaTeX installation by default?”

“Or Cooper Black, or a bunch of other fonts? They’re free, aren’t they? They’re already there on my computer!”

If you’ve ever wondered about this, this article on Free Fonts: Free Is Not Always Free may help you understand some of the underlying issues about font licensing. (Some people would argue that the M$-bundled fonts are of inferior quality compared to the real stuff anyway e.g. Times Roman, Helvetica etc)

On the other hand, rest assured that all is not lost as there are free clones of many of such fonts that you can use in your LaTeX documents anyway.

For example, \usepackage{mathptmx} loads Nimbus Roman, a look-alike for Times Roman, while \usepackage{helvet} loads Nimbus Sans to stand in for Helvetica, which is pretty much indistinguishable from Arial — to the untrained eye anyway.

One last thing: You can still use some non-free fonts: install them using the getnonfreefonts script.

One really last thing: The last thing I want to do is to start a font war on this blog, so please spare me the hate mails! ;-)

Friday, November 12, 2010

TeX, LaTeX and Friends Out of Beta

The community-driven LaTeX-specific Q&A site: TeX, LaTeX and Friends is now out of beta and has a new design. I’m most pleased to see the Tengwar Ring-lore in the top left corner! :-D

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.