# Using TIPA with fontspec

I'm trying to write a document that will contain characters in many different scripts (for which I am using fontspec and rendering with xelatex) and IPA symbols (for which I am using TIPA). Ordinarily, this works fine, however, I want to use slshape for my IPA symbols. If I take the manual's advice and use

\textipa{\slshape f@"nEtIks}


Or

\textipa{\textsl{f@"nEtIks}}


It fails with fontspec loaded. The document renders properly, but the IPA symbols appear upright. If I remove fontspec, then this works correctly, with the IPA symbols slanted. I tried getting fontspec to use tipasl12, but I could not find a way of allowing fontspec to use the font. However I named it, fontspec could not find the font.

This is the LaTeX I have which produces the correct IPA symbols, but they appear upright:

\documentclass[12pt,openany]{book}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fontspec,xltxtra,xunicode}
\usepackage{tipa}

\begin{document}

\textipa{\slshape f@"nEtIks}

\end{document}


The following, however, works perfectly, but - obviously - would not allow me to use Arabic characters:

\documentclass[12pt,openany]{book}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{fontspec,xltxtra,xunicode}
\usepackage{tipa}

\begin{document}

\textipa{\slshape f@"nEtIks}

\end{document}

-

The Arabic font is not a factor. The problem is that fontspec redefines \textipa under the assumption that the Latin Modern fonts have the IPA glyphs, which however should be called by Unicode.

Solution: restore the Computer Modern fonts for IPA.

\documentclass[12pt,openany]{book}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}
\usepackage{fontspec}

\begin{document}
\renewcommand\textipa[1]{{\fontfamily{cmr}\tipaencoding #1}}

\textipa{\slshape f@"nEtIks}

\end{document}


A more complete version, taking into account also the need for typewriter type:

\documentclass[12pt,openany]{book}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}
\usepackage{fontspec}

\AtBeginDocument{
\renewcommand\textipa[2][r]{{\fontfamily{cm#1}\tipaencoding #2}}
}

\renewenvironment{IPA}[1][r]
{\fontfamily{cm#1}\tipaencoding}
{}

\begin{document}

\textipa{\slshape f@"nEtIks}

\textipa[tt]{f@"nEtIks}

\begin{IPA}f@"nEtIks\end{IPA}

\begin{IPA}[tt]f@"nEtIks\end{IPA}

\begin{IPA}\slshape f@"nEtIks\end{IPA}

\end{document}


-
Hi, egreg, thanks very much that works perfectly :) Sadly, however, I have to ask you to extend a little more help. That worked really nicely, but using \textipa{} with fontspec, for some reason, causes the symbols ", E and I not to display. They do display correctly within the IPA environment, i.e. between \begin{IPA}\end{IPA}. Using \begin{IPA}\slshape f@"nEtIks\end{IPA} does work (although \begin{IPA}\textsl{f@"nEtIks}\end{IPA} seems not to. Obviously that doesn't matter much, but I wanted to try typewriter text and, sadly, neither \ttfamily nor \texttt{} seem to work. –  Au101 Jul 27 '12 at 1:00
N.B.: I had to include a slight modification of your original advice: \renewenvironment{IPA}{\fontfamily{cmr}\tipaencoding}{} in order to get the IPA environment to work with \slshape –  Au101 Jul 27 '12 at 1:04
It's strange, because with the suggested redefinition of \textipa, the IPA environment gives correct results to me. –  egreg Jul 27 '12 at 7:03
Hmmmmm I thought that, perhaps because, by using \ttfamily I am declaring a new font family - does computer modern (as in cmr) include computer modern's typewriter text font. I'm not actually sure whether the default is teletype, teletype l or typewriter proportional. –  Au101 Jul 27 '12 at 11:20
@user16968 The problem is indeed in the typewriter type family; if you plan to use TIPA characters in typewriter type, then you have to stick to Computer Modern. –  egreg Jul 27 '12 at 12:44