0

This question already has an answer here:

In the same document (article), I'm using some math packages (amsmath, amssymb, mathcomp, wasysym), and it all works fine; but when I use TIPA with the special latex spaces (\, \; \! \:), LaTeX told me it was unable to build the pdf output. It gives me something like:

LaTeX Warning: Command \! invalid in math mode on input line 45.

Is there a way to make this type of space in math mode with TIPA?

A minimal working example:

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}

\begin{document}
$\forall x \in \mathbb{Z}, x=3k+c, c\in [\![0;2]\!]. -1\equiv 2
\;\:[3]$, so $\forall x \in \mathbb{Z}, x=3k+c, c\in [\![-1;1]\!].$\\
\textepsilon
\end{document}

marked as duplicate by egreg math-mode Aug 10 '16 at 21:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Could you post your code? Preferably in a compilable format (minimal working example)? – heather Aug 10 '16 at 18:36
0

Okay, so the problem is that TIPA defines over some of the math mode spacing commands. For example, \! can precede certain consonants to give you the implosives. Thus

\textipa{\!b}

Will give you ɓ.

Now when you load TIPA normally, it simply overwrites the standard LaTeX definitions. As such if you then try to use commands like \! in math mode, as you normally would, you will get an error, because the new TIPA definitions are being used and they don't work in math mode.

What you have to do instead is pass the [safe] option to TIPA, as described in the manual.

Finally, there is one more option called 'safe', which is used to suppress definitions of some possibly 'dangerous' commands of TIPA.

\usepackage[safe]{tipa}

More specifically, the following commands are suppressed by declaring the safe option. Explanation on the function of each command will be given later.

  • \s Equivalent to \textsyllabic; maybe harmless but too short for a control sequence name.

  • \* Already defined in plain TeX; however, many consider its redefinition harmless.

  • \|, \:, \;, \! Already defined in LaTeX; these redefinitions are obviously the most dangerous ones. However, remedies are prepared even in 'unsafe mode'. There is a command called \Vert which has the same meaning as \| and can be used in 'unsafe' mode. For the remaining three commands, TIPA provides commands called \tipamedspace, \tipathickspace and \tipanegthinspace which retain the meanings of \:, \; and \!, respectively, even in the 'unsafe mode'.

Despite the above 'remedies', you may sometimes want to use the above commands with their original names in the 'unsafe' mode. In such cases, a command called \tipasafemode can be used. For example:

Input:

\textipa{[\!b] [\:r] [\;B]}\quad{\tipasafemode
  $ a\:a\quad b\;b\quad c\!c\quad\| $}\quad
\textipa{[\!b] [\:r] [\;B] (back again!)}

As is shown in this example, \tipasafemode must be used within a group. Otherwise, the meanings of TIPA's special macros are lost.

This, however, gets rid of the TIPA shortcuts such as \!b, making them unusable. Instead, the standard LaTeX definitions are restored. This requires you to use the longer TIPA commands to produce these symbols. As such, you can no longer use \!b to get ɓ, you have to use \texthtb:

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[safe]{tipa}

\begin{document}

$\forall x \in \mathbb{Z}, x = 3k + c, c \in [\![0;2]\!].
-1 \equiv 2 \;\:[3]$, so $\forall x \in \mathbb{Z}, x = 3k + c,
c \in [\![-1;1]\!].$\\
\textepsilon

\begin{IPA}
  \texthtb
\end{IPA}

\end{document}

enter image description here

Instead, you might prefer to load TIPA normally without using the safe option. You can then use the \tipasafemode switch wherever you want to use the LaTeX math mode commands like \!:

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}

\begin{document}

${\tipasafemode \forall x \in \mathbb{Z}, x = 3k + c, c \in
  [\![0;2]\!]. -1 \equiv 2 \;\:[3]}$, so
${\tipasafemode \forall x \in \mathbb{Z}, x = 3k + c, c \in
  [\![-1;1]\!].}$\\
\textepsilon

\begin{IPA}
  \!b
\end{IPA}

\end{document}

enter image description here

Or if you really want to, you can use TIPA normally but replace your instances of \:, \;, etc. in math mode, with \tipamedspace, \tipathickspace, etc. I wouldn't do this:

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}

\begin{document}

$\forall x \in \mathbb{Z}, x = 3k + c, c \in
[\tipanegthinspace[0;2]\tipanegthinspace].  -1 \equiv 2
\tipathickspace\tipamedspace[3]$, so
$\forall x \in \mathbb{Z}, x = 3k + c, c \in
[\tipanegthinspace[-1;1]\tipanegthinspace].$\\
\textepsilon

\begin{IPA}
  \!b
\end{IPA}

\end{document}

enter image description here

  • I'm feeling a bit confused, it's working. And even if i don't know there is (also) a manual for tipa. The major you reminded me was that, sorry if i've cost you time. – prosopopee Aug 10 '16 at 20:39
  • @prosopopee whar are you confused about? – Au101 Aug 10 '16 at 20:40
  • That it was so simple and evident (not for everybody). – prosopopee Aug 10 '16 at 20:44
  • @prosopopee well i've tried to add a bit more explanation for you, see if that helps. There is (almost) always a manual, always check CTAN, or just google <package> manual and something should generally come up. This is a well-documented issue as you can see, I hope you can understand a bit better now what the problem is and the three different ways of overcoming it. – Au101 Aug 10 '16 at 20:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.