wikipedia>Edokter
Xeverything11 (talk | contribs)
m 133 revisions imported: Import from SkyWiki
 
(67 intermediate revisions by 36 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!--PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE-->
{{Uses TemplateStyles|Template:Fraction/styles.css}}
This template builds an alternative form of [[common fraction]]s. The template takes one, two, or three parameters: the optional integer (may be signed), the optional numerator and the required denominator; in this order.  
This template builds an alternative form of common fractions. The template takes one, two, or three parameters: the optional integer (may be signed), the optional numerator and the required denominator; in this order.  


Please '''do not''' <code>subst:</code>itute it. This template should '''not''' be used in science or mathematical articles, per [[MOS:FRAC]] and [[MOS:MATH#Fractions]]; use {{tl|sfrac}} instead. To allow numerical sorting of a column containing fractions, use {{tl|sortfrac}} instead. It is a combination of this template and {{tl|sort}}.
Please '''do not''' <code>subst:</code>itute it.
;<code><nowiki>{{frac|A|B|C}}</nowiki></code>: {{frac|A|B|C}} (integer, numerator and denominator)
:<source lang=html5><span class="frac">A<sup>&nbsp;B</sup>⁄<sub>C</sub></span></source>
;<code><nowiki>{{frac|A|B}}</nowiki></code>: {{frac|A|B}} (numerator and denominator)
:<source lang=html5><span class="frac"><sup>A</sup>⁄<sub>B</sub></span></source>
;<code><nowiki>{{frac|A}}</nowiki></code>: {{frac|A}} (denominator only)
:<source lang=html5><span class="frac"><sup>1</sup>⁄<sub>A</sub></span></source>
;<code><nowiki>{{frac}}</nowiki></code>: {{frac}} (fraction slash only)
:<source lang=html5><span class="frac">⁄</span></source>


==Examples==
; <code><nowiki>{{fraction|A|B|C}}</nowiki></code> : {{fraction|A|B|C}} (integer, numerator and denominator)
;Numbers: {{frac|2}} {{frac|3}} {{frac|2|3}} {{frac|4}} {{frac|3|4}} {{frac|5}} {{frac|2|5}} {{frac|3|5}} {{frac|4|5}} {{frac|6}} {{frac|5|6}} {{frac|7}} {{frac|2|7}} {{frac|3|7}} {{frac|4|7}} {{frac|5|7}} {{frac|6|7}} {{frac|8}} {{frac|3|8}} {{frac|5|8}} {{frac|7|8}} {{frac|16}} {{frac|3|16}} {{frac|5|16}} {{frac|7|16}} {{frac|9|16}} {{frac|11|16}} {{frac|13|16}} {{frac|15|16}}
; <code><nowiki>{{fraction|B|C}}</nowiki></code> : {{fraction|B|C}} (numerator and denominator)
;Units: {{frac|m|s}} {{frac|km|h}} {{frac|kg·m|s²}} {{frac|s}} {{frac|Mbit|s}}
; <code><nowiki>{{fraction|C}}</nowiki></code> : {{fraction|C}} (denominator only)
; <code><nowiki>{{fraction}}</nowiki></code> : {{fraction}} (fraction slash only)


==Deactivation and customization==
== Examples ==
Users who prefer to see fractions inline, e.g. „1&nbsp;2⁄3“ instead of „{{frac|1|2|3}}“, can turn off the effects of this template by adding the following code to [[Help:User style|their user stylesheet]]:
<!--the fractions are separated by commas that are only visible to screen readers because they do not read out the space separators here-->
<source lang="css">.frac>sup /* numerator */,
; Numbers : {{fraction|2}} {{fraction|3}} {{fraction|2|3}} {{fraction|4}} {{fraction|3|4}} {{fraction|5}} {{fraction|2|5}} {{fraction|3|5}} {{fraction|4|5}} {{fraction|6}} {{fraction|5|6}} {{fraction|7}} {{fraction|2|7}} {{fraction|3|7}} {{fraction|4|7}} {{fraction|5|7}} {{fraction|6|7}} {{fraction|8}} {{fraction|3|8}} {{fraction|5|8}} {{fraction|7|8}} {{fraction|16}} {{fraction|3|16}} {{fraction|5|16}} {{fraction|7|16}} {{fraction|9|16}} {{fraction|11|16}} {{fraction|13|16}} {{fraction|15|16}}
.frac>sub /* denominator */
; Units : {{fraction|m|s}} {{fraction|km|h}} {{fraction|kg·m|s<sup>2</sup>}} {{fraction|s}} {{fraction|Mbit|s}}
{
 
  vertical-align: inherit /* or baseline */;
== Notes ==
  font-size: inherit /* or 1em */;
* <code><nowiki>{{fraction}}</nowiki></code> or <code>&amp;frasl;</code> may be used to print out the fraction slash glyph " &frasl; ".
  line-height: inherit /* or 1 */;
* For mixed fractions, in some contexts (like link targets) a "+" is generated between the whole number part and fraction part. If this is not desirable, put the whole number part outside the template, and put a [[w:non-breaking space|non-breaking space]] between when the spacing is desirable. For example: "<nowiki>33&amp;nbsp;{{frac|1|3}}</nowiki>".
  position: inherit /* or static */;
}</source><!--untested-->
<!-- The following would work if the fraction slash was enclosed in a <code>span</code>
These selectors and properties can also be used as a base for custom rendering of vulgar fractions:
<source lang="css">/* Stacked Fractions */
.frac {
  display: inline-block;
  vertical-align: -0.6em;
  font-size: 85%;
  text-align: center;
}
.frac > span /* fraction slash */ {
  display: none;
}


.frac > sup /* numerator */,
== Parameters ==
.frac > sub /* denominator */ {
<templatedata>{
   vertical-align: baseline;
"description": "A template for displaying common fractions of the form int+num/den nicely. It supports 0–3 anonymous parameters with positional meaning.",
   line-height: 1.2em;
"params": {
   font-size: 1em;
"1": {
   position: static;
   "label": "leftmost part",
   display: block;
   "description": "Denominator if only parameter supplied. Numerator if 2 parameters supplied. Integer if 3 parameters supplied. If no parameter is specified the template will render a fraction slash only.",
   padding: 0 0.1em;
   "type": "string/line",
}
   "required": false
.frac > sub {
},
   border-top: 1px solid;
"2": {
   "label": "middle-right part",
   "description": "Denominator if 2 parameters supplied. Numerator if 3 parameters supplied.",
  "inherits": "1"
},
"3": {
  "label": "rightmost part",
  "description": "Denominator, always.",
   "inherits": "1"
}
}
}}</templatedata>


</source>-->
== See also ==
 
* {{tl|sfrac}} ({{sfrac|2}}) displays common fractions using a [[w:vinculum (symbol)|vinculum]] (horizontal line), for scientific and mathematical text
== Code ==
 
<source lang=html5>
<span class="frac nowrap">{{#if:{{{3|}}}
|{{{1}}}<sup>&#32;{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
|{{#if:{{{2|}}}
  |<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
  |{{#if:{{{1|}}}
  |<sup>1</sup>&frasl;<sub>{{{1}}}</sub>
  |&frasl;
  }}
}}
}}</span>
</source>
 
==Notes==
*<code>&amp;frasl;</code> may be used to print out the fraction glyph " &frasl; "
 
==See also==
*{{tl|1/2}} ({{1/2}}), {{tl|1/3}}, {{tl|2/3}}, {{tl|1/4}}, {{tl|3/4}}, shorthands
*{{tl|fraction}} ({{fraction|2}}), only uses precomposed glyphs, which usually is not preferred due to accessibility concerns
*{{tl|sfrac}} ({{sfrac|2}}), displays common fractions using a [[vinculum (symbol)|vinculum]], which is preferable for scientific and mathematical articles.


<includeonly>
<includeonly>
<!--CATEGORIES AND INTERWIKIS HERE, THANKS-->
[[Category:Formatting templates]]
[[Category:Wikipedia formatting and function templates|{{PAGENAME}}]]
[[Category:Mathematical formatting templates|{{PAGENAME}}]]
 
[[af:Sjabloon:Breuk]]
[[ar:قالب:Frac]]
[[as:সাঁচ:Fraction]]
[[az:Şablon:Frac]]
[[bar:Vorlage:Bruch]]
[[bn:টেমপ্লেট:Frac]]
[[ca:Plantilla:Frac]]
[[cs:Šablona:Zlomek]]
[[da:Skabelon:Brøk]]
[[diq:Şablon:Frac]]
[[de:Vorlage:Bruch]]
[[el:Πρότυπο:Frac]]
[[et:Mall:Murd]]
[[es:Plantilla:Fracción]]
[[fa:الگو:تقسیم]]
[[fi:Malline:Murtoluku]]
[[fr:Modèle:Fraction]]
[[frr:Vorlage:Bruch]]
[[gan:Template:Frac]]
[[hi:साँचा:Frac]]
[[hy:Կաղապար:Frac]]
[[id:Templat:Frac]]
[[ja:Template:分数]]
[[jv:Cithakan:Frac]]
[[ko:틀:분수]]
[[is:Snið:Brot]]
[[lt:Šablonas:Frac]]
[[lv:Veidne:Frac]]
[[mg:Endrika:Ampaha]]
[[mk:Шаблон:Дроп]]
[[ml:ഫലകം:Frac/വിവരണം]]
[[mr:साचा:Frac]]
[[ms:Templat:Frac]]
[[ne:ढाँचा:Frac]]
[[nl:Sjabloon:Breuk]]
[[nn:Mal:Brøk]]
[[no:Mal:Brøk]]
[[oc:Modèl:Fraccion]]
[[or:ଛାଞ୍ଚ:Frac]]
[[os:Шаблон:Лыст]]
[[pl:Szablon:U]]
[[pt:Predefinição:Frac]]
[[qu:Plantilla:Frac]]
[[ro:Format:Fracție]]
[[ru:Шаблон:Дробь]]
[[simple:Template:Frac]]
[[sl:Predloga:Ulomek]]
[[sq:Stampa:Frac]]
[[su:Citakan:Frac]]
[[sv:Mall:Frac]]
[[ta:வார்ப்புரு:Fraction]]
[[te:మూస:Frac]]
[[tr:Şablon:Frac]]
[[uk:Шаблон:Дріб]]
[[zh:Template:Fraction]]
[[zh-yue:Template:分數]]
</includeonly>
</includeonly>

Latest revision as of 06:24, 29 April 2025

Template:Documentation subpage Template:Uses TemplateStyles This template builds an alternative form of common fractions. The template takes one, two, or three parameters: the optional integer (may be signed), the optional numerator and the required denominator; in this order.

Please do not subst:itute it.

{{fraction|A|B|C}}
Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").A+BC (integer, numerator and denominator)
{{fraction|B|C}}
Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").BC (numerator and denominator)
{{fraction|C}}
Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").1C (denominator only)
{{fraction}}
Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text"). (fraction slash only)

Examples[edit source]

Numbers
Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").12 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").13 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").23 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").14 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").34 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").15 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").25 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").35 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").45 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").16 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").56 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").17 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").27 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").37 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").47 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").57 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").67 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").18 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").38 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").58 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").78 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").116 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").316 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").516 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").716 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").916 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").1116 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").1316 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").1516
Units
Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").ms Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").kmh Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").kg·ms2 Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").1s Page Template:Fraction/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").Mbits

Notes[edit source]

  • {{fraction}} or &frasl; may be used to print out the fraction slash glyph " ⁄ ".
  • For mixed fractions, in some contexts (like link targets) a "+" is generated between the whole number part and fraction part. If this is not desirable, put the whole number part outside the template, and put a non-breaking space between when the spacing is desirable. For example: "33&nbsp;{{frac|1|3}}".

Parameters[edit source]

A template for displaying common fractions of the form int+num/den nicely. It supports 0–3 anonymous parameters with positional meaning.

Template parameters

ParameterDescriptionTypeStatus
leftmost part1

Denominator if only parameter supplied. Numerator if 2 parameters supplied. Integer if 3 parameters supplied. If no parameter is specified the template will render a fraction slash only.

Lineoptional
middle-right part2

Denominator if 2 parameters supplied. Numerator if 3 parameters supplied.

Lineoptional
rightmost part3

Denominator, always.

Lineoptional

See also[edit source]