Thursday, March 05, 2009

TeXgefühl

German has several words for which there is no English equivalent, and so we've adopted them into our language. Of these, perhaps the most famous is Schadenfreude (literally, something like "harm-joy"), which means "pleasure taken at the misfortune of others".

Another good one is Ohrworm. Literally "ear worm", it refers to a catchy song that you just can't get out of your head.

My colleague Jean-Paul Allouche introduced me to another some time ago: Sprachgefühl. Literally, "language feeling", this word refers to a native speaker's intuitive understanding of the subtleties of his own language. When a French speaker says, "We now prove this by recurrence on n", Jean-Paul looks at me and mouths the word "Sprachgefühl", because he knows that the speaker should have said induction, not recurrence. Similarly, French speakers often say couple instead of pair, and speak about notations instead of notation. (Notation is usually a mass noun in English and hence rarely appears in the plural in mathematics and computer science research -- unless the paper is written by a non-native speaker!) French speakers also often say something like "We denote by |x| the length of the word x", when a native speaker would probably say something like "We let |x| denote the length of the word x".

Based on this, I've coined a new word: TeXgefühl. This means "the intuitive understanding of what is proper usage in the mathematical typesetting language TeX". (There is also the related word, LateXgefühl.) Neither word appears in a Google search, so I really do appear to be the first to say them online.

Both TeX and LaTeX have some subtleties which beginners find difficult to master. These include constructs that improve the appearance of the manuscript, like knowing to put "\ " after any lower-case letter followed by a period that does not end a sentence, as in "Dr.\ Smith"; if you don't do this, tex inserts too much space between "Dr." and "Smith". Another example of TeXgefühl is knowing to use the proper kind of dots in a mathematical expression -- you should write "x_1,   x_2,   \ldots,   x_n" but "x_1   x_2   \cdots   x_n". The subtleties also include knowing that both TeX and LaTeX have reasonably good algorithms for deciding on spacing, so that manuscripts should not be littered everywhere with "\noindent" and \bigskip", and that there is no need to put "\par" or "\\" at the end of every paragraph.

If you have LaTeXgefühl, you know not to hard-code references to theorems, lemmas, etc.. Instead, you use labels inside theorem environments to store the name of the theorem, and then you refer to to the theorem by saying something like Theorem~\ref{thm1}. (The twiddle after "Theorem" is another example of TeXGefühl.)

Those with TeXgefühl know that single-letter functions are always in the italic font, using something like $f(x)$, but that multi-letter functions, such as sin and cos, are nearly always in the roman font, and should be specified using the built-in expressions \sin and \cos. (For some reason, many people also forget this for \gcd.) They know that left-quotes in TeX are different from right-quotes, so that you should write ``quoted expression'' instead of "quoted expression". And they know that page ranges should be specified with two hyphens, like "237--246".

It's hard to attain Sprachgefühl in a foreign language - I will probably never get there in French or German. But with a little work, nearly everyone can attain it in TeX.

22 comments:

Anonymous said...

Fingerspitzengefühl is a personal favourite of mine, a sort of generalization of sprachgefühl applicable to any activity that requires some form of skill.

dot said...

> knowing to put "\ " (...)
> as in "Dr.\ Smith"

I actually thought that you were supposed to put Dr.~Smith, so that the Dr. would not risk ending at the end of the line?

Among other TeXgefuhl, I would add
$\begin{array}{|c|*{8}{c|}} (...) \end{array}$ when you want an array with one title column and 8 data columns.

Jeffrey Shallit said...

Sure, you can do that, too. It doesn't bother me if Dr. and Smith are split over 2 lines, but perhaps I should have given a different example.

Dave said...

Those with TeXgefühl know that single-letter functions are always in the italic font, using something like $f(x)$, but that multi-letter functions, such as sin and cos, are nearly always in the roman font, and should be specified using the built-in expressions \sin and \cos.

Actually, I follow the convention that specific functions such as sin, cos, gcd, are not italicized, but variables that refer to functions (e.g., let $f:\N\to\N$) are italicized, not just for functions but in general. So even if I make up my own single-letter function, such as b_2(n) that outputs the base-2 expansion of a natural number n, I would leave it unitalicized. Similarly, I would write "let $func:\N\to\N$" and let func be italicized to represent that it is a variable not referring to one particular function.

Mike said...

My least favorite violation of TeXgefuhl is when someone makes angle brackets by doing $<x,y>$ instead of $\langle x,y \rangle$. Man, that is ugly.

Eamon Knight said...

