Parallel text and vocabulary in LaTeX

In order to have LaTeX produce sample passages for foreign-language study, but annotated with vocabulary items, I use

  • the parallel package for aligning two text streams (text on the left, vocabulary on the right)
  • the ulem package for underlining words in the text
  • the xeCJK package and the two HAN NOM fonts for Chinese

Here is an example of the format:

Sample Chinese Vocabulary example

The code to produce this may be found at http://bitbucket.org/dpb/parallel_vocabulary_list

Frank Mittelbach’s “moral obligation” license for the LaTeX multicol package

In a recent paper on the history of the LaTeX Project Public License, Frank Mittelbach includes a digression on the licensing of his enormously useful multicol package. He describes the “moral obligation” license of this package as

perhaps the most curious license ever drawn up, in that I required … the licensee to determine the importance of [the software] for his or her circumstances and determine the license fee from that. TUGboat 23(2011)/1:83–94; section 1.2 (p. 84)

The actual terms of the license appear in the multicol.sty file in the standard LaTeX distribution:

%%  Users of multicol who wish to include or use multicol or a modified
%%  version in a proprietary and commercially market product are asked
%%  under certain conditions (see below) for the payment of a license
%%  fee.  The size of this fee is to be determined, in each instance,
%%  by the commercial user, depending on his/her judgment of the value of
%%  multicol for his/her product. ...

I wrote to Mittelbach recently about this matter, and he resolved my questions very charmingly.


Multicol enables segments of different numbers of columns to appear on the same page, along with other functionality helpful in formatting columns. I have used this package in typesetting Jerry Norman’s Manchu dictionary, to place single-column headings at the start of each letter-section in an otherwise two-column text. For example: Jerry Norman, Comprehensive Manchu-English Dictionary, top of first page of section E

I think this sort of section-header must be desirable in many dictionaries.

Manchu dictionary done

Since late Spring of 2009, I have been helping my teacher, Jerry Norman, get the final revision of his Manchu lexicographic material into shape for publication. Earlier editions appeared in 1978 (U. Washington Press) and 1967 (Taipei). I have typeset it (strictly, composed it) using LaTeX and checked and corrected the entries in numerous fine details, and persuaded Prof. Norman to add material on pronunciation and the script, surely important in any dictionary of a foreign language. My mother, who knows neither Manchu nor Chinese but who has professional experience as a proofreader, has read the whole thing carefully twice and suggested countless improvements to the English and the organization of the book.

Now it is done. After two and a half years, today I sent Prof. Norman the final draft of the dictionary, which I hope will see print within 12 months, as A Comprehensive Manchu-English Dictionary.

Calculus III progresses

I am struggling to get caught up on my Calculus III homework. The first exam is 12 days away. I’m deep in the section of the book about which the instructor said, “This is the longest homework section in the semester and it will be the majority of the first exam. Those are the problems to stress about.” (I am obedient in all things, sir.) He recommends ten hours of homework a week for a five-hour-a-week class.

When I started the term, it was taking me an average of 30 minutes per problem — something I can’t imagine the other students are experiencing. I spent four hours on actual problem-solving today, plus perhaps another hour or so of flash-card making and other sorts of review. It hardly seems very much time. But I am pleased to find that my average speed is now down to 20 minutes/problem. That’s cause for optimism, even if it still feels as though my brain is a corroded mass of old gears. Come to think of it, I’ve had that sensation every time I’ve taken math recently, but somehow the immediacy of the sensation is replaced by a feeling of accomplishment after the stress of the moment has passed. It has been 25 years since I took Calculus II, but I think the gear-box is getting back to functioning condition.

Initially, I studied by taking careful notes on the ideas of each section in the text book, and only doing problems afterwards. But now I think that’s for the birds. Doing problems and groping my way through the ideas as I need to has proven a more effective way to get comfortable with the material. The notion that theoretical understanding, gained from reading the chapter, is a useful guide to problem-solving, is nonsense here just as it is in every other field I know of.

