TeX and GNU Emacs: A simpleton’s journey

About four months ago, I asked this question on TeX-sx. Over the previous ten years, I had looked at GNU Emacs, as a programming editor, three or four times, and, each time, given up because I thought the learning and implementation curves too challenging.

But this time, encouraged by the helpful answers to my question, I decided to invest some time in learning Emacs and tweaking it to do what I wanted. And now, four months later, I’m really pleased with the journey so far.


I’m a Windows 7 user, using TeX Live and Emacs 23.3 for Windows. As a specialised software developer, my main TeX products are proposals and design documentation (though I also use it for all my ‘domestic text processing’ tasks). I generally manage documentation source, and everything else in a project, with Git.

Editing documents with Emacs

Plain Emacs out-of-the-box does a wonderful job, but for TeX editing you need a bit more: AucTeX, which provides many useful tools for TeX editing, including a component, RefTeX, which presents you with an intelligent TOC right there in your editor, allowing you to navigate (across multiple input files, of course), and to create index entries, labels, and cross-references very easily. AucTeX also has an outlining component which allows you to fold up your section hierarchy.

Just to whet the appetite, here’s a screen shot of a (fully unfolded) piece of a RefTeX toc:

As well as using Emacs for TeX editing, for notes and brainstorms I can heartily recommend org-mode, which is (much more than) an outliner, with facilities for To-Do items and table manipulation, as well as the usual structural organising.

It took some time to get Emacs tailored exactly to my liking. It’s a bit like typography in that respect; there are always opportunities for ‘just one more tweak’, and a lot of self-control is needed. But you should expect to do some customization, perhaps with help from SO or TeX.se.

Things I have not been able to do

The main reason for these, I think, is that my perception of the effort and irritation needed to get x working exceeds the effort and irritation of ignoring it or inventing a work-around. Here are the principal ones:

  • Unicode support from the keyboard: I occasionally work in multiple languages, including Welsh and Turkish, which are not catered for by ISO-8859-1. I have a customised Windows keyboard layout which generates the right Unicode characters, but Emacs, despite hours of cutting and pasting tentative solutions from the Internet, still insists on shoehorning them into ISO-8859-1: ŵ becomes w, ğ becomes g, and so on. I’ll live with it.
  • I haven’t tried to get Emacs to run LaTeX and produce a preview for me — I use Texworks for that, editing a dummy file which simply points to my master document file. One day…
  • I can’t seem to get references to labels in other files of the same book to work. One day…
  • Doing anything to the *toc* (refreshing, for example) always seems to split the screen. Just grin and bear it.

Summing up

Emacs is a fantastic editing system, and I’m gradually moving all my editing over to it from Notepad++ (something I never imagined doing). I confess to feeling a bit dizzy with all the new key combinations (I sometimes try to close other things with Ctrl-X Ctrl-C), but I’m really overjoyed at having made the move. I know Emacs isn’t for everyone, but if you’re not completely satisfied with your current editor, you really should consider it.

Filed under Editors, Workflow

A new open font: Adobe Source Sans Pro

2012-08-03 by . 6 comments

Using TeX is about more than just the TeX document itself: fonts are a big part of producing high quality documents. One of the issues facing all fans of typography is the availability of fonts. Many professionally-produced offerings are expensive, and have licenses which are restrictive. Of course, there are some notable exceptions, with a number of excellent ‘free’ (as in speech) fonts available. Probably most notable to TeX users in the latter category are those from the Latin Modern/TeX Gyre Project.

Probably the biggest single player in pushing free font development is Google, but their focus is of course more on web technologies than typesetting. There’s now another notable entry in the open source font arena: Adobe. They have just released Source Sans Pro, which as you’ll guess from the name is a sanserif font. Currently, there are no small caps and no Greek or Cyrillic, but it does have old-style and table numerals, and superscript letters: check out the full coverage. (There’s no math support either, but we’ll let them off as that is seriously hard work.) The blog entry announcing the font suggests that there will be a matching monospaced variant in time.

As a demo of the new font, and to show off some TeX, Brent Longborough has put together a reproduction of the front page of Tschichold‘s Elementare Typographie using Source Sans Pro for XeLaTeX. This exploits the LaTeX3 coffins concept, and even takes accounts of side bearings using some code from TeX-sx. As the aim here is to show off the font, first we’ll see the result

then the code

% !TEX TS-program = XeLaTeX
\setsansfont{Source Sans Pro}
  \kern-\XeTeXglyphbounds3 %
  \the\XeTeXcharglyph`#1 %
  \kern-\XeTeXglyphbounds1 %
  \the\XeTeXcharglyph`#1 %
\NewCoffin \result
\NewCoffin \aaa
\NewCoffin \bbb
\NewCoffin \ccc
\NewCoffin \ddd
\NewCoffin \eee
\NewCoffin \fff
\NewCoffin \rulei 
\NewCoffin \ruleii
\NewCoffin \ruleiii 
\SetHorizontalCoffin \result {}
\SetHorizontalCoffin \aaa
  {\fontsize{52}{50}\sffamily\bfseries \kleft{m}itteilunge\kright{n}}
\SetHorizontalCoffin \bbb
  {\fontsize{52}{50}\sffamily\bfseries \kleft{t}ypographisch\kright{e}}
\SetHorizontalCoffin \ccc
                      \quad zeitschrift des bildungsverbandes der
                      deutschen buchdrucker leipzig 
                     \textbullet{} oktoberheft 1925}
\SetHorizontalCoffin \ddd {\fontsize{28}{20}\sffamily sonderheft}
\SetVerticalCoffin \eee {180pt}
\SetVerticalCoffin \fff {140pt}
                 {\raggedright \fontsize{13}{14}\sffamily\bfseries 
                       natan altman \\
                       otto baumberger \\
                       herbert mayer \\
                       max burchartz \\
                       el lissitzky \\
                       ladislaus moholy-nagy \\
                       moln\'ar f.~farkas \\
                       johannes molzahn \\
                       kurt schwitters \\
                       mart stam \\
                       ivan tschichold}
% ------------------------------------------     
\RotateCoffin \bbb {90}
\RotateCoffin \ccc {270}
% ------------------------------------------     
\SetHorizontalCoffin \rulei  {\color{red}\rule{6.5in}{1pc}}
\SetHorizontalCoffin \ruleii {\color{red}\rule{1pc}{23.5cm}}
\SetHorizontalCoffin \ruleiii{\color{black}\rule{10pt}{152pt}}
% ------------------------------------------         
\JoinCoffins \result                \aaa 
\JoinCoffins \result[\aaa-t,\aaa-r] \rulei   [b,r](0pt,2mm)
\JoinCoffins \result[\aaa-b,\aaa-l] \bbb     [B,r](0pt,0pt)
\JoinCoffins \result[\bbb-t,\bbb-r] \ruleii  [t,r](-2mm,0pt)
\JoinCoffins \result[\aaa-B,\aaa-r] \ccc     [B,l](66pt,14pc)
\JoinCoffins \result[\bbb-l,\ccc-B] \fff     [t,r](-2mm,0pt)
\JoinCoffins \result[\fff-b,\fff-r] \ruleiii [b,l](2mm,0pt)
\JoinCoffins \result[\ccc-r,\fff-l] \eee     [B,r]
\JoinCoffins \result[\eee-T,\eee-r] \ddd     [B,r](0pt,4pc)
% ------------------------------------------     
\noindent\TypesetCoffin \result
% ------------------------------------------     

I think you’ll agree it’s a useful addition to the open source font library.

Filed under Uncategorized

To the victor, the potatoes

2012-06-30 by . 0 comments

I remember when I wrote my first application. I was young and inexperienced – an unskilled programmer trying to learn the ways of the Force. The code – ah the code! – was a real mess. But hey, the application was up and running. And I was happy to make things work.

At some point, I got interested in opensource. It was way stronger than me. But how would I embrace the cause? I’m not a perfectionist, but I knew my code – at that moment – was bad, and I was afraid of being ridiculed because of it. Reluctantly, I took the first step and published my first code in the wild.

Get ready for the most random quote ever posted in our community blog. It’s from a Pokémon game: “You’re a rookie trainer, aren’t you? I can tell! That’s OK! Everyone is a rookie at some point!” Truer words were never spoken.

We only gain experience with time. Time helps us write better code. More than that: time helps us be better people.

No man is an island. Living in a very competitive world, we sometimes forget about our neighbour. The daily routine sometimes makes us close our eyes to others. We can’t let that happen to us. Helping other people in their journey – even a simple “good morning, have a nice day!” – frees us from the indifference and apathy of a typical cold-blooded human. And – believe me! – makes us better people.

