Diferencia entre revisiones de «Plantilla:NumBlk»

10 190 bytes eliminados ,  8 jun 2015
sin resumen de edición
(Página creada con «This template creates a numbered block which is usually used to number mathematical formulae. This template can be used together with {{tl|EquationRef}} to produce nicely f...»)
 
Sin resumen de edición
 
Línea 1: Línea 1:
This template creates a numbered block which is usually used to number mathematical formulae. This template can be used together with {{tl|EquationRef}} to produce nicely formatted numbered equations if a back reference to an equation is wanted.
<includeonly>{{#if:{{{1}}}|{{Repeat|<dl><dd>|{{str len|{{{1}}}}}}}|}}
 
{|style="border-collapse:collapse; background:none; margin:0; border:none;"
== Parameters ==
|style="vertical-align:middle; border:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;" class="nowrap"|<p style="margin:0;">{{{2}}}</p>
Parameters <nowiki>{{{1}}}</nowiki>, <nowiki>{{{2}}}</nowiki>, and <nowiki>{{{3}}}</nowiki> of this template are required.  In addition, there are two optional parameters <nowiki>{{{RawN}}}</nowiki> and <nowiki>{{{LnSty}}}</nowiki>.<br>
|style="vertical-align:middle; width:99%; border:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;"|
'''<nowiki>{{{1}}}</nowiki>''': Specify indentation. The more colons (:) you put, the further indented the block will be, up to a limit of 20. This parameter can be empty if no indentation is needed.<br>
<p style="margin:0;">
'''<nowiki>{{{2}}}</nowiki>''': The body or content of the block.<br>
{|style="border-collapse:collapse; background:none; margin:0; border:none; width:99%;"
'''<nowiki>{{{3}}}</nowiki>''': Specify the block number.<br>
|style="border:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;" rowspan="2"|<p style="margin:0; font-size:4pt;">&nbsp;</p>
'''<nowiki>{{{RawN}}}</nowiki>''': Assigned with a non-empty or non-whitespaced string to remove the formatting on the number and the parentheses surrounding the number.<br>
|style="width:100%; border:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;"|<p style="margin:0; font-size:1pt;">&nbsp;</p>
'''<nowiki>{{{LnSty}}}</nowiki>''': Specify the line style.<br>
|style="border:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;" rowspan="2"|<p style="margin:0; font-size:4pt;">&nbsp;</p>
'''<nowiki>{{{Border}}}</nowiki>''': If set, put a box around the equation. (Experimental.)
 
== Examples ==
<div align="center" style="padding:0 0 0 1em;">
{|class="wikitable" width="96%"
!colspan="2"|
=== Equations may render HTML ===
|-
|width="55%"|
<code><nowiki>{{NumBlk|:|<math>y=ax+b</math>|Eq. 3}}</nowiki></code>
|width="45%"|
{{NumBlk|:|<math>y=ax+b</math>|Eq. 3}}
|-
|
<code><nowiki>{{NumBlk|:|<math>ax^2+bx+c=0</math>|Eq. 3}}</nowiki></code>
|
{{NumBlk|:|<math>ax^2+bx+c=0</math>|Eq. 3}}
|-
|
<code><nowiki>{{NumBlk|:|<math>\Psi(x_1,x_2)=U(x_1)V(x_2)</math>|2}}</nowiki></code>
|
{{NumBlk|:|<math>\Psi(x_1,x_2)=U(x_1)V(x_2)</math>|2}}
|-
!colspan="2"|
=== Indentation ===
|-
|
<code><nowiki>{{NumBlk||<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3.5}}</nowiki></code>
|
{{NumBlk||<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3.5}}
|-
|
<code><nowiki>{{NumBlk|:|<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|1}}</nowiki></code>
|
{{NumBlk|:|<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|1}}
|-
|
<code><nowiki>{{NumBlk|::|<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|13.7}}</nowiki></code>
|
{{NumBlk|::|<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|13.7}}
|-
|
<code><nowiki>{{NumBlk|:::|<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|1.2}}</nowiki></code>
|
{{NumBlk|:::|<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|1.2}}
|-
!colspan="2"|
=== Formatting of equation number ===
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=3.5|RawN=.}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=3.5|RawN=.}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<3.5>|RawN=.}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<3.5>|RawN=.}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=[3.5]|RawN=.}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=[3.5]|RawN=.}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3='''[3.5]'''|RawN=.}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3='''[3.5]'''|RawN=.}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<math>(3.5)</math>|RawN=.}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<math>(3.5) \,</math>|RawN=.}}
|-
!colspan="2"|
=== Line style ===
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''(3.5)'''</Big>|RawN=.|LnSty=1px dashed red}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''(3.5)'''</Big>|RawN=.|LnSty=1px dashed red}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''(3.5)'''</Big>|RawN=.|LnSty=3px dashed #0a7392}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''(3.5)'''</Big>|RawN=.|LnSty=3px dashed #0a7392}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=3px solid green}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=3px solid green}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=5px dotted blue}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=5px dotted blue}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=0px solid green}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=0px solid green}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=5px none green}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=5px none green}}
|-
|
<code><nowiki>{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=3px double green}}</nowiki></code>
|
{{NumBlk|1=:|2=<math>\bold{a}(t)=\frac{d}{dt}\bold{v}(t)</math>|3=<Big>'''[3.5]'''</Big>|RawN=.|LnSty=3px double #f4c300}}
|-
!colspan="2"|
=== Border ===
|-
|
<code><nowiki>{{NumBlk|:|<math>y=ax+b</math>|Eq. 3|Border=1}}</nowiki></code>
|
{{NumBlk|:|<math>y=ax+b</math>|Eq. 3|Border=1}}
|}
</div>
=== Positioning relative to surrounding images ===
Numbered blocks should be able to be placed around images that take up space on the left or right side of the screen. To ensure numbered block has access to the entire line, consider using a {{tl|clear}}-like template.
 
To illustrate, consider the example:
<blockquote><pre>[[Image:Bnet_fan2.png|frame|right|Fig.1: Bayesian Network representation of Eq.(6)]]
[[Image:Bnet_fan2.png|frame|left|Fig.1: Bayesian Network representation of Eq.(6)]]
<br><br>A Bayesian network (or a belief network) is a probabilistic graphical model that represents a set of
variables and their probabilistic independencies. For example, a Bayesian network could represent the
probabilistic relationships between diseases and symptoms. Given symptoms, the network can be used to compute
the probabilities of the presence of various diseases.
{{NumBlk|1=:|2=<math>
P(a, b, \lambda) = P(a| \lambda) P(b | \lambda) P(\lambda)\,
</math>,|3='''Eq.(6)'''|RawN=.}}</pre></blockquote>
[[Image:Bnet_fan2.png|frame|right|Fig.1: Bayesian Network representation of Eq.(6)]]
[[Image:Bnet_fan2.png|frame|left|Fig.1: Bayesian Network representation of Eq.(6)]]
<br><br>A Bayesian network (or a belief network) is a probabilistic graphical model that represents a set of
variables and their probabilistic independencies. For example, a Bayesian network could represent the
probabilistic relationships between diseases and symptoms. Given symptoms, the network can be used to compute
the probabilities of the presence of various diseases.
{{NumBlk|1=:|2=<math>
P(a, b, \lambda) = P(a| \lambda) P(b | \lambda) P(\lambda)\,
</math>,|3='''Eq.(6)'''|RawN=.}}
{{clear}}
If it is desirable for the numbered block to span the entire line, a {{tl|clear}} should be placed before it.
<blockquote><pre>[[Image:Bnet_fan2.png|frame|right|Fig.1: Bayesian Network representation of Eq.(6)]]
[[Image:Bnet_fan2.png|frame|left|Fig.1: Bayesian Network representation of Eq.(6)]]
<br><br>A Bayesian network (or a belief network) is a probabilistic graphical model that represents a set of
variables and their probabilistic independencies. For example, a Bayesian network could represent the
probabilistic relationships between diseases and symptoms. Given symptoms, the network can be used to compute
the probabilities of the presence of various diseases.
{{clear}}
{{NumBlk|1=:|2=<math>
P(a, b, \lambda) = P(a| \lambda) P(b | \lambda) P(\lambda)\,
</math>,|3='''Eq.(6)'''|RawN=.}}</pre></blockquote>
[[Image:Bnet_fan2.png|frame|right|Fig.1: Bayesian Network representation of Eq.(6)]]
[[Image:Bnet_fan2.png|frame|left|Fig.1: Bayesian Network representation of Eq.(6)]]
<br><br>A Bayesian network (or a belief network) is a probabilistic graphical model that represents a set of
variables and their probabilistic independencies. For example, a Bayesian network could represent the
probabilistic relationships between diseases and symptoms. Given symptoms, the network can be used to compute
the probabilities of the presence of various diseases.
{{clear}}
{{NumBlk|1=:|2=<math>
P(a, b, \lambda) = P(a| \lambda) P(b | \lambda) P(\lambda)\,
</math>,|3='''Eq.(6)'''|RawN=.}}
{{clear}}
 
== Table caveat ==
 
Because {{tl|NumBlk}} is implemented as a table, putting {{tl|NumBlk}} within a table yields a [[Help:Table#Nested_tables|nested table]]. Due to a bug in [[MediaWiki]]'s handling of nested tables, {{tl|NumBlk}} must be used carefully in this case. In particular, when indentation for the outer table is desired, use explicit '''<nowiki><dl><dd></nowiki>''' and '''<nowiki></dd></dl></nowiki>''' tags for indentation instead of a leading colon (:).
 
For example,
<pre><nowiki><dl><dd>
{|
|<math>(f * g)[n]\,</math>&nbsp; &nbsp; &nbsp;
|{{NumBlk||<math>\stackrel{\mathrm{def}}{=}\sum_{m=-\infty}^{\infty} f[m]\cdot g[n - m]\,</math>|
3=<span style="color:darkred">'''(Eq.1)'''</span>|RawN=.}}
|-
|
|<math>= \sum_{m=-\infty}^{\infty} f[n-m]\cdot g[m].\,</math> &nbsp; &nbsp; &nbsp; ([[Convolution#Commutativity|commutativity]])
|}
</dd></dl></nowiki></pre>
produces
<dl><dd>
{|
|<math>(f * g)[n]\,</math>&nbsp; &nbsp; &nbsp;
|{{NumBlk||<math>\stackrel{\mathrm{def}}{=}\sum_{m=-\infty}^{\infty} f[m]\cdot g[n - m]\,</math>|
3=<span style="color:darkred">'''(Eq.1)'''</span>|RawN=.}}
|-
|
|<math>= \sum_{m=-\infty}^{\infty} f[n-m]\cdot g[m].\,</math> &nbsp; &nbsp; &nbsp; ([[Convolution#Commutativity|commutativity]])
|}
</dd></dl>
which shows how the outer '''<nowiki><dl><dd></nowiki>''' and '''<nowiki></dd></dl></nowiki>''' tags give the same indentation as a single colon (:) preceding the table should.
 
For another example,
<pre><dl><dd>
<dl><dd>
{|
|-
|The first parameter for indentation still works when used inside table.
{{NumBlk|::::|<math>ax^2+bx+c=0</math>|Level 4}}
{{NumBlk|:::|<math>ax^2+bx+c=0</math>|Level 3}}
{{NumBlk|::|<math>ax^2+bx+c=0</math>|Level 2}}
{{NumBlk|:|<math>ax^2+bx+c=0</math>|Level 1}}
{{NumBlk||<math>ax^2+bx+c=0</math>|Level 0}}
|-
|}
</dd></dl>
</dd></dl></pre>
produces
<dl><dd>
<dl><dd>
{|
|-
|The first parameter for indentation still works when used inside table.
{{NumBlk|::::|<math>ax^2+bx+c=0</math>|Level 4}}
{{NumBlk|:::|<math>ax^2+bx+c=0</math>|Level 3}}
{{NumBlk|::|<math>ax^2+bx+c=0</math>|Level 2}}
{{NumBlk|:|<math>ax^2+bx+c=0</math>|Level 1}}
{{NumBlk||<math>ax^2+bx+c=0</math>|Level 0}}
|-
|-
|style="border-left:{{#if:{{{Border|}}}|thin solid|none}}; border-top:{{{LnSty|0px none #e5e5e5}}}; border-right:{{#if:{{{Border|}}}|thin solid|none}}; border-bottom:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;"|
<p style="margin:0; font-size:1pt;">&nbsp;</p>
|}
|}
</dd></dl>
</p>
</dd></dl>
|style="vertical-align:middle; border:{{#if:{{{Border|}}}|thin solid|none}}; padding:0.08em;" class="nowrap"|<p style="margin:0pt;">{{#if:{{{RawN|}}}|{{{3}}}|'''({{{3}}})'''}}</p>
which uses two sets of explicit tags to give the same indentation as two colons (::).
|}{{#if:{{{1}}}|{{Repeat|</dd></dl>|{{str len|{{{1}}}}}}}|}}</includeonly><noinclude>{{Documentation}}</noinclude>
<includeonly>
[[Category:Mathematical formatting templates]]
</includeonly>
2867

ediciones