# XeLaTeX and tipa [duplicate]

So, this code works with XeLaTeX

\documentclass[12pt]{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 pUK.t\~A}
\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}


But when I uncomment the line %\textipa{\slshape pUK.t\~A} just after the \begin{document}, it no longer compiles. How should I correct it?

• I don't know anything about this can \~A be replaced by Ã? It certainly compiles but whether it compiles to the correct thing, I know not! – cfr Sep 19 '15 at 16:13
• To the editor: deleting all blank lines is not helpful. Within the text body, blank lines are part of the code and have semantic meaning. Deleting them changes the typeset output. Within the preamble, they are often used to make code more readable. Removing these wholesale does not, in my opinion, improve the question and I have reverted most of these changes. (I've reduced multiple blank lines to 1 and removed a spurious space, but the rest is part of the MWE in my view.) – cfr Sep 19 '15 at 16:17
• @Romain Picot ^^ – cfr Sep 19 '15 at 16:20
• @cfr, no, it should give puʁ.tɑ̃, as in fr.wiktionary.org/wiki/pourtant (the pronunciation of pourtant). – usr203050 Sep 19 '15 at 16:47
• If you are already using XeLaTeX it makes more sense to not use TIPA but instead just define a new font family that contains phonetic characters and enter them directly into your source. See tex.stackexchange.com/q/224164/2693 for more comments. – Alan Munn Sep 19 '15 at 17:31

This answer is more of a suggestion for an alternative, and I think easier, method. Since you're using Xelatex already, you can set a regular font for your text, and a font only for IPA, therefore inputing IPA directly in your editor. I think it's also more readable when editing than tipa.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Century Gothic}
\newfontfamily\ipafont{Charis SIL}
\newcommand\ipa[1]{{\ipafont #1}}

\begin{document}\noindent
This is a paper about Linguistics (IPA: \ipa{lɪŋgwɪstɪks}). And it goes on...
\end{document}


I've set the regular font to something different than the default font, something more noticeable, so you see the difference.

Here I finally found the answer, after 24hrs of searching and trying. I hope this solves everything, although I may obtain new errors with increasing size of the document.

https://tex.stackexchange.com/a/127427/80224