By far the most common cause of error in my work is sloppy arithmetic errors — half the time, it is just the result of getting plus and minus signs wrong. This in spite of considerable effort to avoid such mistakes. I have had this problem since my childhood. Using LaTeX to do my problems makes it easier to find them, since I can now actually read and even search mechanically through what I’ve written.

Tales from Calculus III

Twenty-five years after I took Calculus II, I am enrolled in Calculus III at City College. I’ve heard from many students that the instructor is one of the best in the program — he is leading one of ten sections this semester and I drew him by chance. Below are some observations recently sent to a few correspondents.

The instructor has said firmly:

The more problems you do, the more shortcuts you will figure out for yourself. The only way you can do this is to do a ridiculous number of problems. You must work almost every day on this stuff, for a couple of hours a day.

Homework is not graded, but we are supposed to keep a special notebook in which “assignments”, meaning hard problems apart from the homework proper, are to be done — and those he will examine on occasion. If we’ve done them. On Thursday morning we were supposed to visit his office before class to show him that we do, indeed, possess such a notebook. The point was to encourage students to make the effort to identify a notebook for those problems early in the term. I was the only one who came, though, and I’m going to be using LaTeX, with his blessing.

The assignment sheet for the semester went up just before class on Tuesday and he announced it in class and told us to do the first three sections, 23 problems in all, mostly vectors, which are not well handled in LaTeX. I spent six hours doing the first assignment and got through 19 of the 23; the last four remain undone several days later, despite my good intentions. On the day they were official due, several of the students were still asking him when he would post the problem sets.

This instructor says he is going at solving problems but his memory is terrible, so he has never learned LaTeX. Instead, he uses MathType, which provides a GUI. It’s a pity, because a math course is really the ideal place to introduce LaTeX and guide students in elementary use of it.

The instructor made a pitch to interest me in abstract algebra. I must admit, what he showed me seemed quite interesting and intuitively clear. I have yet to understand what the place of math will ultimately be in my life — I only know I am not yet done with this question.

I am the only student in the class of around 30 who is taking notes on a computer. Some students do open up a computer briefly, but it seems to have something to do with messaging. I ran into a little trouble today with LaTeX because I had anticipated that we was going to introduce determinants, which I haven’t learned how to handle yet (actually it’s not hard, I now see — the amsmath package has everything I’m likely to need).


A correspondent, seeing the comment about doing “a ridiculous number of problems,” replied:

That sounds reasonable to me. The “problem” is that the advent of software like Wolfram|Alpha removes any real usefulness from this kind of skill … it is now a purely aesthetic amusement.

But I disagree. Skill brings understanding, and understanding leads to insight into other things whose existence you can predict but whose content and requirements you can’t easily anticipate. Much of the mathematical and theoretical component of the computer science education at City College consists of exposure to proofs, or to things like proofs such as building a linked list in C++, and so on. It is not as though we will ever need to build our own linked lists or derive Chebyshev’s inequality. But struggling to produce them myself helps me to understand and retain them, and there is considerable value in that.

generate native MATLAB code from finished figures, for study

There are many small irritations in MATLAB, such as the lack of native LaTeX support for tick labels on the axes in a figure and (at least on the current Mac OS X installation, v. R2011b) failure to support all the native Mac services, such as the “don’t save” key-binding when closing a window or normal filesystem windowing when print-to-file is selected. I do not see a way to save color figures to .ps files, either.

But here is one helpful thing. For study of MATLAB’s syntax on a level a little deeper than what is supplied in the various guides, after finishing a figure, use the menu item File -> Generate Code… to see how MATLAB really describes the figure you have produced. It is instructive to be able to see various efficiencies an inefficiencies introduced, as well as an explicit statement of some of the defaults you have unknowingly used.

LaTeX and electronic documents

