Posts Tagged ‘tex’


Highlight a name in BibTeX Bibliography

In howto on Jan 24, 2016 by theoryl Tagged: , ,

How to highlight a particular author’s name in the bibliography when using BibTeX? This was asked on TeX Stack Exchange. I didn’t like the top answer as much as the third answer. Simply edit the .bst file and add a function that highlights your name:

{ duplicate$ purify$ "YOURNAME" purify$ =
    { bold }

(Here I chose to bold the name)

Then, look for the string “$” in the .bst file, and call the function right after it, e.g.

FUNCTION {format.names}

A related modification you can make in the .bst file is to turn DOI into a hyperlink. Look for the string “doi *”, change it to:

FUNCTION { format.doi } {
        "\href{" doi * "}{DOI: " * doi * "}" *


Font Awesome in pdfTeX

In howto on Jan 15, 2016 by theoryl Tagged: , , , , , , ,

Font Awesome is a font that provides scalable icons that can easily be used in text. It can even be used in TeX!

This is for pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian), which I obtained directly from the Ubuntu 14.04 official repository. The fontawesome package (v3.1.1) in this distribution does not work with pdfLaTeX. (It can only be used with XeLaTeX or LuaLaTeX.) But the latest version of fontawesome (v4.4.0 2015-07-30) includes type1 conversion of the font and is usable with pdfLaTeX. See for more detail.

The zip file available for download from CTAN does not have the correct “TDS” layout though, so it cannot be directly installed. See for detail.

Thus, to really install fontawesome, the following is what I did. First, download the zip file.


Unzip it.


Put the files according to the correct layout (see in the local “texmf” area: ~/texmf/.

mkdir -p ~/texmf/
mkdir -p ~/texmf/doc/fonts/fontawesome/
mkdir -p ~/texmf/fonts/enc/dvips/fontawesome/
mkdir -p ~/texmf/fonts/map/dvips/fontawesome/
mkdir -p ~/texmf/fonts/opentype/public/fontawesome/
mkdir -p ~/texmf/fonts/tfm/public/fontawesome/
mkdir -p ~/texmf/fonts/type1/public/fontawesome/
mkdir -p ~/texmf/tex/latex/fontawesome/

cd fontawesome
mv ~/texmf/doc/fonts/fontawesome/
mv doc/* ~/texmf/doc/fonts/fontawesome/
mv enc/* ~/texmf/fonts/enc/dvips/fontawesome/
mv map/* ~/texmf/fonts/map/dvips/fontawesome/
mv opentype/* ~/texmf/fonts/opentype/public/fontawesome/
mv tfm/* ~/texmf/fonts/tfm/public/fontawesome/
mv type1/* ~/texmf/fonts/type1/public/fontawesome/
mv tex/* ~/texmf/tex/latex/fontawesome/

cd ..
rm -rf fontawesome

Finish the installation. See


Verify that the map file has been registered.


Now, try to pdfLaTeX this guy:



{Normal \faAdjust}
{\Huge Huge \faAdjust}


If pdfLaTeX doesn’t complain, you’re good!


TeX Live 2012 on Linux Mint Maya

In howto on Apr 5, 2014 by theoryl Tagged: , , , , , ,

Ubuntu 12.04 is distributed with a really old version of TeX Live: TeX Live 2009. Fortunately, TeX Live 2012 is available in Ubuntu 12.10 and is backported to 12.04 via a ppa (Thanks!). Since Linux Mint Maya is based on Ubuntu 12.04, it can install the TeX Live version provided by the PPA.

There are numerous answers of how to do that, such as: How do I install the latest TeX Live 2012? (askubuntu), Problems installing TeX Live 2012 on 12.04 (askubuntu), How to remove everything related to TeX Live for fresh install on Ubuntu? (stackexchange)

The following is what I did. If you have never installed TeX before, skip to the next section. Else, let’s uninstall the existing TeX so that you can make a clean installation:

sudo apt-get purge texlive*
# Some of the following might not apply
#sudo rm -rf /usr/local/texlive/2012/
sudo rm -rf /usr/share/texmf/
sudo rm -rf /usr/local/share/texmf/
sudo rm -rf /var/lib/texmf/
sudo rm -rf /var/lib/tex-common/
sudo rm -rf /etc/texmf/
#rm -rf ~/.texlive/
rm -rf ~/.texmf-var/
sudo apt-get purge tex-common
sudo apt-get autoremove
sudo apt-get autoclean

Now add the PPA to you system:

sudo add-apt-repository ppa:texlive-backports/ppa
sudo apt-get update

Now ready to install TeX Live 2012

sudo apt-get install texlive-full

To test whether it’s installed successfully, try calling tex. I got the following prompt:

This is TeX, Version 3.1415926 (TeX Live 2012/Debian)


rst2wiki with math support

In howto on Jul 3, 2012 by theoryl Tagged: , , , , , ,

Another post about reStructuredText: can you convert reStructuredText into Wiki format? I found in Docutils sandbox a tool: rst2wiki. It currently supports conversion to TWiki and Atlassian Confluence. rst2wiki is available through SVN (web-access)

In Docutils >= 0.8, there is “math” support; on the other hand, TWiki can display LaTeX equations if MathModePlugin is installed and set up properly. The syntax is

<latex [attr="value"]* > formula </latex>

In order to use rst2wiki with math support, we will modify In class WikiTranslator, add:

    # Start Math
    def visit_math(self, node):
        if self.math_start:

    def depart_math(self, node):
        if self.math_end:
    # End Math

In class TWikiTranslator, add:

        self.math_start = '<latex>'
        self.math_end = '</latex>'

Done :)


Beamer presentation using LaTeX

In howto on Nov 27, 2011 by theoryl Tagged: , , , , ,

\textsc{Beamer} is a presentation tool that utilizes the powers of \LaTeX to produce high quality presentations in .pdf format. It gives an alternative to Microsoft PowerPoint and OpenOffice/LibreOffice Impress. Most importantly, it allows users to worry about the content and the style separately.

Recently, Beamer has moved from sourceforge to bitbucket: On their new homepage, the installation procedure is not well documented. In particular, downloading and using directly the Beamer source from bitbucket doesn’t function properly. (Apparently it’s due to Mercurial RCS, as documented in bug #10).

There are two better ways to install Beamer on Ubuntu Lucid Lynx 10.04. To install from the repository, just do:

sudo apt-get install latex-beamer

This will give you Beamer version 3.07 (which is slightly more than 2 years old now, as is the tevlive 2009 package).

To take advantage of the latest version, download the .zip file from CTAN: (In the following, it’s assumed that texlive has been installed.) The texmf tree used by the Beamer version from the repo is /usr/share/texmf/tex/latex/beamer. You can replace the beamer directory with the one you extracted from the .zip file. Alternatively, you can put the newer version in the local texmf tree at /usr/local/share/texmf/tex/latex/beamer. This allows you to keep both copies and uses the local version when latex or pdflatex is called. Do texhash or mktexlsr to finish the installation.

The Beamer user guide can be found either from CTAN or by latex-ing the source in the doc directory from the downloaded .zip file. A more useful Quick Start guide can be found here.


Using REVTeX 4.1 on Ubuntu

In howto on Oct 30, 2011 by theoryl Tagged: , , , , , , ,

At the time of writing, the \LaTeX package is provided by texlive or texlive-full (version 2009-7) in Ubuntu Lucid Lynx 10.04 (see community Ubuntu documentation, TeX Live homepage). American Physical Society (APS) and American Institute of Physics (AIP) require that submissions to their journals are typeset in \LaTeX using the REVTeX package. REVTeX has dependencies on AMS-LaTeX and natbib, both of which should come with the default installation of texlive-full. Moving on to install REVTeX 4.1 (released in August 2010), first download the .zip file from the APS page (or from its CTAN directory). Inside the .zip file, there is a README file (take a look at it) and yet another .zip file:

The files and directories inside follow the standard TeX Directory Structure (TDS) layout. Assuming that texlive was installed from the Ubuntu repository, then the local TeX distribution should sit at /usr/share/texmf-texlive. All you need to do is unzipping:

sudo unzip -d /usr/share/texmf-texlive/

Then update the \LaTeX package cache:

sudo texhash

The APS page has a section “Common Problems When First Using REVTeX 4.1”. In particular, REVTeX requires natbib 8.31a or later. The latest natbib can be easily downloaded from CTAN. Unzip the file you downloaded, cd into the directory, and do latex bibentry.ins. This will produce natbib.sty. Now copy the full directory to overwrite the one at /usr/share/texmf-texlive/tex/latex/natbib. Remember to update the \LaTeX package cache again:

sudo texhash

To start using REVTeX, insert the following commands into your .tex file:

\documentclass[aps,preprint,amsmath,amssymb]{revtex4-1}% APS journal style
\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage{hyperref}% add hypertext capabilities
\bibliography{basename of .bib file}

You can find other useful information on the REVTeX FAQ page.


Using mathrsfs script fonts in MediaWiki

In howto on Jan 28, 2011 by theoryl Tagged: , , , , , , , ,

This is in Ubuntu Lucid Lynx 10.04:

The RSFS fonts give you very nice script fonts:

The top row shows the fonts from the command \mathscr while the bottom from \mathcal, which \LaTeX users should be more familiar with.

In order to use the RSFS fonts in \LaTeX, you would add the preamble \usepackage{mathrsfs} in the .tex file. But what if you want to use the RSFS fonts in MediaWiki (the software that powers the Wikipedia), which by default does not include the preamble?

It turns out that you have to compile texvc (the \LaTeX interpreter incorporated into MediaWiki) with some slight modifications to (located in the source directory mediawiki/math). Basically, you want to add the preamble into that file. Below is what I did:

  • First, make sure you have installed mathrsfs.sty in the \LaTeX environment. If not, you can download it from In Ubuntu 10.04, it should be located at /usr/share/texmf-texlive/tex/latex/jknapltx/mathrsfs.sty.
  • Get the MediaWiki source from repo: sudo apt-get source mediawiki. Install all the dependencies as well.
  • Get its compiler: sudo apt-get install ocaml-nox gcc.
  • Now cd to the math directory: cd /var/lib/mediawiki/mediawiki-1.15.1/math
  • Edit the file Find the line beginning with: (if !modules_ams then "\\usepackage{amsmath}\n
  • Now, add: "\\usepackage(mathrsfs)\n" among the preambles.
  • Add another line close to the end of the file: | "\\mathscr" -> (tex_use_ams (); FUN_AR1 "\\mathscr ").
  • Compile: sudo make
  • After it is compiled successfully, copy the executable: sudo cp texvc /usr/bin

Make sure TeX is enabled in MediaWiki config file LocalSettings.php. If not, append the line to the file: $wgUseTeX = true ;.

That’s it. You should be able to use the command \mathscr in your MediaWiki!