Contact

LaTeX

I am slowly sorting out how to use LaTeX to format papers. LaTeX is a great language to use for typesetting papers and does an especially good job handling figures and tables. The add-on BibTeX handles references very nicely. LaTeX is a strange language, though, and there are plenty of things that are not self evident. Here are some random posts on a variety of LaTeX issues that I frequently encounter in formatting papers.

Find location of TeX files

posted Dec 10, 2011, 9:40 PM by David Eagle   [ updated Dec 10, 2011, 9:42 PM ]

This handy utility locates TeX files: kpsewhich; mktexlsr makes the appropriate links.

Use XeTeX engine by default on a specific file

posted Nov 21, 2011, 8:58 AM by David Eagle   [ updated Apr 30, 2012, 10:21 AM ]

Most of my files use the LaTeX rendering system to process my files. Some, especially those with customized fonts, use XeLaTeX. There are two ways to make Aquamacs process this file using the XeTeX engine. First, choose the menu options: command->TeXing Options->Use XeTeX engine. The other is to make a new command to run XeTeX automatically. To do this:

  1. Go to LaTeX->Customize AUCTex->Browse Options
  2. Click "TeX Command" and find the "Command List" drop down.
  3. Click INS
  4. In the Name: box type "XeTeX"
  5. In the Command: box type: "%'xelatex -synctex=1%(mode)%' %t
  6. In the How: select "TeX-run-command"
  7. In the Modes: select "Value Menu" and check LaTeX, ConTeXt, and AmSTeX.
  8. "Save for future sessions"
Now you have a custom menu option under the Command menu that says XeTeX.

THIS WORKS ON AQUAMACS
In order to set this as the default on a specific file add the following local variables to your document. Add these at the end of the document, with the comment characters:
% Local Variables: 
% mode: LaTeX 
% TeX-command-default: "XeTeX" 
% coding: utf-8 
% End: 

THIS WORKS ON EMACS
%Local Variables:
%TeX-engine: xetex
%End:


Close and reopen the document. Click ^C-^C <ret> and this will run XeTeX on your document.

Insert Cites Keyboard Shortcuts - Bibtex/Emacs

posted Oct 26, 2011, 8:47 AM by David Eagle

Here's how to insert cites using keyboard shortcuts in Emacs with a Bibtex file that you've created.

In the preamble make sure that you include:
\usepackage{natbib}

Where you want the bibliography, type:
 \bibliography{<bibfile>}

Replace <bibfile> with the full path to your Bibtex file. Don't include the .bib extension. (e.g. /User/user/bibfile)

