You are currently browsing the archives for the LaTeX category.

Breaking sentences into separate lines with Vim

I just read somewhere that when writing LaTeX documents it’s useful to have each sentence on a new line. My current document only has (double) line breaks between paragraphs. Here is how to use Vim to insert line breaks after each full stop.

In command mode press ‘:’ then enter s/\.\s\+/\.^M/. The ^M character represents a line break and must be inserted with CTRL-V Enter. Press enter to run the substitution on the current line. Add a percent character to run the substitution on the whole file: %s/\.\s\+/\.^M/.

Some more useful commands in a SunWorld article from 1997.

Figures for publication

When producing camera ready versions of publications it seems best to create a Postscript file and then convert to PDF. Some printers (printing companies) require the Postscript files and it’s also the only way I’ve found to correctly embed all the fonts in the PDF.

In Matlab I’ve been using set(gcf, 'PaperPositionMode', 'auto'); print -depsc myfigure.eps; to create the eps file for including in LaTeX.

Run latex mypaper.tex to produce the dvi file.

Run dvips -Ppdf -G0 -tletter mypaper.dvi to produce the PS.

Run ps2pdf -dPDFSETTINGS=/printer -dCompatibilityLevel=1.3 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sPAPERSIZE=letter mypaper.ps to produce the final PDF file. Use pdffonts mypaper.pdf to check that all fonts are correctly embedded.

Replace letter with a4 in the dvips and ps2pdf commands if you’re publishing for Europe.

Some useful links:

Broken figure references in LaTeX

In LaTeX documents figures must always have the caption field before the label field. Otherwise the references will be wrong. See this other blog for more.