question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve text in math

See original GitHub issue

Description

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:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
panoschalcommented, Jun 28, 2019

1. The regular expressions that check for a letter could be made configurable so that in your case or the case of someone using a different alphabet could provide a regular expression to match their alphabet. I don’t know enough about Asian languages (and others) that are character-based as opposed to alphabetic to know whether that is a help to them.

This would be nice, I think. A quick search showed that a regex for Asian characters exists (probably).

2. There is a callback onModeChange – maybe it can be used in your case to “repair” a problem. However, if you are looking for something to switch to textmode and it doesn’t switch, that function won’t help.

I will try to use onModeChange + onKeystroke + mf.perform(['switchMode', 'text']) again and see if I can find a workaround.

1/ would you want to mix Greek and English (i.e. have some words in Greek and some in Roman script?)

No, we probably would not need to mix Greek and English.

2/ Any other exceptions other than alpha/beta/gamma? Are there any common single letter Greek word that should be accounted for?

The exceptions are:

  • “αβγ” like I said before, and two letter combinations, I guess, that would be meant as math.
  • One or two letter words are in this space separated list ο η ή το τα θα να αν ας οι τι με μη σε μα γη ως δε εξ κι plus their corresponding capital letter words.
  • Also there is π that currently switches to math mode automatically when pressed, but could be part of a word as well.
0reactions
arnogcommented, Jun 28, 2019

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

font size in math mode - TeX - LaTeX Stack Exchange
Using \text{\tiny{locations}} does make it a bit smaller. ... One easy way I found to make math font smaller is to wrap a...
Read more >
Create math equations using ink or text with Math Assistant in ...
Learn how to create math equations by drawing or typing an equation, then using Math Assistant.
Read more >
How do I make my writing and math accessible?
Just as there are ways to format text to make it more accessible, there are also considerations for how to write text to...
Read more >
Display style in math mode - Overleaf, Online LaTeX Editor
Introduction. This article explains how to manually adjust the style of typeset mathematics—but we'll start with a quick reminder of the visible differences ......
Read more >
Q. How do I change the font in equations and fractions in ...
For 2020 Word, select the text and then go to "Equation" and select "ab Text" on upper left. Now you can go back...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found