-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for accented characters (á,é,à,è, etc) in math mode. #555
Comments
It would be great if combining accents worked with this, too, e.g. Note that GitHub's monospace fonts may mangle the above example, so feel free to override the fonts or paste elsewhere for viewing. |
@hpfr That works with a bit of Lua (so using LuaLaTeX): \protected\def\afteracc{\directlua{
local nest = tex.nest[tex.nest.ptr]
local last = nest.tail
if not (last and last.id == 18) then
error'I can only put accents on simple noads.'
end
if last.sub or last.sup then
error'If you want accents on a superscript or subscript, please use braces.'
end
local acc = node.new(21, 1)
acc.nucleus = last.nucleus
last.nucleus = nil
local is_bottom = token.scan_keyword'bot' and 'bot_accent' or 'accent'
acc[is_bottom] = node.new(23)
acc[is_bottom].fam, acc[is_bottom].char = 0, token.scan_int()
nest.head = node.insert_after(node.remove(nest.head, last), nil, acc)
nest.tail = acc
node.flush_node(last)
}}
\AtBeginDocument{
\begingroup
\def\UnicodeMathSymbol#1#2#3#4{%
\ifx#3\mathaccent
\def\mytmpmacro{\afteracc#1 }%
\global\letcharcode#1=\mytmpmacro
\global\mathcode#1="8000
\else\ifx#3\mathbotaccentwide
\def\mytmpmacro{\afteracc bot#1 }%
\global\letcharcode#1=\mytmpmacro
\global\mathcode#1="8000
\fi\fi
}
\input{unicode-math-table}
\endgroup
} |
And I use it extensively for things like Using this |
@ArchangeGabriel You should try https://www.ctan.org/pkg/inputnormalization with Report back if that works for both |
Actually, I just tried it with your snippet and can confirm it works! I'm not too familiar with Lua or LaTeX. Would you be able to describe in prose what the snippet you posted does exactly and where it applies (only math environments?)? I'm trying to determine if this solves the entire issue. Also, what are "simple noads"? If you set a math font that included glyphs for accented characters and combining accents, would this snippet use them or would it still replace with TeX macros? |
I'd like to add a dissenting voice here
Actually I think it is fundamentally wrong to associate the unicode accented letters with the math accents. classical tex had good reason to use separate commands for text and math here and using Unicode input doesn't really change that. The accented letters already work in math now if the font supports them, most math fonts don't but for example
It's not unreasonable to want accented letters (or more generally non-ascii characters) for operator names etc, but these should be taken from a font that supports the characters not by using the math accent mechanism. |
This is a good point. It's desirable for semantics to remain consistent between formats. However, I also like to have a more concise, readable source in my documents. I actually want to represent accent operators as closely as possible with Unicode. It appears \documentclass{article}
\usepackage[stixtwo]{fontsetup} % loads unicode-math
\begin{document}
\(\hat{p}\)
\end{document} already copies as Also, your example acutes only look different because you're using Latin Modern (or equivalent) for the text font. If you use STIX Two Text, the two acutes you demonstrate will be visually indistinguishable (and will copy out the same, although one will be the backwards-compatible This seems to indicate that, on the copyable output side of things, What do you think about this? Personally, I like having Unicode approximations of these mathematical operations and think it's better for the hat to copy out to Unicode. On the input side of things, I think authors mixing using accented letters as symbols or as part of function/operator names with using letters with mathematical operator accents is not advisable because there is no way to distinguish them in the output, so I'm personally in favor of allowing authors to set an option to treat accents in the source as |
Yes it would have to be at best an option, as saying it's not advisable doesn't help in some contexts, eg this spanish example I just borrowed from stackexchange actually I'm not sure which of the options here is actually being used, but just demonstrating the end user requirement to have
|
That's a good example. I'm definitely in favor of it being opt-in. But for the sake of argument, I think the only time when the internal representation of Actually, I think such an option should probably limit itself to non "text math" environments (meaning only math environments where text is interpreted as symbols, so plain math text and |
Description
Being able to type
á
instead of\actue{a}
in math mode.Add info or delete as appropriate:
Example
The text was updated successfully, but these errors were encountered: