3

After updating my TeXLive today (last updated about six weeks ago), the following MWE will stop with the recrimination:

Illegal pream-token (^): `c' used. 

If I comment the Latin activation line, then no problem. I have tried all variants of Latin, and checked the manuals of array and polyglossia for hints, but I can't spot the culprit, any ideas? Any recommended hack?

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass{book}

\usepackage{fontspec}
    \setmainfont{Times New Roman}

\usepackage{polyglossia}
    \setdefaultlanguage[variant=british]{english}

    \setotherlanguage{latin}

\usepackage{array}
    \newcolumntype{$}{>{\global\let\currentrowstyle\relax}} % row format
    \newcolumntype{^}{>{\currentrowstyle}}
    \newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
      #1\ignorespaces
    }

\begin{document}

\begin{tabular}{$c^c^c}
\rowstyle{\bfseries}   1&2&3\\
\end{tabular}

\end{document}

2 Answers 2

5

With latin, the character ^ is a shorthand, so it is different in the preamble than in the body of the document. Shorthands used to be activated as soon as the language is loaded, not any longer.

You have three strategies:

  1. transfer \newcolumntype{^}{>{\currentrowstyle}} after \begin{document}
  2. use the cryptic code

    \begingroup\lccode`~=`^\lowercase{\endgroup
      \newcolumntype{~}{>{\currentrowstyle}}%
    }
    
  3. use a different character for the column type

My preference would go to the last option.

Fourth strategy: forget about \rowstyle.

4
  • Forget about \rowstyle? You mean to apply it for every cell of the row, typically the header. I don't know, it is quite cool to have a key 'header format', for instance, make it \bfseries and have it applied to the whole header. True, if you have a \multicolumn, you have to do it by hand anyway. Well, you are right, it is cool but not as useful as it might seem Feb 15, 2020 at 21:00
  • @RaoulKessels It can be useful if you need to alternate styles between rows (but that usually makes for bad tables). For a single row it adds an unneeded complication, IMHO. Pasting a few \bfseries commands is not so difficult and time consuming.
    – egreg
    Feb 15, 2020 at 21:02
  • I agree on both points. The only thing is that it makes the row very long in the source. Usually you get a header in two lines while the main body is nicely aligned. Then, when using \rowstyle, you need to put something between the the alignment specifications. I use |, which then makes it difficult to place vertical lines in the table, which are, I am very sure you will agree, horrible ;-) Feb 15, 2020 at 23:08
  • I went with your option 3, and changed the character to ª. So using \newcolumntype{ª}{>{\currentrowstyle}} everything runs nicely, thanks. Feb 17, 2020 at 9:15
5

gloss-latin makes the ^ active at begin document. This means the tabular doesn't recognize it as a defined columntype anymore. If you activate the shorthand it works again:

\documentclass{book}

\usepackage{fontspec}
    \setmainfont{Times New Roman}

\usepackage{polyglossia}
    \setdefaultlanguage[variant=british]{english}

    \setotherlanguage{latin}

\usepackage{array}
    \newcolumntype{$}{>{\global\let\currentrowstyle\relax}} % row format

    \newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
      #1\ignorespaces
    }

\shorthandon{^} %<---
\newcolumntype{^}{>{\currentrowstyle}}
\begin{document}

\begin{tabular}{$c^c^c}
\rowstyle{\bfseries}   1&2&3\\
\end{tabular}

\end{document}

1
  • This makes the MWE run fine, but with my full preamble, loading many other packages, it became complicated... so I went with @egreg 's suggestion and used a different character; see my comment to his answer. Feb 17, 2020 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .