Help:Displaying a formula: Difference between revisions
Content deleted Content added
Caleb Cooper (talk | contribs) No edit summary |
Caleb Cooper (talk | contribs) Tag: 2017 source edit |
||
Line 1,306:
|}
==
Equations can use color
{| class="wikitable"▼
|-
! How it looks rendered
! Syntax
! Feature
|-
| <syntaxhighlight lang="latex" inline>{\color{Blue}x^2}+{\color{Orange}2x}-{\color{LimeGreen}1}</syntaxhighlight>
|
|-
| {{nowrap|1=<syntaxhighlight lang="latex" inline>x=\frac{{\color{Blue}-b}\pm\sqrt{\color{Red}b^2-4ac}}{\color{Green}2a}</syntaxhighlight>}}
|
|}
The <code>\color</code> command colors all symbols to its right.
However, if the <code>\color</code> command is enclosed in a pair of braces (e.g. <code>{\color{Red}...}</code>) then no symbols outside of those braces are affected.
▲*:<math>{\color{Blue}x^2}+{\color{YellowOrange}2x}-{\color{OliveGreen}1}</math>
{| class="wikitable"
|-
! How it looks rendered
! Syntax
! Feature
|-
| <syntaxhighlight lang="latex" inline>x\color{red}\neq y=z</syntaxhighlight>
|
Colors <span style="color:red;">red</span> everything to the right of <code><nowiki>\color{red}</nowiki></code>. To only color the <math>\neq</math> symbol red, place braces around <code><nowiki>\color{red}\neq</nowiki></code> or insert <code><nowiki>\color{black}</nowiki></code> to the right of <code><nowiki>\neq</nowiki></code>.
|-
| <math>x{\color{red}\neq} y=z</math>
| <syntaxhighlight lang="latex" inline>x{\color{red}\neq} y=z</syntaxhighlight>
|
|-
| <math>x\color{red}\neq\color{black} y=z</math>
| <syntaxhighlight lang="latex" inline>x\color{red}\neq\color{black} y=z</syntaxhighlight>
|
|-
| <math>\frac{-b\color{Green}\pm\sqrt{b^2\color{Blue}-4{\color{Red}a}c}}{2a}=x</math>
| {{nowrap|1=<syntaxhighlight lang="latex" inline>\frac{-b\color{Green}\pm\sqrt{b^2\color{Blue}-4{\color{Red}a}c}}{2a}=x</syntaxhighlight>}}
| The outermost braces in <code>{\color{Red}a}c</code> limit the affect of <code>\color{Red}</code> to the symbol <code>a</code>. Similarly, <code>\color{Blue}</code> does not affect any symbols outside of the <code>\sqrt{}</code> that encloses it, and <code>\color{Green}</code> does not affect any symbols outside of the numerator.
|}
There are several alternate notations styles
▲*:<math>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</math>
{| class="wikitable"
▲{| class=wikitable
|-
! How it looks rendered
! Syntax
! Feature
|-
▲
| <syntaxhighlight lang="latex" inline>{\color{Blue}x^2}+{\color{Orange}2x}-{\color{LimeGreen}1}</syntaxhighlight>
| works with both texvc and MathJax
▲| <math>e^{i \pi} + 1 = 0\,</math>
|-
| <math>\color{Blue}x^2\color{Black}+\color{Orange}2x\color{Black}-\color{LimeGreen}1</math>
| <code>'''\definecolor{orange}{RGB}{255,165,0}\pagecolor{orange}'''e^{i \pi} + 1 = 0</code>▼
| {{nowrap|1=<syntaxhighlight lang="latex" inline>\color{Blue}x^2\color{Black}+\color{Orange}2x\color{Black}-\color{LimeGreen}1</syntaxhighlight>}}
| works with both texvc and MathJax
|-
| <math>\color{Blue}{x^2}+\color{Orange}{2x}-\color{LimeGreen}{1}</math>
| <syntaxhighlight lang="latex" inline>\color{Blue}{x^2}+\color{Orange}{2x}-\color{LimeGreen}{1}</syntaxhighlight>
| only works with MathJax
| style="background-color:orange;" | <math>e^{i \pi} + 1 = 0\,</math>▼
|
Some color names are predeclared according to the following table, you can use them directly for the rendering of formulas (or for declaring the intended color of the page background).
{{Formula Supported Named Colors}}
Latex does not have a command for setting the background color. The most effective way of setting a background color is by setting a CSS styling rule for a table cell:
<pre style="display: inline-block;">
{| class="wikitable" align="center"
| style="background-color: gray;" | <math>x^2</math>
|}
</pre>
Rendered as:
{| class="wikitable" align="center"
| style="background-color: gray;" | <math>x^2</math>
| style="background-color: Goldenrod;" | <math>y^3</math>
|}
Custom colors can be defined using:
<syntaxhighlight lang="latex">\definecolor{myorange}{rgb}{1,0.65,0.4}\color{myorange}e^{i \pi}\color{Black} + 1 = 0</syntaxhighlight>
▲
▲Note that color should not be used as the ''only'' way to identify something, because it will become meaningless on black-and-white media or for color-blind people. See [[Wikipedia:Manual of Style#Color coding]].
== Formatting issues == <!--T:75-->
| |||