Template:Frac: Difference between revisions
Jump to navigation
Jump to search
DroneBetter (talk | contribs) Create (maybe I will make another template with nicer nesting behaviour later, however it will require the entire expression to have enclosing <span>s) |
DroneBetter (talk | contribs) m Continued fractions are fixed and it is nicer now (no enclosings necessary :-) |
||
| Line 1: | Line 1: | ||
<includeonly><span style="padding: 0 0.5ch; display: inline-block; text-align: center; vertical-align: middle;"><span>{{{num|{{{1|p}}}}}}</span><span style="display: block; margin: 0 -0.5ch; border-top: 1px solid currentcolor;"></span><span>{{{ | <includeonly><span style="padding: 0 0.5ch; display: inline-grid; grid-template: 'a n' auto 'a x' auto '- q' auto / auto auto; text-align: center;"><span style="grid-area: a; height: 0; align-self: end; margin-bottom: -0.5ch;""></span><span style="grid-area: n;">{{{num|{{{1|p}}}}}}</span><span style="grid-area: q;">{{{den|{{{2|q}}}}}}</span><span style="grid-area: x; margin: 0 -0.5ch; border-top: 1px solid currentcolor; justify-self: stretch;"></span></span><!--old version (not working with alignment correctly) | ||
<span style="padding: 0 0.5ch; display: inline-block; text-align: center; vertical-align: middle;"><span>{{{num|{{{1|p}}}}}}</span><span style="display: block; margin: 0 -0.5ch; border-top: 1px solid currentcolor;"></span><span>{{{den|{{{2|q}}}}}}</span></span>--></includeonly><noinclude><tt><nowiki>{{</nowiki>'''frac'''<nowiki>}}</nowiki></tt> is a template for expressing fractions with vertically-displaced numerators and denominators. The parameters, <tt>num</tt> and <tt>den</tt>, may have their namees forgone, and default to the first and second inputs, as one would expect. | |||
For instance, <tt><nowiki><tt>{{frac|-(b:{{=}}{{frac|b|2}})-sqrt(b<sup>2</sup>-a*c)|a}}</tt></nowiki></tt> becomes <tt>{{frac|-(b:{{=}}{{frac|b|2}})-sqrt(b<sup>2</sup>-a*c)|a}}</tt>. | For instance, <tt><nowiki><tt>{{frac|-(b:{{=}}{{frac|b|2}})-sqrt(b<sup>2</sup>-a*c)|a}}</tt></nowiki></tt> becomes <tt>{{frac|-(b:{{=}}{{frac|b|2}})-sqrt(b<sup>2</sup>-a*c)|a}}</tt>. | ||
Revision as of 22:42, 23 August 2023
{{frac}} is a template for expressing fractions with vertically-displaced numerators and denominators. The parameters, num and den, may have their namees forgone, and default to the first and second inputs, as one would expect.
For instance, <tt>{{frac|-(b:{{=}}{{frac|b|2}})-sqrt(b<sup>2</sup>-a*c)|a}}</tt> becomes -(b:=b2)-sqrt(b2-a*c)a.
Be warned, the rest of the text aligns with the average y position (between a fraction's numerator's top and numerator's bottom), not the line of separation, so continued (and otherwise nested) fractions are less elegant with this.
- φ=1+11+11+11+...