Silvia Liverani
Home

Research

Blog

Programming

Teaching

Personal

Links

Contact


Main

My
software

LaTeX

Linux

C++

R


Notes on LaTeX

Notes on LaTeX
Choose a presentation style in LaTeX using beamer

Check out the Beamer themes gallery for ideas and examples.


Grammar check for LaTeX

Microsoft Word does have one advantage: a good grammar and spell check. As I haven't found any better grammar check so far, this is my LaTeX solution for grammar and spell check with MS Word using the latex2html command in Linux. First of all, of course, make sure that latex2html is installed in your machine. The idea is to use latex2html to transform our LaTeX file into an HTML file that Word can read to find grammar mistakes that we can edit manually in our LaTeX file.

  1. Make a directory where all the LaTeX files necessary are stored. Very important: There's a bug that causes problems when running latex2html on files which have spaces in the path in either the input path or the output path. The workaround is to either move things to folders with no spaces, or add appropriate symbolic links. This is the error that I got when using LaTeX and there were spaces in the input path:
    texexpand: Error: More than one input file specified.
    texexpand failed: No such file or directory
  2. In a Linux shell run the following command
    latex2html your-file-name.tex
  3. Open the HTML files obtained with Word and use its grammar and spelling check to identify mistakes, and correct them in the original LaTeX files.

However, I haven't been able to use latex2html successfully with jpeg figures and input files, only with simple text-only LaTeX files without using the LaTeX command \input.


Select pages of a ps file

The Linux command psselect selects pages of a postscript file and creates a new postscript file which only contains those pages. For example,

psselect 1-3 document.ps page1-3.ps

selects pages 1 to 3 of the file document.ps and creates a new file page1-3.ps which contains only those pages.


Create pretty graphs in LaTeX

Create pretty graphs in LaTeX using LaTeXDraw, a free PSTricks code generator or PSTricks editor for LateX. A LaTeX document, containing your drawing, is created and compiled into a pdf or a ps document. You can then insert it into your main LaTeX document as a picture (pstricks packages are no more needed and the pdflatex command can be used). Below is a screenshot from the official website. It shows a drawing in LaTeXDraw with a result of another one in pdf.

Another very useful resource for all sorts of pretty graphs in LaTeX is TeXample, an example gallery of graphs produced with the PGF and TikZ packages for creating high quality illustrations and graphics for use with LaTeX. Each graph is associated with the code that produced it, for easy reproducibility.


Create a scientific poster in LaTeX

Create a scientific poster in LaTeX with beamerposter. Below is the screenshot of one of my posters, done with beamerposter.


How to spell check a LaTeX document in Linux

A quick spell check on a LaTeX file in Linux can be done with the command ispell by typing

ispell -t latex_filename.tex

Once the spell check is running, the important commands are the spacebar for skipping to the following mistake without changes and I for adding the word to the dictionary permanently. Ispell runs a spell check, not a grammar check. Bonus: it can use the British spelling! For example: British maximise, American maximize; British colour, American color.

A valid alternative to ispell is aspell. It works in a very similar way:

aspell -t check latex_filename.tex

Alphabetising in BibTeX

Let's say that you have 2 BibTeX items (articles) written by the same author in the same year. Usually BibTeX does a good job at alphabetising but it failed for me a few times. Below is a trick that I found for fixing this problem.

At the beginning of the BibTeX file write:

@PREAMBLE{"\newcommand{\noopsort}[1]{}"}

Then add the command \noopsort in the year entry as follows

@article{White1,
author={White, A.},
title={{Title of paper 1}},
journal={Journal 1},
year={{\noopsort{a}}2009},
}
@article{White2,
author={White, A.},
title={{Title of paper 2}},
journal={Journal 2},
year={{\noopsort{b}}2009},
}

The papers will then be sorted according to the letter in the \noopsort command in the year entry.


Page Headers

This is the header that I have used for my PhD thesis. I wanted a horizontal line at the top of each page, with the page number over it on the left side and the chapter number and title on the right side. I wanted no footer. The command \cfoot{} removes the default page number at the bottom of the page.

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LO,LE]{\thepage}
\fancyhead[RO,RE]{\leftmark}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\headsep}{25pt}
\cfoot{}