Help:Equations
From ChemPRIME
Chemical and mathematical equations can be created in several different ways. The format used is usually dependent on whether you want the symbols to be included in the same paragraph as other text or stand alone (an equation on a line by itself is said to be "displayed"). Symbols representing molecules or simple constants (such as H_{2}O or K_{a}) can usually be included in paragraph form, while important equations should be displayed with LaTeX coding.Contents |
Simple Coding for Formulas and Isotopes
Most HTML style tags work in wiki code, and style tags are quite useful for dealing with equations. The <sup> and <sub> tags, which create superscripts and subscripts, respectively, are useful when including chemical symbolism in regular text. For example,
PO<sub>4</sub><sup>3-</sup>
gives PO_{4}^{3-}.
The Su template combines both subscript and superscript and is great for writing out isotopes or polyatomic ions. For example,
PO{{Su|p= 3-|b= 4}}
gives PO3-4
As you can see, the Su template depicts a superscript/subscript combo stacked in the way it would appear in a typical printed textbook. Use the Su template whenever a subscript should appear directly below a superscript.
To simplify coding isotopes, use the template
{{Isotope|oxygen|16}}
which gives 168O.
Symbols can be made more noticeable by using a system of coding called LaTeX, enclosed in <math> tags. Although the code used is complicated, the resulting equations are enlarged and displayed (in a separate line) as they would be in printed textbooks. Here's one example:
<math>\text{pH}=\text{p}K_{a}\text{+ log}\frac {\text{ }[\text{ A}^{-}\text{ }]\text{ }} {\text{ }[\text{ HA }]\text{ }}</math>
gives
An equation-heavy article should make use of LaTeX formatting, as CoreChem:Polyprotic Acids and Bases does. A more detailed explanation of using LaTeX may be found here). Farther down this page is a list of all equations that are relevant to each chapter in the table of contents for CoreChem and more information about coding with LaTeX.
Using LaTeX
Examples of LaTeX codes for writing mathematical equations are given later on this page and also can be found by searching for "latex math symbols" in Google, for example here or here.
Useful Sites
Other help with math formulas is found atWikipedia:Displaying a Formula
Useful sites with HTML or wiki coding for special characters include
- the Wikipedia Help:Advanced Editing Pages: http://meta.wikimedia.org/wiki/Help:Advanced_editing#Special_characters
- HTML Primer
- HTML Tags
- [1] is an excellent resource for finding HTML friendly metacharacters.
LaTeX Equation Editor
The leftmost button at the top of the wiki-code editor is a capital sigma. Clicking on this button opens the LaTeX equation editor. This editor allows you to see what an equation will look like when interpreted by LaTeX and it also has a number of mathematical expressions already coded so that you can copy and paste them. The equation editor is pretty much self explanatory, so try it out and see whether it works well for you.
When writing a LaTex equation from scratch it's necessary to begin and end the code with the math command like this <math> (CODE HERE) </math> , or as in the example above. However, when creating an equation using the equation editor this is not necessary as the editor will insert these commands automatically. In this case create the equation in the editor and insert it where needed.
Special Characters
In LaTeX math expressions, special characters are embedded with latex code, so and α are
<math>\rarr</math> <math>\alpha</math>.
Including spacing in LaTeX
If you want to include spaces in an equation, use tildes (~). To avoid any confusion with the wiki signature (~~~~) it is a good habit to use "~ " with a space, such as:
Equation | Wiki Code |
---|---|
<math>\text{Density}=\frac{\text{mass}}{\text{volume}} ~ ~ ~ ~\text{or}~ ~ ~ ~ \rho=\frac{\text{m}}{\text{V}}</math> |
Strikethrough in Latex requires backspacing then strikethrough (strikethrough in normal wikicode is <s>text</s> for text):
- Type the text
- Count the number of characters in the text, call it N.
- Precede the text with ~2.5 x N "\!" (backspace) characters
- Precede those characters with "^{underline{M}}" where M = ~1.5 x N "\ " characters.
<math>^{\underline{\ \ \ \ \ \ \ }} \!\!\!\!\!\!\!\!\!\!\!\!\!\!12345</math>
gives
Centering an Equation
To center an equation, use a 'div' tag with a style attribute. All of the code must be in the same line in the editing screen (no line breaks between <div> and </div>).
<div style="text-align:center"><math>\rho=\frac{m}{V}</math></div>
Hyphen or Negative Sign?
A hyphen is not the same as a negative sign.To make sure that your negative charge can be seen as a superscript, or that your algebraic expression looks natural, use what is called an 'en dash' (a dash that is as wide as the letter 'n'). For a dash in text, use an 'em dash' (a dash that is as wide as the letter 'm'). These are encoded in HTML as – and — respectively. Below you can see how hyphens, en dashes, and em dashes look in simple mathematics. The first example uses a hyphen, the second and fourth use en dashes, the third uses an em dash, and the last example uses LaTEX. The last two examples are preferable, because in textbooks variables such as y and a are italicized to distinguish them from units.
Equation | Wiki Code |
---|---|
y = a - b + c^{- 3} | y = a - b + c<sup>- 3</sup> |
y = a – b + c^{– 3} | y = a – b + c<sup>– 3</sup> |
y = a — b + c^{— 3} | y = a — b + c<sup>— 3</sup> |
y = a – b + c^{– 3} | y = a – b + c<sup>– 3</sup> |
y = a − b + c^{ − 3} | <math>y = a - b + c^{-3}</math> |
NOTE: You cannot use en and em dashes within <math> tags! Actually, you don't need to because LaTeX will automatically resize the standard keyboard hyphen (-) to be the correct typeset size for equations.
Force an equation to be a graphic
To force an equation to be generated as a graphic, include a "\," - "small space" - character which forces graphic interpretation of the code.
Equation | Wiki Code |
---|---|
y = 4x^{2} | y = 4x^2 |
OR
Equation | Wiki Code |
---|---|
y = 4x^2\, |
Equation Repository
For each chapter and many sections of ChemPRIME, the table below provides a link to a list of equations used in that section, together with the wiki code that produced the equations. If you need to use one of the equations listed, copy the wiki code to the page you are creating and the equation will appear.
Miscellaneous Formatting Reference
The table below has some quick references for how to format in specific ways common in chemistry equations.
Equation | Wiki Code | Other Info |
---|---|---|
Sample Chemical Formulae | ||
H_{3}O^{+} | H<sub>3</sub>O<sup>+</sup> | Using HTML Markup |
H_{3}O^{ + } | <math>\text{H}_{3}\text{O}^{+}</math> | Using LaTeX: Allowing for translation to text |
<math>\text{H}_{3}\text{O}^{+}\,</math> | Using LaTeX: Force image rendering (\,) | |
I–3 | I{{su|b=3|p=–}} | Using template |
<math>\text{I}_{3}^{-}</math> | Using LaTeX (will always render as image) | |
94Be + 42He → 126C + 10n | {{Isotope|Beryllium|9}} + {{Isotope|Helium|4}} → {{Isotope|Carbon|12}} + {{Isotope|neutron|1}} | Using built-in Isotope Template |
94Be + 42He → 126C + 10n | {{su|b=4|p=9}}Be + {{su|b=2|p=4}}He → {{su|b=6|p=12}}C + {{su|b=0|p=1}}''n'' | Using manual super and subscripts |
<math>{}_{\text{4}}^{\text{9}}\text{Be + }{}_{\text{2}}^{\text{4}}\text{He } \to \text{ }{}_{\text{6}}^{\text{12}}\text{C + }{}_{\text{0}}^{\text{1}}n</math> | Using LaTeX | |
Standard Chemical Equations | ||
<math><math>a\text{A}+b\text{B}_{2} \rightleftharpoons c\text{C}</math> | Using LaTeX | |
aA + bB_{2} cC | aA + bB<sub>2</sub> <math>\rightleftharpoons </math> cC | Using HTML (with LaTeX ) |
<math>a\text{A}+b\text{B}_{2} \to c\text{C}</math> |
Equation | Wiki Code | Other Info |
---|---|---|
<math>\begin{align}{\text{ }[\text{YZ}_{\text{3}}^{\text{2-}}\text{ }] \text{ }}&=\frac{n_{\text{CYZ}_{\text{3}}^{\text{2-}}}}{V_{\text{solution}}} =\frac{\text{number}\times \text{10}^{\text{-a}}\text{ mol }}{\text{number} \times \text{10}^{\text{ -b}}\text{ dm}^{\text{3}}}\\ \text{ }&=\text{number}\times\text{10}^{-\text{c}} \text{ mol dm}^{\text{-3}}\\\end{align}</math> | ||
<math>{[\text{OH}^{ -}]} \approx \sqrt{K_{b}c_{b}}</math> | ||
<math>{[\text{OH}^{ -}]} \approx \sqrt{K_{b}c_{b}}</math> | ||
<math>{[\text{OH}^{-}]}\approx \sqrt{K_{b}\text{(}c_{b}-[\text{OH}^{-}]\text{)}}</math> | ||
H_{2}A + H_{2}O H_{3}O^{+} + HA^{–}
| H<sub>2</sub>A + H<sub>2</sub>O <math>\rightleftharpoons </math> H<sub>3</sub>O<sup>+</sup> + HA<sup>–</sup> <math>K_{a\text{1}}=\frac{\text{ }[\text{ H}_{\text{3}} | |
<math>\text{pH}=\text{p}K_{a}\text{+ log}\frac {\text{ }[\text{ A}^{-}\text{ }]\text{ }} {\text{ }[\text{ HA }]\text{ }}</math> | Henderson-Hasselbalch Equation | |
<math>\begin{align} \text{n}_{\text{X}_{\text{2}}\text{YZ}_{\text{3}}}&=\frac {\text{number g}\text{ X}_{\text{2}}\text{YZ}_{\text{3}}} {\text{number g}\text{ mol}^{-\text{1}}}\\ \text{ }&=\text{number}\times\text{10}^{-\text{a}}{\text{mol} \text{ X}_{\text{2}}\text{YZ}_{\text{3}}}\\ \end{align}</math> | ||
<math>\begin{align} \text{n}_{\text{compound}}&=V_{\text{compound}}\text{ } \times \text{ }c_{\text{compound}}\\ \text{ }&=\text{number}\text{ cm}^{\text{3}}\text{ } \times \text{ }\frac{\text{number}\text{ mmol}} {\text{number cm}^{\text{3}}}\\ \text{ }&=\text{number mmol} \end{align}</math> | ||
<math>\text{pOH}=-\text{log }[\text{OH}^{ -}]=\,</math> | ||
<math>\text{pH}=\text{14}-\text{pOH}= \text{14}-\text{number}=\text{number}\,</math> | ||
For the equilibrium:
| For the equilibrium: <math>\text{A}_{x}\text{B}_{y}\left(s\right) \rightleftharpoons x\text{A}^{m+} \left(aq\right) + y\text{B}^{n+} \left(aq\right)</math> The solubility product constant is: <math>{K}_{sp}=\left[\text{A}^{m+}]^{x} [\text{B}^{n+}\right]^{y}</math> | Solubility Product |