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 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)
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):
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
Wednesday, October 17, 2012
Drawing xkcd-style Plots and Diagrams with LaTeX
Monday, October 8, 2012
Updates for mmuthesis and umalayathesis
mmuthesis
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.
umalayathesis
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
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
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
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:\usepackage{draftwatermark} \usepackage{datetime} \ddmmyydate \SetWatermarkLightness{.9} \SetWatermarkText{Draft\string@\today} \SetWatermarkScale{.6}
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!
Friday, June 22, 2012
LaTeX and Graphics Contest
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
Beamer
Sunday, June 3, 2012
More Ways to Typeset CJK
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:\usepackage{fontspec}
\usepackage{xeCJK}
% Sets font for Roman text.
% There are also \setsansfont, \setmonofont.
% See fontspec documentation.
\setmainfont{Baskerville}
% Traditional Chinese typesetting has no "bold" nor "italic".
% 黑体 ("blackbody") and 楷体 ("regular script") fonts are
% used instead.
\setCJKmainfont[BoldFont=Hei,ItalicFont=Kai]{STSong}
\setCJKsansfont{Hiragino Sans GB}
\setCJKmonofont{STFangsong}
\begin{document}
春眠不觉晓,\emph{处处}闻\textbf{啼鸟}。
\textsf{夜来风雨声,}\texttt{花落知多少?}
\end{document}
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:
\usepackage{zhmCJK}
\setCJKmainfont[BoldFont=simhei.ttf, ItalicFont=simkai.ttf]{HanNomA.ttf}
\begin{document}
世界,你好!
\end{document}
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
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
Tuesday, April 24, 2012
LaTeX Template Website
Tuesday, April 17, 2012
TeX4ht Options
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
Saturday, March 17, 2012
Working collaboratively.. which one you prefer?
Converting an EndNote Database to BibTeX
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.- Put
BibTeX_Export_LLT.ens
(download) in%ENDNOTE%/Styles/
. - Start EndNotes, and load your library.
- Make sure the new style is listed:
Edit > Output Styles > Open Style Manager
Make sureBibTeX_Export_LLT
is checked. - File > Export
Make sure Save File as Type is set to Text Only, and Output Style is set toBibTeX_Export_LLT
. - Save your file and check that it has a
.bib
extension. - 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. -
Ctrl+A
to select all the BibTeX entreis, Tools > Autogenerate BibTeX keys. - 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
\usepackage{pst-fun}
\begin{document}
\begin{pspicture}(-1, -2)(13,10)
\psParrot{.8}
\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}
\end{pspicture}
\end{document}
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
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
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.\usepackage[backend=biber,bibstyle=authoryear,sorting=ydnt]{biblatex}
\usepackage{graphicx}
\bibliography{publications}
\usepackage{hyperref}
\ExecuteBibliographyOptions{doi=false,url=false}
\newbibmacro{string+hyperlink}[1]{%
\iffieldundef{url}{%
\iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
{\href{\thefield{url}}{#1}}}
\DeclareFieldFormat*{title}{\usebibmacro{string+hyperlink}{#1}}
\newbibmacro{usera}{%
\iffieldundef{usera}{}{%
\savefield*{usera}{\filename}%
\usebibmacro{string+hyperlink}{\includegraphics[width=100pt]{\filename}}\\}%
}
\AtEveryBibitem{\usebibmacro{usera}}
\begin{document}
\section{My Academic Portfolio}
\nocite{*}
\printbibliography[title={Articles},type={article}]
\printbibliography[title={Conference Proceedings},type={inproceedings}]
\end{document}
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:$ 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, February 3, 2012
Friday, January 20, 2012
Mail-Merge Batch Generating Documents with datatool Package
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:
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:\documentclass[16pt]{scrartcl}
\usepackage[left=3cm,right=3cm,top=6cm,bottom=5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgschola}
\usepackage{fourier-orns}
\usepackage{graphicx}
\usepackage{wallpaper} % For background image frame
\usepackage{datatool}
% Load database 'names' from file 'namelist.csv'
\DTLloaddb{names}{namelist.csv}
\begin{document}
\linespread{2}\selectfont
\pagestyle{empty}
% Set old-border.jpg as background image
\TileWallPaper{\paperwidth}{\paperheight}{old-border}
% For each record (line) in database 'names'
% Assign field values by name to macros
\DTLforeach{names}
{\name=Name, \ID=ID, \gender=Gender, \yr={Years in Service}}{
{\centering
{\LARGE\bfseries Certificate of Appreciation}\par
{\LARGE\decofourleft\quad\decoone\quad\decofourright}\par
\vskip2em
We thank\par
% Insert '\name' field
{\large\bfseries\MakeUppercase{\name}}\par
% 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
\vskip1em
% 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
}
\vfill
\hfill
\begin{minipage}{.4\textwidth}
Managing Director\par
\vskip1cm
\rule{8em}{.5pt}
\vskip-1em
(MD's Name)\par
\end{minipage}
\pagebreak
}
\end{document}
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
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
Sunday, January 8, 2012
Text-to-Path Conversion with Ghostscript
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.