unicode-math
unicode-math copied to clipboard
mapstochar displayed as "7"
Hi,
I am using lualatex 0.70.1 and the Asana Math font. When I use for example the \xmapsto command or any other command that uses \mapstochar the vertical bar at the beginning of the arrow is displayed as "7".
Here is a minimal example:
\documentclass{minimal}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\begin{document}
$\mapstochar$
\end{document}
I don't think there is anything similar in Unicode, so \mapstochar itself probably has to stay buggy (or we may choose to undefine it). \xmapsto should be redefined using the LuaTeX primitives:
\RenewDocumentCommand\xmapsto{m}{%
\mathrel{\luatexUoverdelimiter 0 "21A6 {\mkern5mu #1\mkern5mu}}%
}
I believe that a combined \Uunderoverdelimiter is still missing, so \xmapsto[…]{…} can't be replicated that easily. This will definitely go to unicode-math at some point when we have sorted out an extended command table structure. Thanks for the pointer.
Thanks for the info. However the code you provided makes the whole xmapsto arrow is invisible (and xmapsto is the symbol I need). If this is currently (and in the near future) not supported by unicode-math (or Unicode) is there a way to use only the xmapsto symbol from a different font, for example mathpazo (and have it work in a document where unicode math and Asana Math are used)?
However the code you provided makes the whole xmapsto arrow is invisible
Uh, that shouldn't happen, of course. Once again I forgot that we switched from family 4 to 0 only recently. So can you try:
\ExplSyntaxOn
\RenewDocumentCommand \xmapsto { m } {
\mathrel {
\luatexUoverdelimiter \symum_allsym "21A6 {
\mkern 5mu \scan_stop: #1 \mkern 5mu \scan_stop:
}
}
}
\ExplSyntaxOff
is there a way to use only the xmapsto symbol from a different font, for example mathpazo
Yes, but there's no interface for it right now, so you have to do it manually (still not too hard). I'll look at this tomorrow.
Using your new code xmapsto works without problems and looks fine. So there is no need for you to investigate the use of mathpazo for this symbol.
Thank you very much :-)
For the record, here is the promised solution to use mathpazo (effectively Computer Modern) for \xmapsto:
\documentclass{article}
\DeclareSymbolFont{pazosymbols}{OMS}{zplm}{m}{n}
\usepackage{mathtools}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\makeatletter
\ExplSyntaxOn
\DeclareMathSymbol \c_pazo_minus \mathbin { pazosymbols } \c_zero
\DeclareMathSymbol \c_pazo_mapstochar \mathrel { pazosymbols } { "37 }
\DeclareMathSymbol \c_pazo_rightarrow \mathrel { pazosymbols } { "21 }
\cs_new_protected_nopar:Nn \pazo_relbar: {
\mathrel {
\mathpalette \mathsm@sh \c_pazo_minus
}
}
\cs_set_protected_nopar:Nn \MT_mapsto_fill: {
\arrowfill@ { \c_pazo_mapstochar \pazo_relbar: } \pazo_relbar: \c_pazo_rightarrow
}
\ExplSyntaxOff
\makeatother
\begin{document}
$a \xmapsto[bbbb]{cccc} d$
\end{document}
Is there any update on when this won't happen with vanilla unicode-math? I just wasted an hour of my time debugging this, and imagine others have done the same 😄 Thanks for the workaround and the awesome package!
Edit: I'm trying to use the workaround above, but the xmapsto arrow is replaced with the text "21A6. Am I doing something wrong?
./ps05.tex:58: Undefined control sequence.
\xmapsto ... {\luatexUoverdelimiter \symum_allsym
"21A6{\mkern 5mu\scan_stop...
@siddharthist Apologies for the inconvenience — as you can probably tell from the commit history of this package, I haven't found the time to work on it in quite some time. I still hope some time this year to make a major update to address a lot of these issues, but no promises on timing… a fix to Philip's code above would look like this:
\documentclass{article}
\usepackage{unicode-math}
\ExplSyntaxOn
\NewDocumentCommand \xmapsto { m } {
\mathrel {
\exp_after:wN \Uoverdelimiter \cs:w sym \__um_symfont_tl \cs_end: "21A6 {
\mkern 5mu \scan_stop: #1 \mkern 5mu \scan_stop:
}
}
}
\ExplSyntaxOff
\begin{document}
\[ \xmapsto{f} \]
\end{document}
(Not sure why this issue was closed last year — I've re-opened to implement something to add something like one of the fixes above.)
You don't need \exp_after:wN
\NewDocumentCommand \xmapsto { m }
{
\mathrel
{
\Uoverdelimiter \use:c { sym \__um_symfont_tl } "21A6
{
\mkern 5mu \scan_stop: #1 \mkern 5mu \scan_stop:
}
}
}
A fix for XeLaTeX is missing, though.
Oops, old habits :)
\use:c { sym \__um_symfont_tl } gives an undefined command error with a current unicode-math,
@u-fischer Thanks Ulrike — I've been trying to improve my variable names and this one was particularly bad :) Code should now be:
\NewDocumentCommand \xmapsto { m }
{
\mathrel
{
\Uoverdelimiter \use:c { sym \l__um_symfont_label_tl } "21A6
{
\mkern 5mu \scan_stop: #1 \mkern 5mu \scan_stop:
}
}
}
I've kept this issue open to figure out a way to fix it properly, but haven't had much time to put my thinking cap on.
Well I guess some other package shouldn't use \l__um_symfont_label_tl either but probably \symoperators. Or is there some other "public" unicode-math command?
Regarding a xetex fix: As luatex has sensible primitives now it is perhaps the right time to make a proper feature request regarding extensible arrows. (see also http://tug.org/pipermail/xetex/2016-February/thread.html#26395).
The problem is that \l__um_symfont_label_tl is somewhat extensible, in that yes by default it is just "operators" but if a second maths font is loaded for a different range it gets set to some internal string for that font.
I should take a leaf from the fontspec NFSS approach here and just make the string settable, so you could write
\setmathfont{foo} \setmathfont{bar}[range={...},symlabel=myrangefont]
which would define \symmyrangefont for use in this context.
(Although I'd rather steer people away from the csname \sym.. in this context because I overloaded \sym.. for the different ranges too! So maybe provide a set of new math macros to select symbols from a particular font.)
I'm not sure that key is needed. Only a \get_um_XXXXXl: function or a \um_XXXX variable that package writers can use and so don't have to misuse the internal \l__um_symfont_label_tl .