2

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}
%\newfontfamily{\AR}[Script=Arabic]{Scheherazade}

\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?

cfr
  • 198,882
usr203050
  • 373
  • 4
  • 16
  • 1
    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
  • 4
    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 https://fr.wiktionary.org/wiki/pourtant (the pronunciation of pourtant). – usr203050 Sep 19 '15 at 16:47
  • I know what it would give because it works with latex (often inside math environment). – usr203050 Sep 19 '15 at 16:50
  • 2
    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 http://tex.stackexchange.com/q/224164/2693 for more comments. – Alan Munn Sep 19 '15 at 17:31
  • Also, how isn't this duplicate of Using TIPA with fontspec? – Alan Munn Sep 19 '15 at 17:37
  • @AlanMunn, indeed, I copied the code from there but the problem is entirely different. I try to adapt it for my purpose... – usr203050 Sep 20 '15 at 03:38
  • The issue is the same as in the duplicate question; besides, the current version of fontspec makes the code compile as is. – egreg Feb 02 '17 at 09:31

2 Answers2

1

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.

example image

Alenanno
  • 37,338
0

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

usr203050
  • 373
  • 4
  • 16