16 May 2006

Some of my LaTeX tricks

Every mathematician of the last 20 years should have their personal bag of LaTeX tricks. Here's a couple of mine:

  • Graphics. This, in particular, is an area where everyone has their own tricks. My standard procedure is as follows:
    • Create some graphic in XFig, making sure that all text is marked special. (You can do this automatically by editing your .xfigrc file.)
    • Using TransFig, convert this file into four formats: pstex, pstex_t, pdftex, pdftex_t. There's a catch here: you need to make sure that myfigure.pdftex_t version includes myfigure.pdf, not myfigure.pdftex, which is the default. I guess this counts as a bug. This chore is usually done by a script for me:
      # Convert all fig files to four other formats, using fig2dev.
      for FILE in *.fig; do
      FILE=`basename $FILE .fig`
      if [ $FILE.fig -nt $FILE.pstex ]; then
      fig2dev -L pstex $FILE.fig $FILE.pstex
      if [ $FILE.fig -nt $FILE.pstex_t ]; then
      fig2dev -L pstex_t -p $FILE.pstex $FILE.fig $FILE.pstex_t
      if [ $FILE.fig -nt $FILE.pdf ]; then
      fig2dev -L pdftex $FILE.fig $FILE.pdf
      if [ $FILE.fig -nt $FILE.pdftex_t ]; then
      fig2dev -L pdftex_t -p $FILE.pdf $FILE.fig $FILE.pdftex_t
    • Then in my LaTeX file, I have this code in the preamble:
      and whenever I want to include the file myfigure.fig, I just write \myinput{myfigure}.
    This has several nice properties: you can use LaTeX math constructs in figures (just surround them with dollar signs) and it looks great in both PDF and DVI.
  • I'm very proud of the following piece of code:
    \newcounter{storedequation} % To store the equation number when we
    % temporarily change it.
    Now we have an environment lettereqns, with one parameter, which makes all equations in it be numbered (P1), (P2) etcetera if the parameter is P.


Post a Comment

Links to this post:

Create a Link

<< Home