0

I am typesetting a document using the package tipa, and it happens often that the contents of each cell in a column of a table are notionally IPA and need to be enclosed between \textipa{ and }. So I want to define a column type which will add those enclosing strings.

I know the technique of using \newcolumntype from package array for enclosing such cell contents between two strings, e.g. \newcolumntype{M}{>{$}p<{$}} to supply math mode $'s. But what if a string to be added contains a backslash or a brace?

MNWE. Here, the \textipa disappears and I get literal braces. \backslash and \arraybackslash are to no avail.

    \documentclass[12pt,a4paper]{article}
    \usepackage{array} % for \newcolumntype
    \usepackage{tipa}
    \newcolumntype{I}{>{\textipa\{}c<{\}}}

    \begin{document}
    \begin{tabular}{I}
    lOrEm IpsUm
    \end{tabular}
    \end{document}
Rosie F
  • 444

1 Answers1

0

Thanks to Ulrike Fischer's referring me to this answer, I now find that the following does what I want. (I add two more columns, to show that the desired effect does not leak beyond the one column it is supposed to happen in.) Note that the braced expressions that follow > and < in the \newcolumntype command do not contain the braces which are meant to embrace the argument of \textipa.

\documentclass[12pt,a4paper]{article}
\usepackage{array} % for \newcolumntype
\usepackage{collcell}
\usepackage{tipa}

\newcolumntype{I}{>{\collectcell\textipa}c<{\endcollectcell}}

\begin{document}
\begin{tabular}{lIl}
left&lOrEm IpsUm&right
\end{tabular}
\end{document}
Rosie F
  • 444