About Franco-English mismatches: A couple of years ago I joined a project for which most of the base code had been written in France. The comments, at least, were in (frequently stilted) English, but what threw me for a while were the frequent references to "valorisation" of data. I eventually figured out that it meant nothing more esoteric than an en masse initialization, ie. the assigning of values to a whole whack of stuff. Nothing to do with making the data brave and strong....

Anonymous said...

Do you remember the old VW commercials that used the word Fahrvergnügen. Like a lot of german words, I think this one is just plain fun to say.

Anonymous said...

One good LaTeX trick that some folks don't use is using \left and \right to automatically make the "big" parentheses, brackets, braces, etc.

Re. English subtleties: a very common expression I find in papers written by French speakers is "We now precise the following..." (This is legit in French, since "preciser" is a verb in French.) Another example is the use of "unicity" instead of "uniqueness".

Anonymous said...

Similarly, I would write "let $func:\N\to\N$" and let func be italicized to represent that it is a variable not referring to one particular function.

Shouldn't that be "let $\mbox{\em func}:\N\to\N$" instead?

Anonymous said...

How about Htmlgefühl? I get really confused going back and forth between LaTeX and HTML tables.

Anonymous said...

This is sort of off topic, but I was listening to some Dennett earlier and it occurred to me that if we adopt the word Schadenfreude into the English language that would be horizontal meme transfer, haha.

Anonymous said...

Similarly, I would write "let $func:\N\to\N$" and let func be italicized to represent that it is a variable not referring to one particular function.

Shouldn't that be "let $\mbox{\em func}:\N\to\N$" instead?


I believe complete LaTeXgefuel-ness (how's that for a new word?) requires using \DeclareMathOperator{\func}{func}, and then writing \func, just like \sin and friends.

Sometimes I download the source to an arXiv paper, or paper from an online journal, and am usually appalled at what I see. I'm glad that I now have a word to use to express what they've done wrong!

NAL said...
This comment has been removed by the author.
Jeffrey Shallit said...

NAL:

What I wrote is correct; please look at it again. In the first example, we have items separated by commas, and for that you must use \ldots. In the second we have a product, and for that you must use \cdots.

Anonymous said...

Do your universities teach students how to use TeX? That would be great. Most people I know learned (La)TeX from someone who was already using it. They got some basic instructions, the not so short guide and an example.

I very slowly discovered all the examples of TeXgefühl you described over the years. Only a month ago I found out that I should never use eqnarray again.

Anonymous said...

In 18 years of typesetting over 300 technical books for publishers in TeX, I have never once wanted wide spaces after sentence-ending punctuation. It is an anachronism. Include

\frenchspacing

in your preamble and never again worry about the space after "Dr."

~~ Paul

Anonymous said...

Ionica, why shouldn't you use eqnarray? One quite common mistake authors make is to use a matrix when they really want a sequence of aligned (sub)equations.

~~ Paul

Paul C. Anagnostopoulos said...

Let me offer my services: If you have any TeX questions, I would be happy to answer them if I can. No charge, of course.

Note that I'm coming from the viewpoint of technical publishing, so I will tend to give you advice that matches what publishers and typesetters want when they produce books or articles from your files.

~~ Paul
pcanagnostopoulos@gmail.com

Anonymous said...

Dear Paul, thanks for your kind offer! I saved your email adres and will surely ask you some questions in the near future.

About the eqnarray, I noticed that my co-authors all switched to the aligned-environment for aligning multiple lines of equations or conditions. When I asked them if I should do this too, they answered with a firm `Yes'. And I must admit the spacing looks nicer with aligned, but I can't put my finger on the difference.

Paul C. Anagnostopoulos said...

Yes, the aligned environment is fine. Just don't use a matrix for aligned equations.

~~ Paul

Anonymous said...

And I must admit the spacing looks nicer with aligned, but I can't put my finger on the difference.

Eqnarray uses unconventional spacing that's inconsistent with the way all other equations are spaced in TeX. It was originally an ad hoc way to arrange multiple equations using the array features in TeX, by treating the = sign and the left/right sides of the equation as antries in an array. If you typeset a single equation using eqnarray and also the standard way, you'll see that the eqnarray spacing is dramatically different around the = sign (and definitely worse). The newer aligned command fixes that problem.

Anonymous said...

Interesting post, interesting reactions. One meme is missing though, to my mind: for some of these issues, AMSTeX and AMSLaTeX have an arguably better approach.

One is the dots: I like the approach where \dotsb is for dots between binary operators, \dotsc is for dots between commas, \dotsi is for dots between integral signs etc.

I believe that \DeclareMathOperator, suggested by Dan, is another excellent AMS(La?)TeXism.

And finally, as I think Ionica refers to in their first comment, AMSLaTeX has environments that are far superior to eqnarray, such as align.

Thanks for an interesting post.