Saturday, September 17, 2011

Emacs for LaTeX on Windows and on Ubuntu

Want to use Emacs to type up your LaTeX document? Here is the article for you. Setting up Emacs on Ubuntu is a lot easier than on Windows. For Ubuntu (at least on 10.04), simply type
  • sudo apt-get install emacs
You may also like to install some other emacs-lisp scripts to help your editing work, for instance, color-theme to give you a better mood while editing and Aspell to enable the on-the-fly spell check in flyspell-mode:
  • sudo apt-get install emacs-goodies-el
Although the emacs in the Ubuntu repository is bundled with a simple TeX mode, you may want to use an advanced version: AUCTeX:
  • sudo apt-get install auctex
That's all for Ubuntu. Of course here we have assumed that you have had latex installed on your Ubuntu computer.

For Windows, things are trickier. There is no such an automatic installation repository. You have to put things together piece by piece. First of all, you have to find the compatible Emacs version with AUCTeX on Windows. The current supported Emacs version is 23.3. You can find version 24.1 on line, but it is better to install 23.3 just because we prefer AUCTeX for our LaTeX editing work.
Here is the link for Emacs 23.3:
There is actually no installation procedure for Emacs: just download it, decompress it, put the decompressed folder to your preferred location, and make a shortcut so that you can easily launch it. Fr a better mood for editing, you can find color themes here:
Just decompress the file you download and put the folder into your preferred location. In order to let Emacs find the color themes, we have to add the folder into the load list. You can do that by modifying the customized Emacs setup file: .emacs, which is located in ~/AppData/Roaming/ for Windows 7. Note that the file .emacs should be in parallel with the folder emacs.d. If there is no such a file, you should create it yourself. Add the following line in the .emacs file to help Emacs find the folder:
  • (setq load-path (append load-path (list "../../el/color-theme-6.6.0")))
We use the relative path here. The current entry of Emacs on load should be the folder bin where Emacs is launched. We create a folder el to place all installed emacs-lisp files in parallel with the folder emacs-23.3. You can choose your preferred location and modify the path being added accordingly. Then you need to link the command so that you can call color-theme by M-x:
  • (require 'color-theme)
To link all commands to all themes (a command in color-theme):

  • (color-theme-initialize)
And set up the default color theme:
  • (color-theme-robin-hood)
which is one of my favor. The theme color-theme-charcoal-black is also pretty good. Restart Emacs in order to see the effect. If the selected theme does not appear, check here for a detailed setup procedure:

Next, we are going to install Aspell and the dictionaries. Aspell is the spell-checking program which is newer than ispell. Anyway, to simply put it, if you need auto-spell checking capability when you are typing in Emacs, you need to install it. You can download it here
You need to install the program before installing each dictionary. The Aspell version 0.5.3 will not add itself to the path. You can try this command
  • aspell -a
to see if the Aspell command is in the path. If not, you have to add it to the path. Once it is in the path, you can use M-x flyspell-mode to check spelling every time when you type a word.

Last, you will need to install AUCTeX. You can find it here:
Installing AUCTeX is relatively easy: just decompress the .zip file, and copy&paste the decompressed folders to overwrite your original Emacs software. Here you have to make sure the AUCTeX version is compatible with the Emacs being overwritten. That's all for Windows!

Enjoy LaTeXing in Emacs!

Friday, September 16, 2011

Embed Fonts in PDF

Got complaints from your publisher about missing fonts? Here we compile a set of commands that you can embed and check whether your file has included everything.

The source is here
http://www.grassbook.org/neteler/highres_pdf.html
 
  • ps2pdf -dEmbedAllFonts=true main.ps main2.pdf
If you don't have the .ps file with you, try to convert the .pdf file to .ps first
  • pdf2ps main.pdf
You can check whether every font is included by
  • pdffonts main.pdf
That's all!
Please consult with the 2nd link above for the limitation of ps2pdf. In my case, ps2pdf generates high-resolution bitmapped fonts rather than the original outlined fonts. The bitmapped fonts make the resulting .pdf file pretty ugly on the screen though the print-out is fine.

Any solution for that?