Ads by Google

Saturday, June 28, 2008

What font is the text in the current buffer?

To know what the font and what the glyph codes are, use C-u C-x = on the current character the point is on. You should see something like

character: i (105, #o151, #x69, U+0069)
charset: ascii (ASCII (ISO646 IRV))
code point: #x69
syntax: w which means: word
category: a:ASCII graphic characters 32-126 (ISO646 IRV:1983[4/0]) l:Latin
buffer code: #x69
file code: #x69 (encoded by coding system windows-1252-unix)
display: by this font (glyph code)
-outline-DejaVu Sans Mono-normal-r-normal-normal-16-120-96-96-c-*-iso8859-1 (#x69)

It can also be invoked as M-x describe-char.

Wednesday, June 25, 2008

pgfplots: Plotting in LaTeX

pgfplots looks like a promising package for getting plots into LaTeX. I should probably give it a spin. The manuals, in PDF, here and here are detailed and extensive. And the plots are lovely; beautiful. (There, I get all nerdy)

One reason that I'd like to learn this package is that the alternate approach is to use gnuplot to generate a jpeg and then include that into LaTeX file. That comes with a whole bunch of issues like fiddling with fonts to match the LaTeX font scheme one uses, scaling the jpeg image to fit page and colours.

Since pgfplots is another package with the TeX system, it should be technically be a case of simpler and smaller dependencies for plots. And it uses the same pgf package that is part of the larger beamer package developed by Till Tantau. If you're a MikTeX user, it is available as a download from the package manager.

Saturday, June 21, 2008

Common Emacs lisp idioms

This page by Xah Lee might be useful if you're into elisp programming.

Wednesday, June 18, 2008

Changing the default mode of the *Scratch* buffer

The default *Scratch* buffer in Emacs starts in fundamental mode which might not be useful for lots of people who either don't know or want to work on elisp.

If text mode makes sense for you as the default, the following addition to the .emacs file should fix it.

(setq initial-major-mode 'text-mode)

Note that you don't lose much if you're trying out a few lisp forms as they can be eval'ed anywhere by hitting C-x C-e that would have the same effect as doing it in lisp mode.

Sunday, June 15, 2008

Creating animations in PDF using LaTeX

If you ever wanted to simple animations of your graphs or pictures in your LaTeX paper then the animate package is the way to go. The documentation and examples are good to get you started.

Wednesday, June 11, 2008

A quick way to open files in Emacs

Emacs users when interacting with the shell have a faster method to open files compared to other editors. Most editors will provide a shell escape through which a listing of a directory can be got; or a find command executed.

That's it.

You still need to highlight the interested file, copy into your "open file" dialog and then open the file. Well, Emacs offers the same feature too and more.

If your point is positioned at the start of the file name /tmp/foo, then M-x ffap which stands "find file at point" opens the file. As usual the excellent documentation of ffap gives you other options. Apart from the name, the way the file is opened is simply intuitive without any fuss. In fact, the documentation lists other options to ffap that might useful for mouse users.

Sunday, June 8, 2008

A better parentheses matching emacs package

For those who find the default parenthesis matching a bit lacking in features, the mic-paren package offers additional features that can be useful. I've been using it for quite some time and frankly, don't recall what I'd miss if I lose it. I mean, I've got used to thinking that this is the default behaviour of Emacs.

An indicative list of features from the package commentary...

  • Both forward and backward parenthesis matching (simultaneously if cursor is between two expressions).
  • Indication of mismatched parentheses.
  • Recognition of "escaped" (also often called "quoted") parentheses.
  • Option to match "escaped" parens too, especially in (La)TeX-mode(e.g., matches expressions like "\(foo bar\)" properly).
  • Offers two functions as replacement for `forward-sexp' and`backward-sexp' which handle properly quoted parens (s.a.). These new functions can automatically be bounded to the original binding of the standard `forward-sexp' and `backward-sexp' functions.
  • Option to activate matching of paired delimiter (i.e., characters withsyntax '$'). This is useful for writing in LaTeX-mode for example.
  • Option to select in which situations (always, never, if match, if mismatch) the entire expression should be highlighted or only the matching parenthesis.
  • Message describing the match when the matching parenthesis is off-screen(vertical and/or horizontal). Message contains either the linenumber orthe number of lines between the two matching parens. Option to select in which cases this message should be displayed.
  • Optional delayed highlighting (useful on slow systems),
  • Functions to activate/deactivate mic-paren.el are provided.
  • Numerous options to control the behaviour and appearance of mic-paren.el.
The package is also actively maintained and the latest version can be either found on the emacswiki site or at Thien's site.

Thursday, June 5, 2008

PDF autorefresh with AucTeX and Sumatra PDF

For users of Emacs on windows, Acrobat Reader does not play well with AucTeX. If the PDF file is open, while compiling the .tex file, Emacs will throw a write error because the reader locks the file for it's own use.

Sumatra PDF seems to have sorted this issue out in it's latest release of the viewer. At least that's what the release notes claim. I haven't tried it so far. But the announcement on the comp.text.tex newsgroup caught my eye and I think it's worth noting.

If it really works as advertised in the release notes, then one does not have to close and reopen the PDF file when generating it through AucTeX. With the autorefresh feature, it should be possible to iteratively add text and compile in a smooth workflow.

I shall have to try this feature and switch the reader if all goes well. The last time I tried the Sumatra PDF viewer I had problems rendering pgf rendered drawings. Maybe things are better this time as I did not fully check what was and was not supported in the earlier releases.

Wednesday, June 4, 2008

Listing code snippets in LaTeX

There are a number of ways and packages that provide for code listings in LaTeX. One that I personally prefer and that has enough options to customise is the listings package. It provides a multitude of options to pretty print code snippets. It has support for a number of languages which is more along the lines of keywords that is just about enough for code listings.

It has features to
  • Number the lines
  • keyword highlighting
  • Ability to add your own keywords
  • provide background colour
  • whitespace identification for languages that need them
  • labeling them for cross reference
One other feature is the ability to reuse the definitions into a style format, so that the same environment can be reused with a minimal of code repetition. And the documentation is excellent with lots of examples and feature setting explanation. For code which is indented, it also allows the verbatim code to be shrunk to fit the page(in the default font size, it does scroll off the page), though it does affect the readability of the page.