Skip to content
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 <, >, | and many \text... commands in text mode #684

Merged
merged 1 commit into from
May 17, 2017

Conversation

edemaine
Copy link
Member

This started as a fix to #662, which reported lack of < and > support in text mode. As suggested, I mapped them to regular < and > characters as if \usepackage[T1]{fontenc} is in effect. This seems like the preferred behavior (unless you're typing in Spanish or another language that uses upside-down symbols... but then perhaps better to use Unicode symbols).

I also noticed that | wasn't working in text mode, but was supposed to, so I added that. These are one-line changes.

I then implemented \textless, \textgreater, \textbar as aliases to these symbols.

I then started going through this symbol list to see what other characters were missing. I added support for \textdollar, \textunderscore, \textbraceleft, \textbraceright, \textbardbl, \textendash, \textemdash, \textquote(dbl)(left/right) as aliases to existing symbols. I didn't attempt to add the other text symbols, though that might be good for a future project...

@kevinbarabash
Copy link
Member

@edemaine I'm confused about \textdollar and the other \text___ aliases. Won't \text{\textdollar} output \textdollar instead of $?

@edemaine
Copy link
Member Author

defineSymbol(text, main, textord, "$", "\\textdollar"); defines \textdollar to output the symbol $ in the main font with type textord. To confirm, here's a screenshot of the local server tester:

textdollar

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are couple more alias that could be added:

  • \textsterling (alias of \pounds)
  • \textregistered (alias of \circledR)

src/symbols.js Outdated
defineSymbol(math, main, textord, "\u2021", "\\ddag");
defineSymbol(text, main, textord, "\u2021", "\\ddag");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may as well add \textdagger and \textdaggerdbl as well.

@edemaine
Copy link
Member Author

Added. Also noticed that \circledR, \checkmark, \pounds work in text mode too, so added those. And I'm fairly certain \pounds is a textord not mathord. \pounds\text{\textsterling\pounds} now produces 3 identical symbols.

@kevinbarabash
Copy link
Member

@edemaine it looks like the change to \pounds change the symbols screenshot test. Can you verify that \pounds is indeed a textord in math mode? If it, please update the screenshot for the symbols test.

@edemaine
Copy link
Member Author

edemaine commented May 1, 2017

Indeed, $\pounds$ generates a mathord, same as $\mathsterling$ (another alias I added). $\text{\pounds}$ generates a textord (I believe -- at least, the LaTeX output of the symbol is different from the math version), but our font doesn't have that symbol, so I've left it generating a mathord.

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in this. Requesting a TODO be added and then this will be ready to merge.

src/symbols.js Outdated
defineSymbol(math, main, textord, "\u00b0", "\\degree");
defineSymbol(text, main, textord, "\u00b0", "\\degree");
defineSymbol(math, main, mathord, "\u00a3", "\\pounds");
defineSymbol(math, main, mathord, "\u00a3", "\\mathsterling");
defineSymbol(text, main, mathord, "\u00a3", "\\pounds");
defineSymbol(text, main, mathord, "\u00a3", "\\textsterling");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mentioned that $\text{\pounds}$ generates a textord, should \text{\textsterling} do the same? Can you add a TODO so that people aren't confused by the use of mathords in text mode later on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Although I found this discussion where @xymostech suggests that maybe we should move away from mathord vs. textord, and rather just specify which font to use. It seems LaTeX has a notion of "mathord" but no notion of "textord" (at least I've never seen one in debugging output)?

@edemaine
Copy link
Member Author

edemaine commented May 16, 2017

Should be good to go now. Someday, a more thorough symbol review wouldn't hurt, but this should help!

(Also rebased.)

Add long-form aliases for various text symbols

* \textgreater is an alias for > in text mode
* \textless is an alias for < in text mode
* \textbar is an alias for | in text mode
* \textdollar is an alias for \$ in text mode
* \textunderscore is an alias for \_ in text mode
* \textbraceleft is an alias for \{ in text mode
* \textbraceright is an alias for \} in text mode
* \textless is an alias for < in text mode
* \textgreater is an alias for > in text mode
* \textbar is an alias for | in text mode
* \textbardbl is an alias for \| in text mode
* \textendash is an alias for -- in text mode
* \textemdash is an alias for --- in text mode
* \textquoteleft is an alias for ` in text mode
* \textquoteright is an alias for ' in text mode
* \textquotedblleft is an alias for `` in text mode
* \textquotedblright is an alias for '' in text mode
* \textdagger is an alias for \dag in text mode
* \textdaggerdbl is an alias for \ddag in text mode
* \textsterling is an alias for \pounds in text mode
* \dag, \ddag work in text mode
* \circledR, \checkmark, \pounds work in text mode too
* Extend Symbols1 test to test \pounds and \textdollar in \text
* Add note about \pounds in text vs. math mode
@kevinbarabash
Copy link
Member

LGTM. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants