[XeTeX] xunicode and TIPA
Ross Moore
ross.moore at mq.edu.au
Wed Jul 28 23:37:11 CEST 2010
Hi Ulrike and Alan,
On 29/07/2010, at 4:03 AM, Ulrike Fischer wrote:
>> I know the definition for the IPA environment isn't correct; what I
>> want is characters inside that environment to be interpreted in the
>> same way that they are within the \textipa command provided by xunicode.
>
> You must use a name with small letters for your environment (tipa
> activates the others)
>
> \documentclass{article}
> \usepackage{xltxtra}
> \newfontfamily{\ipafont}{Doulos SIL}
> \def\useTIPAfont{\ipafont}
> \newenvironment{ipa}{%
> \let\stone\TIPAstonebar
> \let\tone\TIPAtonebar
> \setTIPAcatcodes\activatetipa
> \csname useTIPAfont\endcsname
> }{}
> \begin{document}
> \textipa{RPAQIOE} % This will give you correct phonetic characters
> \begin{ipa}
> RPAQIOE
> \end{ipa}
>
> \end{document}
You can take the extra step to be able to use
\begin{IPA}
...
\end{IPA}
viz.
>>> \documentclass{article}
>>> \usepackage{xltxtra}
>>> \newfontfamily{\ipafont}{Doulos SIL}
>>> \def\useTIPAfont{\ipafont}
>>> \newenvironment{ipa}{%
>>> \let\stone\TIPAstonebar
>>> \let\tone\TIPAtonebar
>>> \setTIPAcatcodes\activatetipa
>>> \useTIPAfont % no need for \csname here
>>> }{}
>>> \let\realend\end
>>> \let\endIPA\endipa
>>> \def\IPA{\let\end\ipaspecialend\ipa}% change how \end works inside IPA envs
>>> \def\endendipa{\end{IPA}}
>>> {\catcode`I = \active \catcode`P = \active \catcode`A= \active
>>> \gdef\foundendipa{IPA}%
>>> \gdef\ipaspecialend#1{\def\testforipa{#1}%
>>> \ifx \testforipa \foundendipa\expandafter\endendipa
>>> \else\realend{#1}%
>>> \fi}%
>>> }% end of \catcode changes
>>>
>>> \begin{document}
>>> \textipa{RPAQIOE} % This will give you correct phonetic characters
>>> \begin{ipa}
>>> RPAQIOE
>>> \end{ipa}
>>>
>>> RPAQIOE
>>>
>>> \begin{IPA}% So will this!
>>> RPAQIOE
>>> \end{IPA}
>>>
>>> \end{document}
But do *not* try to nest these environments.
If you have macros expanding to use such environments,
then there is no guarantee that these will work properly.
I think they will, since the definitions will have been
made with non-active letters, but have not tested it.
Writing out IPA environments into auxiliary files is
almost certain to *not* work.
But test it, if you need this kind of feature.
> --
> Ulrike Fischer
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross.moore at mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 (0)2 9850 8955
Sydney, Australia 2109 fax: +61 (0)2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list