There you are, ready to write you thesis. Here is a compilation of tricks of the trade... don't forget to add stuff to it as you discover it! ALD

Thesis (and paper) Writing Tricks

1.  Meeting Page Limits

Some nice tricks of the trade on "LaTeX tips to meet publication page limits" on this blog:

  • Includes description on using vspace, addtolength, and setting specific margins and spacing between sections.

Savetrees: Another good one is the Latex savetrees package.

Also, a nifty quick way to count words in the finished pdf document:

  • While still in Latex you can also use the detex command to get a plain ascii file with all your words with the Latex stuff stripped out. Then you can just count words of this file.

Can use the web interface and load a .tex file, or download the Perl script, also counts figures, tables and equations.

2.  Minimize PDF Size

(maybe more useful for paper-writing)

  • Web method: Just drag-and-drop your pdf and it will automatically download a reduced-size version for you.

3.  Vector Images with Latex Text

This always have vector-based images generated from solidworks, inkscape, powerpoint, matlab or python that look great but don't support latex fonts or text options like easy subscript. How do you get those features? INKSCAPE can do it.

  1. Get your vector image imported into inkscape. Its native filetype is .svg, but it can import images from many sources, such as vector pdfs generated from solidworks or .wmf files saved from powerpoint. The point is, if you save it as a vector image, inkscape can probably edit it.
  2. Edit your text. This is the point where you should convert something gross like "theta1" to "$\theta_{1}$" or "v ab" to "$\overline{v}^{a/b}$". you can also add tags like "\Large{}" to control final text size. (you can also edit the output file if you prefer, see step 6)
  3. Save as a .pdf . !!IMPORTANT!! Save with the option PDF+LaTeX on. Also save with the "Export area is drawing" option checked, and that the "Convert texts to paths" option is off.
  4. Check out the .pdf file that has been generated. The text should have been stripped away.
  5. Check out the .pdf_tex file that has been generated. You may need to edit the image path depending on your latex project location.
  6. You can also edit the text directly in your .pdf_tex file if you need to change font sizes or modify the text. It is much harder to move the text around using this method, so I suggest saving the intermediate inkscape image as an .svg so you can edit in the future.
  7. In a normal figure, where you would normally put the \includegraphics command, replace it with an \input command, with the path to the .pdf_tex file instead of the .pdf. Details on this step, including image sizing, can be found in the .pdf_tex file itself.
  8. Voila!

4.  PDF images and figures

How to crop the white border around the pdf generated by matlab

  • On a MAC, in terminal, you can use pdfcrop:

pdfcrop -margins 10 fig.pdf fig.pdf

Or you can use Preview on the Mac and crop, rotate and other jolly things, then resave the pdf file. But the command line method above would let you write a batch program to do a whole bunch of figures at once...

Or, you can take the pdf output (print to pdf. It seems to come out a standard size) and use the clip and trim commands. I find that "trim = 40mm 85mm 40mm 85mm" works pretty good for the matlab produced pdfs. I couple it with scale to linewidth. Complete syntax is \includegraphics[trim = 40mm 85mm 40mm 85mm, clip, width=\linewidth]{fig.pdf} (Sam)

When using images from Powerpoint, have Powerpoint print to PDF, then pull into Preview, crop, etc.

If you have the figure as PDF, you can pull it into Inkscape or Illustrator or Keynote to edit, add markup etc.

4.1  Figures tips from ME310 Latex template

ME310 reports can run to 200 pages and look a lot like a thesis, with lots of figures. So the following tips can be useful:

  • Latex tips for ME310 reports
  • Use \clearpage to force Latex to unload its queue of figures, so that the text can catch up. If necessary, it will put some figures on pages by themselves before starting the next section.
  • Use the \caption[short caption]{This is the long caption} feature so that your Table of Figures doesn't get too many long entries (see example below).
Latex uses rules to determine where to put figures. It likes to put them at the top or bottom of a page, if possible. It avoids having just a few lines of text ("orphans") immediately above or below a figure. You can control figure placement to some extent using any combination of the commands [h], [b], [t] and [p] which allow it to place the figure here, at the bottom of the page, at the top or on it's own page by itself (see the figure example below for syntax). Another option is [h!] which is more emphatic than [h]. You can also coerce Latex to place a figure almost immediately where it is placed in the .tex file by using [H] which will often cause a page break to make room for the figure.

Full page figures in landscape orientation:

 \begin{figure}[p]   % p for "page" for let it be a full page figure
		includegraphics[angle=90, height=8in]{Figures/ideastorm.jpg}
	\caption[Rotated landscape figure example]{An example of taking a large figure
              and having Latex rotate it 90 degrees to display it in landscape format 
              as a full page figure.}
	\label{fig:full-page-example}  %Tag for referring to figure in text.

5.  References

5.1  Mendeley Bibtex Syncing

MRC: I think the nicest solution is the one that John Ulmen figured out for our Dynamic Sensing chapter:

  • Set up a (shared) Mendeley database for all your references.
  • In Mendeley preferences, set Preferences/Bibtex/Enable BibTex syncing and specify a folder where you'd like the resulting .bib files to be. You probably want it to be one .bib file per Collection or Group.
    • Also in Mendeley/Preferences/Document Details check that you set "citation key" to always be included as a field.
  • Finally, when you import things into Mendeley, always enter something useful like "Asbeck2012spine-mechanisms" for the contents of the citation key field.

Now you will always have a .bib file that has useful citation keys. Never edit the .bib file directly; just update Mendeley as new references come in.


  • The "Import to Mendeley" tab on browsers is a bit dangerous. For anything that you import, it is wise to check afterward to be sure the details are all correct. It usually works OK for journals, less reliable with conference publications.
  • There is a tool in Mendeley that can help you find and merge duplicate entries
  • Note that when you "copy" references from one collection or group to another, you are actually just updating the links; it is not duplicating the entry.

January 2013: Stanford has made a deal with Mendeley that gives you more storage and group membership options than the standard free account. To make use of it, you just need to Join the Stanford Group. See the Stanford Library Mendeley page for details.

You can do pretty much the same thing using Zotero but we seem not to be using Zotero...

5.2  Bibtex

A few words about Bibtex: Bibtex is not Latex. It's a separate program with its own syntax. It doesn't understand percent symbols for comments. It tends to ignore anything in braces {xxx} that it doesn't understand.

When citing conference proceedings:

  1. Are you sure there is not a subsequent journal article? If so cite it instead.
  2. Otherwise, use @inproceedings -- do not use @article -- for the citation. For citing web pages use @misc.

There is a free program that comes as part of the giant Texshop/Latex/Tex installation on Macs called BibDesk. It is good (and picky) about finding errors and cleaning up your .bib files if necessary -- although fixing things in this way kind of violates the Mendeley-->.bib idea above.

6.  Hyperlinks in documents

Really handy if your long document has hyperlinks so when you click on citations or figure references or any cited URL it pops you there. Also table of contents, list of figures, etc. The default hyperref setting is a it ugly with colored boxes everywhere. A nice, non-intrusive solution from alumnus Alan Asbeck:

 %Fancy callout for hyperref
    pdfauthor={Mark Cutkosky and John Ulmen},
    pdftitle={Dynamic Tactile Sensing},
    pdfsubject={Book Chapter},
    pdfborder={0 0 0},

7.  Tables

Simple tables are not bad, but fancy tables are a pain in Latex. If you don't want to learn how to do them, you have two other options:

  • Do your table in MS Word or Open Office, print to PDF and import the cropped PDF just like a figure. Call it Table, Latex doesn't care.
  • Do your table in Open Office (similar to MS Word), first having installed the Writer2Latex plugin. Then export your table to Latex and paste into your document.
  • Cropping PDF's of tables is easy in Inkscape. Open the file, go to document properties, select crop to image. Be sure to leave margins or the bottom of your table will be cropped off!
Page last modified on July 10, 2014, at 10:51 PM