LaTeX Tricks and Tips

LaTeX is nice. It does what you,and only what you want. Unlike certain word processors, it does not make assumptions about what it thinks you intend to do and then screw up your document "helping" you. LaTeX files are small and can be opened under any editor and you don't have to worry about versions. LaTeX is capable of handling books (100's of pages and figures) without breaking a sweat. The typesetting is publication quality, especially the mathematics, no ill-spaced kludgy bitmaps here. Latex can do just about anything you want but it takes some learning. Some people are put off by mark-up languages, but if you persevere, you will find the power of LaTeX unparalleled. Here are some things I have learned along the way to help you with your latexing. Many of these things came up when I had to write grants which are very specific with their formats (your margins are too narrow, no money, next).

  1. LaTeX is a set of macros built on top of TeX. Many people have written their own macros, which they call packages, to extend the functionality of LaTeX. There are hundreds of packages out there to do just about anything you want. Check out the TeX Catalogue On-line to see if someone has developed a package for your specific need.
    If you have the TeTeX distribution, look first in /usr/share/texmf/doc/latex for the documentation about all the pakages already installed. I still continue to find new ones that I haven't seen before.
  2. To generate PDF files, do it directly. Do NOT convert from postscript. If you have a Red Hat Installation (up to 7.2), you have a broken pdflatex. First, make sure you have a recent pdflatex by typing pdflatex -v. If the version is less than 3.14159-0.14h (the 14h is the important part), then upgrade. I found the following procedure to work for my tetex installation executed as root:
    1. get the precompiled pdftex and unpack it
    2. replace your current executables of pdftex and pdfetex with those from the package
    3. replace the *.pool files in /usr/share/texmf/web2c with those you downloaded
    4. run texconfig init
    Now you are set to just run pdflatex instead of latex. The only difference between pdflatex and latex is that each program accepts different image formats so you will have to have encapsulated postscript versions for latex and JPEG, PNG or PDF for pdflatex. Use epstopdf to create pdf from postscript. The same packages work for both programs so output is identical. A skeleton of a latex file which distinguishes which program is being used to process it is available.
  3. Use the geometry package to lay out your page. It is so much easier than \pagewidth, etc. as it does all the math calculations to fill in everything you don't specify.
  4. When submitting your c.v, you want people to know how many publications you have, with all the publications listed in different categories. Therefore, you might want to reverse number your citations and preserve the numbering between lists. Here is an example of a latex file which makes use of the revnum package to do this and here is the output. If I later add another reference anywhere, I do not need to renumber everything, I just have to increment one initial counter value.
  5. Use pybliographic to manage your bibliography. It's a really nice gui to edit your Bibtex files. The latest version queries Medline directly and imports the bibliographic entries. You can also use it to exchange bibliographies between Endnote and BiBTeX. Just export the bibliography in the "refer" format from Endnote. When reading the Endnote generated file from pybiographic, the "0" (zero) tag will be initially undefined so an entry must be added. Go to "Settings/Preferences" and click on the "Refer" tab. In the "Key" field type "0" and in the "Value" field enter "type" and then hit the "Set" key and then hit "OK". Now you are ready to read your bibliography into pybliographic.

    For the MAC, I use Bibdesk. It's not quite as extensible as pybliographic and has stalled in its attempts to import Medline, but it's a nice GUI.

    Recently, I have started using JabRef which is Java-based.

    I recently had to import a database in RIS format. I ended up modifying a PERL script that I found on the web but it works pretty well now.

  6. Use the fancyhdr package for defining headers and footers.
  7. To start numbering at a certain page, like 10 for example, use the command \setcounter{page}{10}. To change the style of numbering to roman, for example, \renewcommand{\thepage}{\roman{page}} This works for any of the other numbering counters like chapter and section.
  8. Sometimes you are limited to one page of references and if you use bibtex, it will automatically put a blank line in between the references in the bibliography wasting valuable space. This space is controlled by \parskip but even if you set \parskip to 0pt before the bibliography command, it will be ignored. Dr. Gernot Plank sent me this fix to put in the preamble (the part before \begin{document}).
    The old work-around I came up with was to edit the .bbl file. I added the line \setlength{\parskip}{-5pt} right after \begin{thebibliography} at the top of the file. N.B You had to re-edit this file after every time you ran BibTex.
  9. LaTeX can be used to make big conference posters. Here is a link how to do it. Dr. David Westwick had this to say about the instructions given by the link:
    The pstricks stuff recommended on the web page didn't work as advertised (at least not on my linux box, or on our suns) -- in the end, I generated an eps of the poster, and then created a separate LaTeX document and used the graphicx package to scale things up to full size (I think that was the point where I had to start hacking bounding boxes to get everything to work).
    He sent me a tar ball of his poster.
  10. Equations for M$ PowerPoint.
    Using built-in PowerPoint fonts to display math is like trying to trim leather with kindergarten scissors: it ain't gonna work. I generally write a single equation latex file and then convert to png at 600 dpi. This looks smooth on the screen, can be seen in PowerPoint, and I can set the background transparent. Remember to contrast your text colour with the background and don't be afraid to make it large enough for people in the back row to read. Here is an example of the Navier-Stokes equation. Note the use of the geometry package to limit the page size. To convert to png, I use ImageMagick:

    convert -density 600 -geometry 50% navstokes.pdf navstokes.png

    If you really hate PowerPoint, you can try packages like HA-Prosper which make PDF's which can be viewed fullscreen and can have animations embedded within them.

  11. LaTeX sometimes adds too much space, especially when you have a page limit and are trying to cram more in. For getting rid of unnecessary space, check out this nice page.
  12. Here are some bst and sty files that I have modified to work properly. Include the sty files by using the \usepackage command.
    1. Biophysical Journal bst and style files. Add the command \singlespacing after your abstract.
    2. Journal of Cardiovascular Physiology and Heart Rhythm bst and sty files.