Exporting from dia to LaTeX

July 10th, 2009

Exporting diagrams from Dia into LaTeX (with LaTeX fonts etc) is quite easy once you figure out how to do it. There are several TeX exporting options in Dia, but this is the only one that I could get to produce satisfying results.

Using Dia 0.97, or later, export the diagram as MetaPost. Then run mptopdf on the exported metapost to get a shiny pdf to include in the LaTeX document.

LaTeX reference card

October 8th, 2007

A handy LaTeX reference card.

Matlab matrix to LaTeX

September 30th, 2007

Here’s a handy Ruby one-liner for converting Matlab output with matrices to a form that can be directly pasted into a LaTeX array.

ruby -ne 'puts($_.strip.split(/\s+/).join(" & ") + " \\\\")'

An example:

matlab -r "[1 2 3; 3 5 7], exit" -nosplash -nodisplay |  ruby -ne 'puts($_.strip.split(/\s+/).join(" & ") + " \\\\")'

outputs

 \\
To & get & started, & type & one & of & these: & helpwin, & helpdesk, & or & demo. \\
For & product & information, & visit & www.mathworks.com. \\
 \\
 \\
A & = \\
 \\
1 & 2 & 3 \\
3 & 5 & 7 \\
 \\
 \\

where the matrix body is ready to be copied directly into a LaTeX array.

A = \left(
  \begin{array}{ccc}
    1 & 2 & 3 \\
    3 & 5 & 7 \\
  \end{array}
  \right)

The graphs package is nice for drawing graphs and trees. There’s also a handy guide.

Multiple indices in LaTeX

May 28th, 2007

Creating multiple indices in LaTeX doesn’t take especially more work than just creating a single index. It just involves using an additional package as explained in The LATEX Local Guide.

I recently had to typeset a couple of lists of newline-delimiters to LaTeX. Rather than to do the mind-numbing job by hand, I wrote the following script. It takes one argument: the number of columns one wants in the table to have. It then expects the list from standard input, the first row is assumed to be the table captions.

An example:

> to_table 3
Name
Has foo
Has bar
Program1
Yes
No
Program2
No
Yes
^D

Results in

  \begin{tabular}{ccc}
  Name & Has foo & Has bar\\
  \hline
  Program1 & Yes & No\\ 
Program2 & No & Yes
  \end{tabular}

Read the rest of this entry

Graphs in LaTeX (again)

March 9th, 2007

Another good tool for creating graphs in LaTeX is Asymptot. It’s command-based and makes it easy to produces good-looking graphs.

Increasing LaTeX's memory

February 25th, 2007

I recently ran in to the following error while trying to compile a LaTeX document.

! TeX capacity exceeded
...
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

Luckily you don’t need to ask a wizard, you can increase LaTeX’s memory yourself.

Presentations in LaTeX

February 13th, 2007

I find it quite frustrating to make slide shows using WYSIWYG editors such as open office. Luckily I recently found a LaTeX package for slides called Beamer which works well, so there’s no need to abandon the luxuries of LaTeX typesetting.

There’s also exists a small tour for beamer which gives a good introduction to the package.

Making an index in LaTeX

December 19th, 2006

Making an index in LaTeX is far easier than I thought. MakeIndex does most of the work.

Read the rest of this entry

LaTeX math symbols

December 14th, 2006

I often forget how to create certain math symbols in LaTeX. Luckily I always have a handy chart of LaTeX math symbols close.