texmath icon indicating copy to clipboard operation
texmath copied to clipboard

Handle < and > in array column specifiers

Open catap opened this issue 4 years ago • 3 comments

I just discovered the next issue when array's is used instead of case.

The test case:

\documentclass{scrartcl}

\usepackage{amsmath}
\usepackage{array}

\begin{document}

\setlength{\arraycolsep}{1pt}
\begin{equation}
  x =
  \left\{ \begin{array}{>{\arraybackslash$} p{3cm} <{$} l}
            y - 1, & \mbox{if } 1 \\
            y,       & \mbox{if } 2 \\
          \end{array} \right.
\end{equation}


\end{document}

Error:

[WARNING] Could not convert TeX math 'x =
    \left\{ \begin{array}{>{\arraybackslash$} p{3cm} <{$} l}
              y - 1, & \mbox{if } 1 \\
              y,       & \mbox{if } 2 \\
            \end{array} \right.', rendering as TeX:
  ft\{ \begin{array}{>{\arraybackslash$} p
                     ^
  unexpected ">"
  expecting white space, letter, "|" or "}"

catap avatar Dec 28 '20 19:12 catap

What is the meaning of the column specifiers {>{\arraybackslash$} and <{$}? That's the part the parser doesn't seem to understand.

jgm avatar Dec 28 '20 20:12 jgm

>{XXX} and <{YYY} are used to put XXX in the entry of column and YYY right after entry of the column.

In my case it puts

  • \arraybackslash to restore behaviour of \\ that is used to break a line :)
  • $ after \arraybackslash is using to start math environment,
  • $ at the end to finish math environment.

catap avatar Dec 28 '20 20:12 catap

@jgm any news with this? :)

catap avatar Feb 18 '21 22:02 catap