Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The polynom style (version “2006/04/20 0.17 (CH,HA)” from texlive 2012) has to be told about which tokens represent variables. The manual has an example like this:

\polyset{vars=XYZ\xi,  % make X, Y, Z, and \xi into variables
         delims={[}{]}}% nongrowing brackets

When I try to typeset this in a minimal document

\documentclass{article}
\usepackage{polynom,amsmath,amssymb}
\begin{document}
\polyset{vars=XYZ\xi,delims={[}{]}}
\polylongdiv{\xi^2-1}{\xi-1}
\end{document}

I get the following error message:

! Missing \endcsname inserted.
<to be read again> 
                   \xi 
l.4 \polyset{vars=XYZ\xi,delims={[}{]}}

So there appears to be a problem trating greek letters as variable tokens. Can anyone suggest a way to resolve this, i.e. to actually typeset a ξ or similar greek letter as a variable in a polynom long division?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The manual seems wrong about this: you must use simple letters for your polynomials; but you can use a devious hack:

\documentclass{article}
\usepackage{polynom,amsmath,amssymb}
\begin{document}

\begingroup\mathcode`A=\xi
\polyset{vars=A}
\polylongdiv{A^2-1}{A-1}
\endgroup

\end{document}

Just choose an unused letter for your Greek one, et voilà.

enter image description here


A bit of explanation is in order. When TeX is in math mode, it looks at letters (more precisely, character tokens of category 11 or 12) as math characters, which have a mathcode attached to them. Control sequences can denote a mathcode and this is the case for the Greek letters: the definition one finds in fontmath.ltx

\DeclareMathSymbol{\xi}{\mathord}{letters}{"18}

ultimately boils down to the primitive statement

\mathchardef\xi="0118

where the first digit 0 tells TeX \xi is an ordinary symbol; the second digit is the "math group" (1 corresponds to letters); the third and fourth digits tell the slot in the font where the symbol should be taken from.

With

\mathcode`A=<number>

we assign A a mathcode with the same specifications; actually we don't need to know what mathcode is associated to \xi, because any control sequence defined with \mathchardef can be used as a number when the syntax of TeX requires one. So with

\mathcode`A=\xi

we're saying that any A in a math formula, from that point on, will just behave like \xi. Of course this respect grouping, so all of this takes place in a group; I delimited it with \begingroup and \endgroup, { and } would be good too, but the former delimiters pose less problems than the latter in certain situations.

share|improve this answer
    
I would +1 this 10 times! I just spent 1 hour looking for the source of this error. Thanks! –  willem Mar 6 '13 at 16:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.