[Tex/LaTex] Bad mathchar with semantic package

package-options

I get the following error message when using the semantic package:

   ! Bad mathchar (32768).
<to be read again> 
                   \relax 
l.13 \begin{document}

The problem goes away if I load the semantic package with just the inference option. However, I do need math ligatures (the \mathlig command).

Also, the problem disappears if I do not load the mathtools package. Here is a minimal working example:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{semantic}

% \usepackage{mathtools}     % Uncommenting this causes the problem.

\mathlig{->}{\rightarrow}
\mathlig{|->}{\mapsto}

\begin{document}

Here is a formula: $a -> b |-> c$.

\end{document}

Best Answer

The semantic package documentation doesn’t explicitly tell that amsmath should be loaded before it.

Since mathtools loads amsmath, the same applies.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{mathtools} % must go before semantic
\usepackage{semantic}

\mathlig{->}{\rightarrow}
\mathlig{|->}{\mapsto}

\begin{document}

Here is a formula: $a -> b |-> c$.

\end{document}

enter image description here

I'm not really sure of the advantage of -> over \rightarrow and |-> over \mapsto.