The current issue of TUGboat (32.2, 2011), the Communications of the TeX Users Group, has eight papers in a section called “Electronic Documents,” dealing with various issues affecting the relationship between LaTeX and the latest fashions in on-line publishing and mobile devices. The ePub format, standard on most e-readers, remains a significant rival to the dominance of PDF, widely used for long-term document storage, and several of the articles address the challenges ePub presents.

All are worth reading; I single out these two as especially useful:

A third noteworthy paper is Axel Kielhorn’s “Multi-target publishing” (based on a German original, also 2011), which describes pathways from LaTeX to PDF or ePub output by way of John Gruber’s Markdown language (currently at http://daringfireball.net/projects/markdown/). The chief element of these pathways is Pandoc, on which see http://johnmacfarlane.net/pandoc (accessed 20120107); the main Github repository is currently at https://github.com/jgm/pandoc (accessed 20120107).

“Suppose” for math proofs, in LaTeX

Slightly adapted from a suggestion by Scott Pakin, here is LaTeX code to generate the “suppose” symbol used by some mathematicians in writing proofs:

\newlength{\Swidth}
\newcommand{\suppose}{%
\settowidth{\Swidth}{S}
\makebox[\Swidth]{\(_{\rule{.15ex}{.8ex}}\)}\llap{S}%
}

“Suppose there exists some \(x\) in set \(U\ldots\)” becomes \(\suppose\ \exists\ x\in U\ldots\)



The symbol is the letter S with a vertical bar through the bottom curve:

Graphing flowcharts and automata in LaTeX

The language Dot describes graphs in plain text. It is used with the Graphviz graphic application; both were originally developed at Bell Labs.

Below are a few notes on surprises I had when working with .dot and .svg (“Scalable Vector Graphics”, a standard XML-based format for graphs) files in Python:

  1. For viewing .svg files, desktop installations of Ubuntu use the Gnome viewer “Eye of GNOME” (eog) by default.
  2. Ubuntu’s (Lucid) server installation of graphviz does not include a viewer by default. You can display .svg files using Firefox; set the browser to about:config and confirm that you have the setting svg.smil.enabled;true and place an entry in your ~/.mailcap file:

    image/svg+xml; firefox

    Of course, you can also install eog on your server.

  3. The current Mac version of Graphviz (v. 2.28) has no trouble opening a .dot file, but apparently it cannot open .svg files.

For use within LaTeX documents, it is possible to do everything native packages or (more interestingly) to incorporate Graphviz output by converting it to a native format:

  1. The native LaTeX tools for producing flowcharts and automata are the tikz and pstricks packages. TikZ, which has more comprehensive support, supplies a library called automata (see the TikZ manual for detailed instructions. There is also a third library, VauCanSon-G, but it appears to have less functionality.
  2. There is a Python module, dot2tex by Kjell Magne Fauske, that converts .dot and other Graphviz formats to TikZ or pstricks.
  3. Fauske has also written a LaTeX package, dot2texi, that allows .dot (etc.) graphical output to be embedded directly in a LaTeX document.

Apparent misspelling in LaTeX command set: \guillemotleft and \guillemotright

The traditional French double quotation marks, « and », are called guillemets. They are used in the scripts of many modern languages, including some forms of Chinese (as 《 and 》 in restricted contexts).

The standard LaTeX commands to produce them, however, are \guillemotleft and \guillemotright; substituting e for the o leads to a compiler error. It seems that a non-standard spelling of guillemet influence the choice of the LaTeX command.

My Petit Robert (vintage 1991) defines guillemot: “Oiseau palmipède voisin du pingouin, habitant les régions arctiques [Web-footed bird related to the penguin, inhabiting arctic regions].” Perhaps this is all a plot to plant Linux imagery in people’s LaTeX code.

Table of contents in a LaTeX book: make the TOC entry different from the actual chapter headings in the text

Use

  \chapter[TOC form]{text form} 

at the start of each chapter. The TOC will have “TOC form” (supplied between square brackets) and the chapter itself will have “text form” (supplied between curly braces).

If the TOC form itself contains a closing square bracket (]), the compiler will think the balanced brackets [] have ended and generate an error. But rather than escaping the extra ], which may lead to confusion with the math display environment, place the whole TOC form within braces:

  \chapter[{TOC form with closing bracket}]{text form}

