變更
Close improperly closed tt tags
<includeonly><!-- 在這裡加入模板的保護標識 --></includeonly>
<noinclude>{{template doc page viewed directly}}</noinclude>
== 用法 ==
<!-- 在本行下編輯模板說明 -->
<templatedata>
{
"params": {
"1": {
"label": "数值"
},
"2": {
"label": "不确定性(上界)"
},
"3": {
"label": "不确定性下界"
},
"nocategory": {
"label": "不加错误提示分类"
},
"e": {
"label": "指数"
},
"u": {
"aliases": [
"ul"
],
"label": "单位"
},
"up": {
"aliases": [
"upl"
],
"label": "每"
},
"p": {
"label": "值前缀"
},
"end": {
"label": "主后缀"
},
"+errend": {
"label": "不确定性上界后缀"
},
"-errend": {
"label": "不确定性下界后缀"
},
"errend": {
"label": "不确定性后缀"
},
"s": {
"label": "值后缀"
}
},
"description": "便于使用科学计数法(包括不确定性)显示数值。",
"format": "inline"
}
</templatedata>
==Purpose==
This template is used to easily present values in [[scientific notation]], including uncertainty and/or units, in accordance with the [[WP:MOSNUM|wikipedia manual of style]]. It wraps the entire result in a {{tl|nowrap}} block, so that it never gets broken into separate pieces at the end of a line. (See [[WP:NBSP]] for more information on the usage of non-breaking spaces.)
== Arguments ==
There are four ways this template can be used:
* <code><nowiki>{{</nowiki>val|''number''<nowiki>}}</nowiki></code> - for displaying values without uncertainty/significance.
* <code><nowiki>{{</nowiki>val|''number''|''uncertainty''<nowiki>}}</nowiki></code> - for displaying values with uncertainty like so {{val|1234|56}}.
* <code><nowiki>{{</nowiki>val|''number''|''upper uncertainty''|''lower uncertainty''<nowiki>}}</nowiki></code> - for displaying values with uncertainty like so {{val|1234|+56|-78}}.
* <code><nowiki>{{</nowiki>val|''number''|(''significance'')<nowiki>}}</nowiki></code> - for displaying values with significance like so {{val|1234|(56)}}.
They all take roughly the same arguments
{|
|valign=top| '''1''' || The value (must be a valid number)
|-
|valign=top| '''2''' || The (upper limit of) uncertainty (must be a valid number) or significance (must be a valid number in parenthesis)
|-
|valign=top| '''3''' || The lower limit of uncertainty (must be a valid negative number)
|-
|valign=top| '''e''' || The exponent for the power of 10 (optional). This will show up in the result as " × 10{{su|p=e}}".
:Values (arguments '''1'''-'''3''' and '''e''') are run through code copied from {{tl|delimitnum}} for readability, except for argument '''2''' when it is surrounded by parenthesis. '''This currently causes an error for large numbers, numbers that require high precision and numbers that have zeros after the decimal point. This last issue is being addressed, the other issues require changes to the Wikipedia software.'''
|-
|valign=top| '''u''' / '''ul''' || The units for the number (optional, with/without a link to the page about the unit respectively).
|-
|valign=top| '''up''' / '''upl''' || The units per for the units (optional, requires '''u''' to be specified, with/without a link to the page about the unit respectively).
:Units (specified by '''u''', '''ul''', '''up''' and '''upl''') are replaced by a more aesthetically pleasing HTML representation and get a link ('''ul''' and '''upl''' only, if they are in the list found in {{tl|val/units}} or if they are supported by {{tl|convert}}). You can specify units using just '''u'''; a good example is "ul=m/s", which gets translated to "[[Meter per second|m·s<sup>-1</sup>]]", or you can use '''u''' and '''up''', as in "u/up"; a good examples if "ul=m|up=s", which gets translated to "[[Meter|m]]/s".
|-
|valign=top| '''p''' || A prefix for the value (such as ∆, ⌀, etc.; optional).
|-
|valign=top| '''s''' || A suffix for the value (such as %, optional).
:Prefixes (specified by '''p''') and suffixes (specified by '''s''') are put in front of or behind the value ''as is'': this includes spaces. They are inside the ''nowrap'' block and will always be on the same line as the value. The parameters that previously provided this functionality ('''h''' for header and '''f''' for footer) are ''deprecated'' and will be ignored.
|-
|-
|valign=top| '''end''' || Appends something after the main value. For example, <nowiki>{{val|123.24|end=...}}</nowiki> gives {{val|123.24|end=...}}
|-
|valign=top| '''errend''' || Appends something after the uncertainty. For example, <nowiki>{{val|123.23|end=...|2.34|errend=...}}</nowiki> gives {{val|123.23|end=...|2.34|errend=...}}
|-
|align=top| {{nobr|'''+errend'''}} & {{nobr|'''-errend'''}} || Appends something after the positive/negative uncertainties. For example, <nowiki>{{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}}</nowiki> gives {{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}}
|-
|valign=top| '''nocategory''' || If set to any value, errors in the use of this template will not cause the page to be added to the [[:Category:Pages with incorrect formatting templates use|Pages with incorrect formatting templates use]] category. This is useful for documentation and test pages that do not need to be fixed.
|}
See {{tl|val/test}} for a list of examples of the correct output of {{tl|val}} and the errors it may return when incorrectly used.
== Errors ==
There is strict checking on the validity of arguments; any incorrect use will result in an error, which is displayed using {{tl|FormattingError}}. Pages that contain incorrect use of this template will show up on [[:Category:Pages with incorrect formatting templates use]].
== Format convention ==
As mentioned before, {{tl|val}} should produce formatting compliant with the [[WP:MOSNUM|wikipedia manual of style]]. It currently produces formatting compliant with the ''U.S. Government Printing Office Style Manual'', in [http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=2008_style_manual&docid=f:chapter12.pdf rules 12.9e and 12.14], which requires that the [[decimal separator]] be a [[full stop]]; i.e. “decimal point” (.), requires comma-delimiting to the left of the decimal point for numbers with four or more digits to the left (values of {{val|1000}} or more), and also requires space-delimiting to the right of the decimal point for numbers containing five or more digits to the right (e.g., {{val|0.12345}} and {{val|5.12345}} and {{val|125.12345}}).
Note that if <nowiki>{{val}}</nowiki> is used on numbers simultaneously comprising four or more digits to the left of the decimal point ''and'' five or more digits to the right, the resultant expression will delimited with commas left and spaces (actually non-selectable, non-breaking, narrow gaps) right (see below).
== Examples ==
:{|
|-
|<code><nowiki>{{val|1234567890}}</nowiki></code>|| → ||{{val|1234567890}}
|-
|<code><nowiki>{{val|1.23456789}}</nowiki></code>|| → ||{{val|1.23456789}}
|-
|{{xpdop3c|gives={{!}}{{!}} → {{!}}{{!}}|d=|val|21563.252564425}}
|-
|colspan=3|'''Uncertainty/significance'''
|-
|<code><nowiki>{{val|1.234|0.005}}</nowiki></code>|| → ||{{val|1.234|0.005}}
|-
|<code><nowiki>{{val|1.234|+0.005|-0.006}}</nowiki></code>|| → ||{{val|1.234|+0.005|-0.006}}
|-
|<code><nowiki>{{val|1.234|(5)}}</nowiki></code>|| → ||{{val|1.234|(5)}}
|-
|colspan=3|'''Exponents/units'''
|-
|<code><nowiki>{{val|1.234|e=5|u=m}}</nowiki></code>|| → ||{{val|1.234|e=5|u=m}}
|-
|<code><nowiki>{{val|1.234|e=5|u=m2}}</nowiki></code>|| → ||{{val|1.234|e=5|u=m2}}
|-
|<code><nowiki>{{val|1.234|e=5|ul=m}}</nowiki></code>|| → ||{{val|1.234|e=5|ul=m}}
|-
|<code><nowiki>{{val|1.234|0.056|e=7}}</nowiki></code>|| → ||{{val|1.234|0.056|e=7}}
|-
|<code><nowiki>{{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}</nowiki></code>|| → ||{{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}
|-
|<code><nowiki>{{val|1.234|0.056|e=7|ul=psi}}</nowiki></code>|| → ||{{val|1.234|0.056|e=7|ul=psi}}
|-
|<code><nowiki>{{val|123.4|ul=USgal}}</nowiki></code>|| → ||{{val|123.4|ul=USgal}}
|-
|<code><nowiki>{{val|12.34|ul=mpgimp}}</nowiki></code>|| → ||{{val|12.34|ul=mpgimp}}
|-
|colspan=3|'''Prefix/suffix'''
|-
|<code><nowiki>{{val|p=Δ&nbsp;|12.34|s=%}}</nowiki></code>|| → ||{{val|p=Δ |12.34|s=%}}
|}
== 參見 ==
* {{tl|Valid}} : number validity checking (for parameters 1, 2, 3, e : value, and uncertainties, base-10 exponent)
* {{tl|FormattingError}} : for reporting inconsistent parameters
* {{tl|Val/delimitnum}} : for formatting a decimal number with delimiters between groups of digits
* {{tl|Su}} : for formatting exponents, or two-values incertainty one below the other (monospaced : currently not printable to PDF)
* {{tl|Val/units}} : for formatting unit names (contents of parameters <tt>u</tt> or <tt>up</tt>)
* {{tl|Val/unitswithlink}} : for formatting unit names with links (contents of parameters <tt>ul</tt> or <tt>upl</tt>)
<includeonly>
[[Category:数学格式模板]]
[[ar:قالب:val]]
[[as:সাঁচ:Val]]
[[bn:টেমপ্লেট:Val]]
[[cy:Nodyn:Val]]
[[da:Skabelon:Værdi]]
[[diq:Template:Val]]
[[en:Template:Val]]
[[id:Templat:Val]]
[[it:Template:M]]
[[ja:Template:Val]]
[[km:ទំព័រគំរូ:Val]]
[[mr:साचा:Val]]
[[ne:ढाँचा:Val]]
[[or:ଛାଞ୍ଚ:Val]]
[[pt:Predefinição:Val]]
[[ro:Format:Val]]
[[roa-tara:Template:M]]
[[sco:Template:Val]]
[[si:සැකිල්ල:Val]]
[[sk:Šablóna:Val]]
[[te:మూస:Val]]
[[th:แม่แบบ:ค่า]]
[[uk:Шаблон:Val]]
[[yo:Àdàkọ:Val]]
</includeonly>
<noinclude>{{template doc page viewed directly}}</noinclude>
== 用法 ==
<!-- 在本行下編輯模板說明 -->
<templatedata>
{
"params": {
"1": {
"label": "数值"
},
"2": {
"label": "不确定性(上界)"
},
"3": {
"label": "不确定性下界"
},
"nocategory": {
"label": "不加错误提示分类"
},
"e": {
"label": "指数"
},
"u": {
"aliases": [
"ul"
],
"label": "单位"
},
"up": {
"aliases": [
"upl"
],
"label": "每"
},
"p": {
"label": "值前缀"
},
"end": {
"label": "主后缀"
},
"+errend": {
"label": "不确定性上界后缀"
},
"-errend": {
"label": "不确定性下界后缀"
},
"errend": {
"label": "不确定性后缀"
},
"s": {
"label": "值后缀"
}
},
"description": "便于使用科学计数法(包括不确定性)显示数值。",
"format": "inline"
}
</templatedata>
==Purpose==
This template is used to easily present values in [[scientific notation]], including uncertainty and/or units, in accordance with the [[WP:MOSNUM|wikipedia manual of style]]. It wraps the entire result in a {{tl|nowrap}} block, so that it never gets broken into separate pieces at the end of a line. (See [[WP:NBSP]] for more information on the usage of non-breaking spaces.)
== Arguments ==
There are four ways this template can be used:
* <code><nowiki>{{</nowiki>val|''number''<nowiki>}}</nowiki></code> - for displaying values without uncertainty/significance.
* <code><nowiki>{{</nowiki>val|''number''|''uncertainty''<nowiki>}}</nowiki></code> - for displaying values with uncertainty like so {{val|1234|56}}.
* <code><nowiki>{{</nowiki>val|''number''|''upper uncertainty''|''lower uncertainty''<nowiki>}}</nowiki></code> - for displaying values with uncertainty like so {{val|1234|+56|-78}}.
* <code><nowiki>{{</nowiki>val|''number''|(''significance'')<nowiki>}}</nowiki></code> - for displaying values with significance like so {{val|1234|(56)}}.
They all take roughly the same arguments
{|
|valign=top| '''1''' || The value (must be a valid number)
|-
|valign=top| '''2''' || The (upper limit of) uncertainty (must be a valid number) or significance (must be a valid number in parenthesis)
|-
|valign=top| '''3''' || The lower limit of uncertainty (must be a valid negative number)
|-
|valign=top| '''e''' || The exponent for the power of 10 (optional). This will show up in the result as " × 10{{su|p=e}}".
:Values (arguments '''1'''-'''3''' and '''e''') are run through code copied from {{tl|delimitnum}} for readability, except for argument '''2''' when it is surrounded by parenthesis. '''This currently causes an error for large numbers, numbers that require high precision and numbers that have zeros after the decimal point. This last issue is being addressed, the other issues require changes to the Wikipedia software.'''
|-
|valign=top| '''u''' / '''ul''' || The units for the number (optional, with/without a link to the page about the unit respectively).
|-
|valign=top| '''up''' / '''upl''' || The units per for the units (optional, requires '''u''' to be specified, with/without a link to the page about the unit respectively).
:Units (specified by '''u''', '''ul''', '''up''' and '''upl''') are replaced by a more aesthetically pleasing HTML representation and get a link ('''ul''' and '''upl''' only, if they are in the list found in {{tl|val/units}} or if they are supported by {{tl|convert}}). You can specify units using just '''u'''; a good example is "ul=m/s", which gets translated to "[[Meter per second|m·s<sup>-1</sup>]]", or you can use '''u''' and '''up''', as in "u/up"; a good examples if "ul=m|up=s", which gets translated to "[[Meter|m]]/s".
|-
|valign=top| '''p''' || A prefix for the value (such as ∆, ⌀, etc.; optional).
|-
|valign=top| '''s''' || A suffix for the value (such as %, optional).
:Prefixes (specified by '''p''') and suffixes (specified by '''s''') are put in front of or behind the value ''as is'': this includes spaces. They are inside the ''nowrap'' block and will always be on the same line as the value. The parameters that previously provided this functionality ('''h''' for header and '''f''' for footer) are ''deprecated'' and will be ignored.
|-
|-
|valign=top| '''end''' || Appends something after the main value. For example, <nowiki>{{val|123.24|end=...}}</nowiki> gives {{val|123.24|end=...}}
|-
|valign=top| '''errend''' || Appends something after the uncertainty. For example, <nowiki>{{val|123.23|end=...|2.34|errend=...}}</nowiki> gives {{val|123.23|end=...|2.34|errend=...}}
|-
|align=top| {{nobr|'''+errend'''}} & {{nobr|'''-errend'''}} || Appends something after the positive/negative uncertainties. For example, <nowiki>{{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}}</nowiki> gives {{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}}
|-
|valign=top| '''nocategory''' || If set to any value, errors in the use of this template will not cause the page to be added to the [[:Category:Pages with incorrect formatting templates use|Pages with incorrect formatting templates use]] category. This is useful for documentation and test pages that do not need to be fixed.
|}
See {{tl|val/test}} for a list of examples of the correct output of {{tl|val}} and the errors it may return when incorrectly used.
== Errors ==
There is strict checking on the validity of arguments; any incorrect use will result in an error, which is displayed using {{tl|FormattingError}}. Pages that contain incorrect use of this template will show up on [[:Category:Pages with incorrect formatting templates use]].
== Format convention ==
As mentioned before, {{tl|val}} should produce formatting compliant with the [[WP:MOSNUM|wikipedia manual of style]]. It currently produces formatting compliant with the ''U.S. Government Printing Office Style Manual'', in [http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=2008_style_manual&docid=f:chapter12.pdf rules 12.9e and 12.14], which requires that the [[decimal separator]] be a [[full stop]]; i.e. “decimal point” (.), requires comma-delimiting to the left of the decimal point for numbers with four or more digits to the left (values of {{val|1000}} or more), and also requires space-delimiting to the right of the decimal point for numbers containing five or more digits to the right (e.g., {{val|0.12345}} and {{val|5.12345}} and {{val|125.12345}}).
Note that if <nowiki>{{val}}</nowiki> is used on numbers simultaneously comprising four or more digits to the left of the decimal point ''and'' five or more digits to the right, the resultant expression will delimited with commas left and spaces (actually non-selectable, non-breaking, narrow gaps) right (see below).
== Examples ==
:{|
|-
|<code><nowiki>{{val|1234567890}}</nowiki></code>|| → ||{{val|1234567890}}
|-
|<code><nowiki>{{val|1.23456789}}</nowiki></code>|| → ||{{val|1.23456789}}
|-
|{{xpdop3c|gives={{!}}{{!}} → {{!}}{{!}}|d=|val|21563.252564425}}
|-
|colspan=3|'''Uncertainty/significance'''
|-
|<code><nowiki>{{val|1.234|0.005}}</nowiki></code>|| → ||{{val|1.234|0.005}}
|-
|<code><nowiki>{{val|1.234|+0.005|-0.006}}</nowiki></code>|| → ||{{val|1.234|+0.005|-0.006}}
|-
|<code><nowiki>{{val|1.234|(5)}}</nowiki></code>|| → ||{{val|1.234|(5)}}
|-
|colspan=3|'''Exponents/units'''
|-
|<code><nowiki>{{val|1.234|e=5|u=m}}</nowiki></code>|| → ||{{val|1.234|e=5|u=m}}
|-
|<code><nowiki>{{val|1.234|e=5|u=m2}}</nowiki></code>|| → ||{{val|1.234|e=5|u=m2}}
|-
|<code><nowiki>{{val|1.234|e=5|ul=m}}</nowiki></code>|| → ||{{val|1.234|e=5|ul=m}}
|-
|<code><nowiki>{{val|1.234|0.056|e=7}}</nowiki></code>|| → ||{{val|1.234|0.056|e=7}}
|-
|<code><nowiki>{{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}</nowiki></code>|| → ||{{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}
|-
|<code><nowiki>{{val|1.234|0.056|e=7|ul=psi}}</nowiki></code>|| → ||{{val|1.234|0.056|e=7|ul=psi}}
|-
|<code><nowiki>{{val|123.4|ul=USgal}}</nowiki></code>|| → ||{{val|123.4|ul=USgal}}
|-
|<code><nowiki>{{val|12.34|ul=mpgimp}}</nowiki></code>|| → ||{{val|12.34|ul=mpgimp}}
|-
|colspan=3|'''Prefix/suffix'''
|-
|<code><nowiki>{{val|p=Δ&nbsp;|12.34|s=%}}</nowiki></code>|| → ||{{val|p=Δ |12.34|s=%}}
|}
== 參見 ==
* {{tl|Valid}} : number validity checking (for parameters 1, 2, 3, e : value, and uncertainties, base-10 exponent)
* {{tl|FormattingError}} : for reporting inconsistent parameters
* {{tl|Val/delimitnum}} : for formatting a decimal number with delimiters between groups of digits
* {{tl|Su}} : for formatting exponents, or two-values incertainty one below the other (monospaced : currently not printable to PDF)
* {{tl|Val/units}} : for formatting unit names (contents of parameters <tt>u</tt> or <tt>up</tt>)
* {{tl|Val/unitswithlink}} : for formatting unit names with links (contents of parameters <tt>ul</tt> or <tt>upl</tt>)
<includeonly>
[[Category:数学格式模板]]
[[ar:قالب:val]]
[[as:সাঁচ:Val]]
[[bn:টেমপ্লেট:Val]]
[[cy:Nodyn:Val]]
[[da:Skabelon:Værdi]]
[[diq:Template:Val]]
[[en:Template:Val]]
[[id:Templat:Val]]
[[it:Template:M]]
[[ja:Template:Val]]
[[km:ទំព័រគំរូ:Val]]
[[mr:साचा:Val]]
[[ne:ढाँचा:Val]]
[[or:ଛାଞ୍ଚ:Val]]
[[pt:Predefinição:Val]]
[[ro:Format:Val]]
[[roa-tara:Template:M]]
[[sco:Template:Val]]
[[si:සැකිල්ල:Val]]
[[sk:Šablóna:Val]]
[[te:మూస:Val]]
[[th:แม่แบบ:ค่า]]
[[uk:Шаблон:Val]]
[[yo:Àdàkọ:Val]]
</includeonly>