The title for this blog post might be a little strange. It’s a famous passage from Quincas Borba, a novel by the Brazilian novelist Joaquim Maria Machado de Assis. Machado de Assis is surely amongst the great writers of all time. When I was a kid, we had to read at least one of his books for a literature class. And I picked that one. The full passage is as follows, a jewel of the Machadian literature:

Imagine a field of potatoes and two starving tribes. There are only enough potatoes to feed one of the tribes, who in that way will get the strength to cross the mountain and reach the other slope, where there are potatoes in abundance. But, if the two tribes peacefully divide up the potatoes from the field, they won’t derive sufficient nourishment and will die of starvation. Peace, in this case, is destruction; war is preservation. One of the tribes will exterminate the other and collect the spoils. This explains the joy of victory, anthems, cheers, public recompense, and all the other results of warlike action. If the nature of war were different, those demonstrations would never take place, for the real reason that man only commemorates and loves what he finds pleasant and advantageous, and for the reasonable motive that no person can canonize an action that actually destroys him. To the conquered, hate or compassion; to the victor, the potatoes.

In the novel, Quincas Borba is a philosopher who created a theory called Humanitism, which could be roughly summarized as the survival of the fittest. It’s a satire for both Comte’s Positivism and Darwin’s Natural Selection, a way of exposing the inhuman and unethical character of the survival of the fittest when applied to men.

I’ve been thinking of this question for a long time: should we share the potatoes? No.

We have something far more valuable to share than a mere potatoes: our knowledge. Sharing what we know gives everybody the chance of surviving. A community built with knowledge and valuing everyone in particular is healthier than a bunch of crumbs.

It’s been a privilege to be part of our TeX community. Everybody is welcome. And we try our best to make people feel that way. From a TeX newbie to an experienced TeXnician, everybody can help, either asking or answering questions. My great friend egreg brilliantly said that “without problems to solve the knowledge doesn’t improve”.

If you have any questions, please ask! Don’t be afraid. And if you can contribute to a question, either by answering it or even adding a comment, please do it. Everybody benefits from our actions, especially our community.

Help us make our community even better. Ask questions, write comments and answers, give advices, upload packages to CTAN, fork repositories, join a project, chat with other members. To the victor, the potatoes. To the wise, the community.

Filed under Advocacy, TeX.sx

Our first 100k+ user

2012-06-27 by . 7 comments

We have another great milestone in our beloved TeX community: our very first user to break the 100k barrier! Who? I’ll give you a hint:

more »

Filed under TeX.sx

TeXtalk: an interview with Andrew Stacey

2012-06-20 by . 0 comments

Welcome to the TeXtalk! We have a very special guest for today: our friend Andrew Stacey, a well-known member of our community, trusted user, 40k+ rep, 274 badges, and one of the resident TikZ experts. Get ready for this great interview! From this episode on, we are using the new interview format as discussed in our meta site. Hope you guys like it! :)

more »

Filed under Interviews

Representing TeX.SX in TeX and LaTeX Contests

Contests are a nice way of pursuing our TeX passion. We have an enjoyable competition, show our TeX skills and learn something new, while producing our contribution, and by seeing the results of other fellow TeXnicians. We already had a contest on TeX.SX, celebrating the first birthday of our site.

Contests are also a way to reach out to TeX users who did not visit our site yet: if such a contest happens somewhere else, and if we go there and show our skills.

Currently there’s one running on LaTeX-Community.org. LaTeX users are invited to write a small article, the best articles will be rewarded with a prize. Packt Publishing has sponsored two copies of the gnuplot Cookbook written by Lee Phillips for the winners. Matching the subject of the book, the topic of the contest is LaTeX and graphics.

The contest will close June 20th. So, there are some days left. Even small articles just like blog posts are very welcome. I would appreciate if some of our fellow TeX.SX users would join the competition. I know, we have very capable TeXnicians here on the site, also regarding the contest topic.

For more details about the competition and for a contact, have a look at the LaTeX Contest announcement.

Filed under Contests, LaTeX

The Hitch-Hiker’s Guide to LaTeX3

2012-05-23 by . 1 comments


As with the original Hitch-Hiker’s Guide, this blog post won’t actually be all that useful to someone wanting to truly explore LaTeX3. It’s more of a “What I did on my holidays” kind of guide. I’ve recently had my first go at doing some coding with LaTeX3 and I thought it might be interesting to record my experiences.

The main site has certainly made me more aware of the LaTeX3 project. Familiarity, in this case, has not bred contempt but rather it has meant that LaTeX3 has seeped into my consciousness so that I’ve become vaguely familiar with it without ever actually having to think about it. Before this current experience then I had had a bit of exposure to LaTeX3 through making a few adaptations to the (most excellent) unicode-math package, but that was very definitely a case of “Monkey see, Monkey not really have a clue what he’s doing so it’s a million to one chance but it might just work.”. To really get to grips with something new, I need a problem to work on. Finally, along came a problem that I wanted to solve in TeX but which was very definitely a regular programming problem. So the prospect of doing it in ordinary TeX was too daunting to contemplate. For this problem, learning LaTeX3 seemed the lesser of two evils.

more »

Filed under LaTeX3

KOMAscript: new English manual

2012-05-19 by . 0 comments

Markus Kohm, maintainer of KOMAscript has published a new version (3.11) of the KOMAscript bundle. There is one extraordinary issue: The new version includes a new manual in English. Markus said on his webpage:

»A new English user manual with the same structure and completely translated content of the German user manual is provided. There are still several issues with the translation, nevertheless, it’s much better than the previous English manual.«

As far as I can see, all the features of KOMAscript 3 are documented, the same as in the German version.

As TeXLive 2011 is frozen right now , you probably need to download the new version yourself from Berlios; follow the links on Markus’ website. Users of MiKTeX will probably get it soon.


Filed under LaTeX, Packages

A Tale of Two Questions

2012-05-18 by . 4 comments


For quite some time I’ve had the idea of writing a blog post about what makes a Great Question. The first problem with that is that it is highly subjective. I’ve no real problem with that (and this is the blog part of the site, after all) but it needs to be done carefully. The second is that it would be very easy to make it about what is wrong with questions rather than what is right. Particularly when comparing questions to see why one is great and another isn’t. So the post keeps getting started and then stopped as it trails off into a lengthy discussion about the quality of sand.

Fortunately, a recent question has given me a way in to this post. It’s almost a duplicate question, in fact. And the two questions are useful ones to compare to see the difference between a Good Question and a Great Question. Both questions are good questions, but the second version had a little bit extra which lifted it.

more »

Filed under Questions

Using sprite sheets with LaTeX

2012-05-04 by . 3 comments

Sprite sheet is the name of a big image containing several smaller images or icons. It’s a technique usually employed by webdesigners to reduce the number of requests the browser makes to the server – reducing the number of HTTP requests can make a Web page load much faster. It’s also used a lot in animation engines.

I was wondering if I could use a sprite sheet in a LaTeX document, so I got a sample image from the Tango Desktop Project and mapped it:

All icons are placed in a big image, like a matrix, and the size is fixed at 24px × 24px per icon. How can I select one of the icons from a LaTeX document? Thanks to our friend and moderator Martin Scharrer, including sprite sheets is a breeze with adjustbox!

This amazing package, amongst other features, allows us to adjust images with \adjustimage. We can also use \includegraphics with the clip option which we can use for mapping our sprite sheet. For instance, let’s include the warning sign in our document. We need to collect some data first:

We have all the parameters for including the warning sign. It’s now a simple call to \includegraphics[clip,trim=48px 96px 120px 48px]{sampletango.png} or \adjustimage{Clip=48px 96px 120px 48px}{sampletango.png} and the correct icon is included! The parameters to the trim/Clip option are:

  • 2 icons from left to right: 2 × 24px = 48px
  • 4 icons from bottom to top: 4 × 24 = 96px
  • 5 icons from right to left: 5 × 24 = 120px
  • 2 icons from top to bottom: 2 × 24px = 48px

The full code is as follows:


\usepackage{graphicx} \usepackage{adjustbox}


\begin{figure} \centering % using includegraphics % \includegraphics[clip,trim=48px 96px 120px 48px]{sampletango.png} % using adjustimage \adjustimage{Clip=48px 96px 120px 48px}{sampletango.png} \caption{A warning sign.} \end{figure}


The output:

There we go, sprite sheets with LaTeX. :)

Filed under LaTeX