Where you want to insert a cite type: 
Ctrl-c-[

Then select the cite type from the list.

Then type the terms you want to search for and hit enter. A list will appear on the right. Select the reference you want and press enter.

Turn Endnotes to Footnotes

posted Apr 21, 2011, 7:09 AM by David Eagle   [ updated Apr 21, 2011, 7:17 AM ]

Here's how to turn your footnotes into endnotes easily.

1. add \usepackage{endnotes} to the preamble to enable the endnotes package that is included with standard latex distributions.

2. add \let\footnote=\endnote to convert all instances of \footnote{} to \endnote{}
When you want to add an endnote, just type \footnote{TEXT} where you want the reference to appear.

3. add \listofendnotes where you want the list of endnotes to appear.

Sideways Longtables in LaTeX

posted Feb 21, 2011, 10:30 AM by David Eagle

Here's how to create tables that span multiple pages and are rotated sideways (landscape). In the preamble type:

\usepackage{longtable,lscape}

When you want to add the table type:

\begin{landscape}
 \begin{longtable}{lccccccll} %note the lccccll are the standard column alignments
\caption{CAPTION} \label{tab:1}\\ %label is referenced in the text with \ref{tab:1}
....
\end{longtable}
\end{lscape}



Adding Figures with Captions in Latex

posted Sep 24, 2010, 6:24 AM by David Eagle   [ updated Sep 24, 2010, 6:25 AM ]

Here's the snippet to add reasonable nice figures in a paper with centered captions that are the same width as the figure:

\begin{figure}[htp]
  \centering
  \includegraphics[width=.8\textwidth]{NAME.pdf}
\parbox[t]{0.8\linewidth}{%
\caption{NAME}%
\label{fig:fig1}}
\end{figure}

Ubuntu Stata

posted Jul 8, 2010, 12:13 AM by David Eagle   [ updated Oct 9, 2010, 4:59 AM ]

Yes, it can be done. It takes a little work, but here are the steps:

  1. sudo mkdir /usr/local/stata11 %create directory for Stata

  2. sudo ln -s /usr/local/stata11 /user/local/stata %symbolic link for easy updating
  3. sudo /media/Stata/install %run the installer

  4. cd /usr/local/stata11

  5. sudo ./stinit %run the license program

  6. add the following to your ~/.profile file (with an text editor)

  7. PATH="/bin:/usr/bin:/usr/bin/local:$HOME/bin:/usr/local/stata"

  8. Log out and in. 

  9. the command stata should work in a terminal

  10. xstata will not! (this is the GUI version)

  11. Add the following links:

    sudo ln -s /usr/lib/libgtk2.0-0 /usr/lib/libgtk-1.2.0

    sudo ln -s /usr/lib/libtiff.so.4 /usr/lib/libtiff.so.3

    sudo ln -s /usr/lib/libgtksourceview-2.0.so.0 /usr/lib/libgtksourceview-1.0.so.0

    Stata can be tricked into using the newer version instead of the old version it is expecting.

    Stata 11 may close unexpectedly when starting the .do file editor. If that happens  installing libgtksourceview 1.0 may fix the problem:

    sudo apt-get install libgtksourceview1

Funky Within Document Links

posted Apr 30, 2010, 8:14 PM by Dungeon Dwellers

To add a link to a section in the document, the hyperref package works very well.  as \usepackage{hyperref} in the preamble and then type:

\hyperref[label]{text to draw the ref around}

Very slick and lots of customizations available.

Convert .ris, Endnote .ris to .bib and vice versa

posted Apr 16, 2010, 10:07 AM by David Eagle

Here's a great set of applications, run at the command line, to convert various bibliographic citation formats from one to the other, using an intermediate (xml) format. This is great for converting Endnote .ris files from databases into BibTeX format as the BibTeX export option is not always available (e.g. for JSSR). 

To run these commands on a mac, either unzip the archive into you /opt/local/bin directory, or specify the path the files in your ~/.profile file by editing this file and adding the line:
    export PATH=/opt/local/bin:/opt/local/sbin:$PATH

Convert LaTeX to Word

posted Mar 31, 2010, 11:37 AM by David Eagle   [ updated Oct 9, 2010, 4:58 AM ]

Many journals won't take LaTeX files and insist on a word format. There's no great solution to this problem, but here are the best

Latex2rtf is my go-to program. It is very simple to use, and handles many basic formating issues. If you keep your latex document simple, this will do the trick.

TTH - works very well, but doesn't handle a lot of special formatting. It converts equations to text rather than images.
This is a TEX --> html converter and uses a command-line interface.
This is my go-to option for converting tables into an Excel-readable format.
http://hutchinson.belmont.ma.us/tth/manual.cgi#tth_sEc1.3

Pandoc handles simple LaTeX files and can convert them to a number of formats that Word will read:

Hyperlatex is a solution that employs emacs macros. In my experience, it doesn't work terribly well. Latex2rtf and TTH seem to work better.

1-10 of 13
http://www.davideagle.org/random-latex-issues
www.davideagle.org
crawl=CC-MAIN-2013-20
48125
application/http; msgtype=response
sha1:HFB6H2UWTMOPVAGLXUL7G4BXRPNPFXEJ
<urn:uuid:90328b13-7e51-4e50-92fc-432858d8dd9c>
2013-05-20T04:06:35Z
173.194.74.121
sha1:GFYHDBG7LKJQ6Z3SFDPVLSSGATIRPQWX
<urn:uuid:39458d31-7260-4da5-876c-9a419703fde9>
http://www.davideagle.org/random-latex-issues
response
<urn:uuid:9d5da8a8-919c-43f4-abf6-f5c150e4810e>
robots: classic
hostname: ip-10-60-113-184.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2013-20
operator: CommonCrawl Admin
description: Wide crawl of the web with URLs provided by Blekko for Spring 2013
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf