Improve text in math
See original GitHub issueDescription
When writing about math, it is not uncommon to need to add some text. For example, “When x<0, x^{2n+1} <0”. mathlive has a \text
command to indicate text, but in the editor, this is a very clumsy way of adding text.
For working out a solution to a problem, being able to easily mix text and math is very common. For students, being able to do this in a manner that isn’t distracting or hard to figure out is very important.
Suggestion
[based on discussions between @NSoiffer and @arnog]
mathlive should auto detect when something is math and something is text and automatically create the \text
. Some ideas of triggers
- math operators such as
+
and=
indicate that the operands should be math - runs of characters (especially ones that form words that aren’t known functions) are indications of text
- spaces and punctuation are potential switch points (space is also used to move out of superscripts, etc., so how do we know to insert a space versus move somewhere?)
- space could be considered an operator that means either “implied times” or “text space” and it’s meaning is determined by it’s operands. Because you don’t know the right operand fully during typing, it’s meaning may change as more characters are typed. Another example would be typing the sequence
i
,if
,if
, where the interpretation is sqrt(-1), sqrt(-1) times f, "if " (i.e, text). - text is more likely in some places (e.g, on the baseline) than in others (e.g, in a superscript).
- shortcuts interact with interpreting text (“something” should include the shortcut for “in”)
Intermediate Solution
I think auto detection is hard. An intermediate solution and/or forcing text solution would make "
as in in "this is text"
force text mode. "
s would always show up in pairs. When the insertion cursor is moved outside of a quote, they disapear. Clicking in the text would make them reappear.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
This would be nice, I think. A quick search showed that a regex for Asian characters exists (probably).
I will try to use
onModeChange
+onKeystroke
+mf.perform(['switchMode', 'text'])
again and see if I can find a workaround.No, we probably would not need to mix Greek and English.
The exceptions are:
ο η ή το τα θα να αν ας οι τι με μη σε μα γη ως δε εξ κι
plus their corresponding capital letter words.WhenI implemented smart mode I thought about Greek (and other non-roman scripts) but I wasn’t sure there was a use case for it. If you are a Greek user and believe it would be useful I’ll look at it. Like Neil said, that’s a tricky area so I’ll need to think it through to make sure it doesn’t break anything. Two questions 1/ would you want to mix Greek and English (i.e. have some words in Greek and some in Roman script?) 2/ Any other exceptions other than alpha/beta/gamma? Are there any common single letter Greek word that should be accounted for?