I normally use the package titlesec for fine control of chapter headings, but what is described above will work without it.

Remember that you have to compile your code twice in order to get the TOC to be updated correctly: once to typeset the whole text, and then once more to generate the TOC based on the typeset text.

———
[Edited] for clarity.

How I learned LaTeX

LateX is Leslie Lamport’s document preparation system based on Donald Knuth’s TeX typesetting language. Although at times rather complicated, it is the most powerful tool available to people like me for typesetting and formatting documents. I failed to learn it after several serious attempts, but one day I essentially placed myself in a situation where I had to learn it in order to function, and that worked.

In 1994 my wife and I were doing heavy dialect fieldwork in rural Fújiàn, but our visas ended in the Spring and we left China to look in on family and prepare for the next bout of fieldwork. At that time, the University of Washington had a little humanities computing center, where I went to get help with various computing tools. While there, I heard one of the staff making an enthusiastic plug for LaTeX. That must have been just after the Mittelbach/Goossens LaTeX Companion appeared. I found the software hard to install and soon gave up. In those days, I took my field notes by hand with technical pens and transferred them to Microsoft Word files, using a Macintosh font of my own design that had all the phonetic symbols I needed.

That situation repeated itself a few times in the following years. Norm Kabir made a valiant effort to interest me in LyX in 2006, knowing of my desire to automate the typesetting of database dumps. but I gave up again after difficulties with installation and with typesetting Chinese text.

In the Spring of 2010, however, while taking math courses at City College, I began to feel frustrated reviewing my handwritten notes or searching through them to find some example or detail. I tried taking notes on a simple text editor, but there were inevitable problems representing the more complicated mathematical forms. At the start of the Fall semester, remembering LaTeX, I installed the Mac “TeXShop” editor and spent one evening learning the most basic commands, choosing a command reference card to have handy all the time, and setting up a simple template. After tentative note-taking in a couple of classes early in the term, on 14 November I took the plunge and began using LaTeX for all in-class writing apart from exams. I have done so ever since, and am now able to reproduce just about everything I ever see in the classroom, except for actual drawings. (LaTeX tables remain time-consuming, and tree diagrams are just passable in the \verbatim environment.)

I’m a strong believer in the value of proficiency, to be cultivated by hands-on practice and even rote repetition, rather than understanding alone — because when we think we understand, we sometimes don’t really. And I’m convinced that the way to learn LaTeX is by forcing oneself to use it all the time. The pressure of real-time transcription forced me to solve problems on the fly and find ways to retain what I had learned, and I think that is the best way to approach a complex tool like LaTeX. If I had waited until it was convenient to learn it, I would probably never have done so at all.

(My initial template was for LaTeX proper, but I have since switched to XeLaTeX in order to get better support for Chinese.)

Boris Veytsman’s review of Kottwitz, LaTeX Beginner’s Guide

Boris Veytsman gives limited praise to Stefan Kottwitz’s new \LaTeX guide (ISBN 13: 978-1-84719-986-7) in a two-page review. Briefly:

The new book … is very much unlike other introductory \LaTeX courses. The author, evidently, wanted to make a \LaTeX book for the new generation — the generation of Twitter and mobile devices. The book’s advantages and disadvantages stem from this. … Despite its flaws, this is an interesting book. It covers many useful topics not covered elsewhere, it is well written and is understandable for a novice. This book can be [the] basis of a crash course in \LaTeX or as a self-study tool — as long as the student does not use it as an example of the typographic art.

The full review (TUGboat 32/2:228–29) is on-line at the TUG site, and TUG currently has a discount code for the book, as does the publisher.

Chapter 5 of the book, “Creating Tables and Inserting Pictures,” is currently available on-line.