Category Archives: LaTex

Adding LaTex styles to user directory

I just learned the following tricks about how to add LaTex styles to a user directory (with no admin privileges).

1) Use the following command in shell to check out TeX variable $TEXINPTUS:

$ kpsewhich -expand-var ‘$TEXINPUTS’
, which generates output likes the following:

{/users/biobeat/.texlive2007/texmf-config,/users/biobeat/.texlive2007/texmf-var,/users/biobeat/texmf,/etc/texmf,!!/var/lib/texmf,!!/usr/local/share/texmf,!!/usr/share/texmf,!!/usr/share/texmf}/tex/{kpsewhich,generic,}//

Please notice that that “/users/biobetat/texmf” is used.

2) Now we can add all the style file collections there, or a subdirectory of that path. Below is where I put my files.

$ ls ~/texmf/tex/latex/mycls/
spbasic.bst spmpsci.bst spphys.bst svind.ist svmono.cls

Write Technical Notes with listings Package in LaTex

LaTex is an ideal tool for writing technical notes. There is even a package, named listings,  to add non-formatted text such as computer source code. This URL shows you how to use it. And, R, Python, C/C++, and Perl are all supported.

To use listing package with the beamer presentation environment of LaTex, one needs to use \begin{frame}[fragile] (note the added [fragile] option) to make it work.

Prefix figure numbers in Appendix in LaTex

The following code will use “Figure S[1, 2, ..]” for figures in appendix.

\makeatletter
\renewcommand{\thefigure}{S\@arabic\c@figure}
\makeatletter

If “Supplementary Figure” instead of “Figure” is preferred, one can use the following command:

\renewcommand{\figurename}{Supplementary Figure}

Similarly, to put “S” before equation numbers (e.g. [S1], [S2], instead of [1], [2]), one can use the following command:

\makeatletter

\renewcommand{\theequation}{S\@arabic\c@equation}

\makeatletter