LaTeX tips

From QERM Wiki
(Difference between revisions)
Jump to: navigation, search
m (Recommendations for downloads: fixed formatting)
(word count)
Line 80: Line 80:
  
 
* Every symbol you could ever imagine: [http://www.math.utoronto.ca/mathit/symbols-letter.pdf The Comprehensive LaTeX Symbol List]
 
* Every symbol you could ever imagine: [http://www.math.utoronto.ca/mathit/symbols-letter.pdf The Comprehensive LaTeX Symbol List]
 +
 +
==Word Count==
 +
You can count words after compiling to pdf with the following command. More details [http://markelikalderon.com/2006/11/04/latex-word-count-and-textmate/ here].
 +
 +
ps2ascii mydocument.pdf | wc -w
  
 
==Additional Pages==
 
==Additional Pages==

Revision as of 17:49, 22 November 2010

LaTeX logo huge.png

This will be a repository of tips for using LaTeX. To add a tip, just create a link below, for example: Separating the Red Sea and save the page. The link will be red. Just click on the red link and you will automatically be editing the page. Nothing like a blank canvas to share your hard-gleaned wisdom!

Contents

Recommendations for downloads

  • Best Windows LaTeX compiler Miktex
  • Best Windows editor TeXnicCenter
  • Best Mac editor TeXShop
  • Best Mac compiler MacTeX
  • A Linux Integrated LaTeX Enivronment Kile
  • For any Linux/Unix system, simply use your favourite Unix editor to type the mylatex.tex file. Here is a basic list of Unix commands. To check your spellings, you can say

ispell mylatex.tex (.tex extension may be omitted) A better program for spell-checking on linux is Aspell. Replace ispell above with aspell .

Emacs also provides a great environment for LaTeX. While using Emacs, install AucTeX for best results.

General setup

  • Compiling the LaTeX using pdfTeX allows the creation of pdf files as the final product and the inclusion of graphics created as pdf files from some other source. For many people this is more convenient than using postscript files which may be the default for LaTeX compilers and editors. pdfTeX works nicely with images produced as pdf files (see R/General Information on Plotting).

Converting from other formats

There are a variety of tools for converting to LaTeX from other formats, many of which are described here. For equations, the only software that QERMunists have found to be truly great is GrindEQ's Word2LaTeX. Unfortunately, that one costs $129, but they have a "fully functional evaluation/download version", so as long as you fully embrace LaTeX after converting your files, then you could get by with just the free trial.

MathType (unfortunately no longer free!, $57 or 30-day trial that might be enough to move all the way to LaTeX), will nicely convert individual equations written in Equation Editor or MathType to LaTeX. Within MathType, use the menu for Preferences > Translators, and select "Translation to other language" and pick the default, "TeX -- LaTeX 2.09 and later". Now highlight any equation in the MathType window and paste into a text file. The pasted text should appear as text in LaTeX syntax.

Anyone have any success converting using Open Office, or even seeing MathType-produced equations in Open Office?

Converting to other formats

latex2rtf

latex2rtf converts .tex documents to .rtf, which can be opened in Open Office or Word and saved as a .doc. Get it here (windows) or your favorite package manager (linux/mac). Usage is as simple as latex2rtf myfile where myfile has extension .tex and has already been compiled. There are switches to control how equations are handled (see the documentation for more details), and some examples are -M3 (convert both inline and displayed equations to RTF), -M12 (convert both inline and displayed equations to bitmaps), and -M32 (insert the raw latex equation delimited by <<: and :>>). If you choose to insert the raw latex equation and you have MathType, you can convert equations to MathType equations by cutting/pasting the latex into the MathType window, or with MathType 6.5 for windows, highlight the latex equation in Word and click the TeX toggle command on the toolbar. Latex2rtf supports bibliographies.

latex2rtf for dummies (aka eileen) on a Mac

  • If you know how to install things with Unix commands, you are not a dummy.
  • Otherwise, (and this doesn't necessarily mean you're a dummy), get a package installer (i-installer or FinkCommander); make your choice here.
  • Use these to find latex2rtf. i-installer was already on my computer, and filled in the blanks as far as many of the prerequisite packages. e.g. I think I needed ImageMagick and FreeType2 to start.
  • Also find and install package netpbm. I found this with FinkCommander, but not with i-installer. This will make more of your error messages disappear.
  • Next use Terminal, available already on your Mac. It's very similar to the windows command prompt. Type:
latex mypaper
bibtex mypaper # if you use bibtex
latex2rtf mypaper

These are the same commands as above, more details available here.

  • Terminal details I don't want to look up again and you may find helpful:
    • "pwd" returns current directory.
    • "cd /Users/yourname/YourFolder/" changes the current directory to the folder YourFolder on your hard drive.
    • "cd /Volumes/Cruzer/MyFolder/" changes the current directory to the folder MyFolder on a thumb drive that calls itself Cruzer.
    • To run latex2rtf on a .tex file, use the "cd" command to put yourself in the right directory, then follow the steps above.
    • Error messages will be shown in Terminal, and generally correspond either to programs or packages not installed, or to LaTeX functions not recognized. Check the documentation link above to see if your referenced function has any hope of being found by latex2rtf or if it will simply be ignored.
    • To find if there are hidden files on your computer, e.g. in /usr/local/bin/, which may be referenced by some of the source code, type "open -a finder /usr/local/bin/". I ran into a few error messages that led me to believe I was missing files either in this folder or in /usr/bin/. Use i-installer or FinkCommander to find any more necessary packages.
  • Finally, when you have run latex2rtf and you want to see the results, make sure to open your newly created .rtf file in Word. None of the bitmaps or rtf math conversions will show up if you let the default program (TextEdit on my computer) open the file.

GrindEQ

GrindEQ LaTeX-to-Word is a windows-only product that converts .tex to .doc. It costs €49 but the evaluation version comes with 10 launches.

Adobe Acrobat Pro

Acrobat Pro will export .pdf files to Word. It does alright with the text portions, but the equation conversion is pretty awful. Unfortunately, some of the converted documents hang Word, YMMV.

Open Office

Open Office 3 can import .pdf files and then save them as Word files. Equations look OK, but seem to be a collection of images, rather than any editable equation format.

Compatibility with R

Sweave is a great way to embed R output in LaTeX. Pdf10.png Here is a GREAT example, and perhaps everything you need to start.

xtable is a nice R function (thanks EliG) to produce latex style tables in R

Useful Links

  • Great resource to get started and have questions answered: LaTeX WikiBook
  • A quick cheat sheet of all the things you forget. Cheat Sheet

Word Count

You can count words after compiling to pdf with the following command. More details here.

ps2ascii mydocument.pdf | wc -w

Additional Pages

Topics include:

Personal tools