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

\copyright, \textregistered, \textcircled support #1073

Merged
merged 3 commits into from
May 8, 2018

Conversation

edemaine
Copy link
Member

This seems to work at regular size and \small, but not e.g. in subscript. Suggestions welcome.

Based on discussions with @kevinbarabash in KaTeX/katex-fonts#9

@kevinbarabash
Copy link
Member

@edemaine can you post what it looks like for \textstyle and \scriptstyle? Is it just the subscript that looks wrong, or is it also wrong in superscript?

@edemaine
Copy link
Member Author

edemaine commented Jan 18, 2018

Here's the current state for http://localhost:7936/?text=%5Cbegin%7Bmatrix%7D%0A%5Ccopyright%5Csmall%5Ccopyright%5Cfootnotesize%5Ccopyright%5Ctiny%5Ccopyright%5C%5C%0A%5Ccopyright_%7B%5Ccopyright_%7B%5Ccopyright%7D%7D%0A%5Cend%7Bmatrix%7D%0A :

image

It looks like \llap is resetting the font to normalsize. This seems to be a bug in \llap, because LaTeX doesn't work that way. Er, it's more complicated than that... \small doesn't actually affect math font size in LaTeX, but does affect the text in \llap, while \llap does include the normal/script/scriptscriptstyle:

image

$$
\begin{matrix}
x\rlap{x} & \small x\rlap{x} & \footnotesize x\rlap{x} & \tiny x\rlap{x} \\
x\rlap{x} & \scriptstyle x\rlap{x} & \scriptscriptstyle x\rlap{x} \\
x\rlap{x} & _{x\rlap{x}} & _{_{x\rlap{x}}} \\
\end{matrix}
$$

Here's KaTeX's rendering: (sorry, I'm on Windows right now, so fonts aren't loading)

image

Incidentally, LaTeX does some weird stuff with resized copyrights. Here's the first example:

image

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.

Not sure the best way to deal with the font size issues. Finding an appropriate glyph for the \copyright symbol might be easier in the short term. Another option might be to implement \mathchoice and then tweak the definition for each style.

@codecov
Copy link

codecov bot commented May 3, 2018

Codecov Report

Merging #1073 into master will decrease coverage by 0.03%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1073      +/-   ##
=========================================
- Coverage   83.83%   83.8%   -0.04%     
=========================================
  Files          61      61              
  Lines        3971    3982      +11     
  Branches      659     662       +3     
=========================================
+ Hits         3329    3337       +8     
- Misses        543     546       +3     
  Partials       99      99
Impacted Files Coverage Δ
src/macros.js 84.81% <100%> (+0.29%) ⬆️
src/symbols.js 100% <100%> (ø) ⬆️
src/functions/accent.js 90.16% <70%> (-4.29%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f01f504...facd231. Read the comment docs.

@edemaine
Copy link
Member Author

edemaine commented May 3, 2018

I revisited this, implementing an actual \textcircled command as an accent, like in LaTeX. This accent seems to behave differently from all other accents in that its width contributes to the width of the final symbol (cf. #1033), and it is never offset vertically. I'm not sure what triggers this in (La)TeX, but I'm calling this a "full" accent barring a better name. \copyright behaves very well now, as does \textregistered:

\copyright_{\copyright_{\copyright}} \small \copyright \tiny \copyright

image

This should be good to go, unless someone knows better terminology for this type of accent. Oh, also need to add tests.

@edemaine edemaine changed the title \copyright support \copyright, \textregistered, \textcircled support May 3, 2018
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.

LGTM. Thanks for seeing this through.

defineMacro("\\textcopyright", "\\textcircled{c}");
defineMacro("\\copyright",
"\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");
defineMacro("\\textregistered", "\\textcircled{\\scriptsize R}");
Copy link
Member

Choose a reason for hiding this comment

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

yay for macros

width: 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

I wish we store more props directly on the domTree nodes we create so that we don't have all of this extra data hanging out in this file. No action required.

@@ -684,6 +684,7 @@ defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis
defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute
defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph
Copy link
Member

Choose a reason for hiding this comment

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

I see, this is just an alias.

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.

2 participants