[XeTeX] xunicode's textipa command

Andy Lin kiryen at gmail.com
Mon Nov 9 02:03:24 CET 2009


On Sun, Nov 8, 2009 at 13:55, Ross Moore <ross at ics.mq.edu.au> wrote:
> Hello Andy,
>
> On 08/11/2009, at 3:02 PM, Andy Lin wrote:
>
>> Hi Ross,
>>
>> On Sat, Nov 7, 2009 at 00:14, Ross Moore <ross at ics.mq.edu.au> wrote:
>>>
>>> Hello Andy,
>>>
>>> On 07/11/2009, at 4:17 AM, Andy Lin wrote:
>>>
>>>> I'm currently using linguex to typeset examples, and I've noticed that
>>>> \textipa is broken within the \ex. command/environment. Upon further
>>>> investigation, it seems that even \newcommand\ipa[1]{\textipa{#1}}
>>>> breaks \textipa (although \let\ipa\textipa, as mentioned in the tipa
>>>> manual, is fine). I'm not sure what the problem is exactly, if it has
>>>> to do with xunicode setting capital letters as active in its textipa
>>>> implementation or something else,
>
> Yes, this is indeed related to the problem, ...
>
>> The tipa text commands that are redefined in xunicode (e.g.
>> \textturna) work great, but it's the \textipa command which is a
>> little bit problematic, since xunicode's implementation of it involves
>> turning A-Z, 0-9, and ;:| and @ into active characters. It works fine
>> in standard paragraph mode, but it seems to break inside certain
>> environments and doesn't seem to allow its inclusion in \newcommands.
>
>  ... since the  \ex  command reads to the next (implicit) \par
> before doing its work.
>
> This means that the \catcode of any character within its argument
> is frozen with the standard meaning, before \textipa  has the
> chance to setup the meanings that you want them to have.
>
> However, with the modern eTeX extensions to TeX, you can overcome
> this kind of difficulty:
>
>  \newcommand\ipa[1]{\textipa{\scantokens{#1}}}

Ah, I had no idea that was how \ex. operated. I thought it merely set
\par to be active to serve as an end-environment.

>
>
>
>>>> though the solution proposed there was to simply input the unicode
>>>> equivalents of the IPA characters (which would break compatibility
>>>> with non-unicode LaTeX), or to come up with a TECkit mapping for the
>>>> IPA characters (which I'm willing to do, but only if there are no
>>>> other options).
>>>
>>> The TECkit mapping approach is interesting, but is really only
>>> applicable if you are using non-active characters, rather than
>>> macros, to specify the font characters.
>>>
>> I ended up making a TECkit mapping soon after I posted the message
>> when I realized that the \textipa command was only responsible for
>> remapping 40 glyphs. I've attached the map and tec files. I've changed
>> the glyph mapping for G and U, these are lowercase glyphs in tipa but
>> xunicode maps them to uppercase.
>
> Please explain this in detail, with examples.
> Aaaah, you file  xetex-tipa.map  does this.
>
> The differences seem to be:
>
> ;B > U+03B2;\textbeta  name taken for the greek letter
> G > U+0263;\textgamma
> ;G > U+0264;\textbabygamma
> ;U > U+01B1;\textupsilon
> U > U+028A;\textscupsilon
> ;Z > U+021D;\textyogh
> ;" > U+02B9;\textprimstress (looks like math prime)
>
>
> Would it be sufficient to make the expansion of ; (active)
> to check the next token and produce the appropriate
> characters for ;B  ;G  ;U  ;Z  ;"  else \texthalflength  ?
>
> If this is all that is needed, I'll adjust the  xunicode.sty
> coding to implement this.
>
I actually took the lines ( e.g. ;B > U+03B2;\textbeta...) straight
from the xunicode.sty file, including some lines that were commented
out with % in the sty file (which I've commented out with ; in the map
file), the only modifications I've made are to G and U (the tipa
manual shows these as tall as the x-height); B, Z, and ; have the same
alternate definitions within xunicode.sty.

>
>> I was reluctant to use this solution because it's an additional file
>> that people have to install in order to have linguex, tipa, and XeTeX
>> play together nicely.
>
> Send a real-world example (with a PDF of what the output
> should look like) so I can be sure I'm doing the right thing.
I've attached a tex and pdf file.

>
>> (I'm running a LaTeX tutorial in a couple of
>> weeks with people who are used to Word, and the less I ask them to dig
>> around their texmf trees the better.) However, the \textipa command
>> was written to map normal, non-active, basic latin characters to IPA
>> glyphs so it seems that a TECkit mapping is the appropriate solution
>> here.
>>
>>>> Has anyone run into this problem before? Can it be solved by some
>>>> combination of \protect, \expandafter, etc.?
>
>  The primitive you want to use is  \scantokens .
>  This allows the \catcode to be altered for otherwise frozen
>  characters.
>
>
>>> Can you provide an example (La)TeX document that displays
>>> some of the difficulties that you are facing.
>>>
>> \documentclass{article}
>> \usepackage{xltxtra}
>> \setmainfont{Cambria}
>> \usepackage{linguex}
>>
>> %\AtBeginDocument{\def\textipa#1{{\addfontfeatures{Mapping=xetex-textipa}#1}}}
>> %This is the solution that I'm using now, having made the xetex-textipa
>> map
>> \begin{document}
>> \textipa{ABCabc} % This text renders as it should (script a, s-z,
>> curly tail c, abc)
>>
>> \ex. \textipa{ABCabc} % This text renders as ABCabc
>
>  \ex. \ipa{ABCabc} % This now works properly.
>
>>
>> \end{document}
>
>> Sincerely,
>> Andy Lin
>
>
> Hope this helps,
>
>        Ross
>
> ------------------------------------------------------------------------
> Ross Moore                                       ross at maths.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
> ------------------------------------------------------------------------
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XuniTipa.tex
Type: application/x-tex
Size: 624 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20091108/d9b7a9a1/attachment-0001.tex>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XuniTipa.pdf
Type: application/pdf
Size: 14923 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20091108/d9b7a9a1/attachment-0001.pdf>


More information about the XeTeX mailing list