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

Wednesday, September 21, 2011

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:

\documentclass{beamer}
\usetheme{Skudai}

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

\begin{document}

\begin{frame}[t]
\titlepage
\end{frame}

\begin{frame}
\frametitle{First Frame}
My content
\end{frame}

\end{document}

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

Hi,

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

\begin{pspicture}(-12pt,-6pt)(3.4,1in)
\psbarcode{9781860742712}{includetext}{ean13}
\end{pspicture}


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


\begin{pspicture}(1in,1in)
\psbarcode{Herbert Voss ^142^164^186}
{rows=48 columns=48 parse}{datamatrix}
\end{pspicture}


\begin{pspicture}(-.5cm,-.7cm)(8,0.3in)
\psbarcode{0123456709498765432101234567891}
{includetext}{onecode}
\end{pspicture}


\begin{pspicture}(2in,2in)
\psbarcode{http://latex-my.blogspot.com/}
{}{qrcode}
\end{pspicture}



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
\begin{pspicture}(2in,2in)
\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}
\end{pspicture}



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%
\begin{pspicture}(2in,2in)
\psbarcode{BEGIN:VCARD^^J%
VERSION:3.0^^J%
N:Lian Tze;Lim^^J%
FN:Lim Lian Tze^^J%
PHOTO;VALUE=URL;TYPE=JPG:http://liantze.penguinattack.org/images/LLT-profile.jpg^^J%
TEL:+60123456789^^J%
ADR:;;109 Lorong Oak 47, Taman Oak;Butterworth;Pulau Pinang;13000;Malaysia^^J%
EMAIL:liantze\string@gmail.com^^J%
URL:http://liantze.penguinattack.org/^^J%
END:VCARD}
{eclevel=M height=2 width=2}{qrcode}
\end{pspicture}



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%
\begin{pspicture}(2in,2in)
\psbarcode{BEGIN:VCALENDAR^^J%
VERSION:2.0^^J%
BEGIN:VEVENT^^J%
SUMMARY:25th Pacific Asia Conference on Language, Information and Computation^^J%
ORGANIZER;CN=Assoc Prof Francis Bond:MAILTO:fcbond@ntu.edu.sg^^J%
URL:http://portal.cohass.ntu.edu.sg/PACLIC25/^^J%
LOCATION:Nanyang Technological University, Singapore^^J%
DTSTART;TZID=Asia/Singapore:20111216T090000^^J%
DTEND;TZID=Asia/Singapore:20111218T180000^^J%
END:VEVENT^^J%
END:VCALENDAR}
{eclevel=M height=2 width=2}{qrcode}
\end{pspicture}



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:

\usepackage{pst-barcode}
\usepackage{auto-pdf-pst}

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

\documentclass{beamer}
\usetheme{Manhattan}

\begin{document}
\begin{frame}
\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.
\end{theorem}
\pause
\begin{itemize}
\item<+-> First item in a list
\begin{enumerate}
\item<+-> First item in a list
\item<+-> Second item in a list
\end{enumerate}
\item<+-> Second item in a list
\end{itemize}
\end{frame}
...
\end{document}



For archival and distribution purposes, I usually invoke

\documentclass[trans]{beamer}

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{beamer}
% \documentclass[handout]{beamer}
% \documentclass[trans]{beamer}


\mode<beamer|trans>{
\usetheme{Manhattan}
}

\mode<handout>{
\usetheme{default}
\usepackage{pgfpages,pgf}
\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.