Using Fractions On Websites

前端 未结 5 765
时光取名叫无心
时光取名叫无心 2020-12-12 07:15

Is it possible to use any fraction symbol on a website, represented as ¼ rather than 1/4 for example?

From what I\'ve gathered, these are the only

相关标签:
5条回答
  • 2020-12-12 07:34

    As I undserstand HTML5 includes MathML which can represent any fraction you want.

    While searching the unicode table I also found these: ⅑ ⅒ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞.

    0 讨论(0)
  • 2020-12-12 07:35

    There are several possibilities:

    • Use special character for fractions. Not possible for 2/4 for example, and problematic in font support for all but the three most common (vulgar) fractions you had found.
    • Use markup like <sub>2</sub>/<sup>4</sup>. Probably messes up your line spacing, and does not look particularly good.
    • Construct a fraction using some CSS for positioning and size control and using fraction slash character instead of the common slash. Rather awkward really, I would say.
    • Use OpenType <code>"frac"</code> feature. Rather limited support in browsers and especially in fonts.
    • MathJax, e.g. \(\frac{2}{4}\) or some more elaborated TeX code to produce a different style for fraction.
    • MathML. Verbose, and browser support to MathML inside HTML could be better.

    These are explained more and illustrated in my page “Math in HTML (and CSS)”, section Fractions.

    The choice thus depends on many factors. It also depends on the font quite a lot. I suggest that you test the different options using the font family declaration you intend to use. Despite the many alternatives, you might end up with using just the simple linear notation like 2/4.

    0 讨论(0)
  • 2020-12-12 07:39

    The image below displays all unicode-defined fraction symbols. Each of them is treated as one single character. You can use all of them freely, of course, but if you want more, e.g. 123/321, then you should look out for a library that can create fractions dynamically.

    An option for doing so would be using LaTeX. There is another question (with very good answers) on how to do this.

    enter image description here

    Image from http://symbolcodes.tlt.psu.edu/bylanguage/mathchart.html#fractions

    0 讨论(0)
  • 2020-12-12 07:46

    You can test http://www.mathjax.org/ it is a JavasScript library to make a Math Formula if this is what you want.

    0 讨论(0)
  • 2020-12-12 07:52

    A web page is built up with text, and that text is encoded in a certain character set. The character set you select decides on which characters can be displayed. This also means that characters or symbols that don't exist in the character set cannot be displayed.

    As shown in Michael's answer, Unicode defines symbols for a number of fractions. These can be displayed without using all kinds of tricks, for example server or client side generated small bitmaps showing the desired fraction, or as indicated by mohammad mohsenipur a Javascript library that transforms TeX or MathML.

    0 讨论(0)
提交回复
热议问题