Writing Chemistry Formulas in LaTeX

In summary, to write chemical formulas in LaTeX, use the \ce{} command from the mhchem package. To include subscripts and superscripts, use _{} and ^{} commands. Charges can be added using ^+ or ^- commands or the \ce{charge} command. Chemical equations can be written using \ce{->} and \ce{<=>} commands, with reactants and products separated by the \ce{+} command. Special packages and formatting options for chemical formulas include mhchem, chemformula, and chemmacros, as well as the \ce{[...]} command for formatting without reactions and balancing.
  • #1
malawi_glenn
Science Advisor
Homework Helper
Gold Member
6,735
2,455
Hi!

How can i write chemistry formulas in LaTeX ?

Such as:
MgC_12 etc...

It does not look good if it is done in math-environment...:rolleyes:
 
Physics news on Phys.org
  • #2
how do these look?

[tex]\text{Mg C}_{12}[/tex]

[tex]2 \text{H}_2 + \text{O}_2 \rightarrow 2 \text{H}_2\text{O}[/tex]
 
  • #3
Very nice, many thanks =)
 

1. How do I write a chemical formula in LaTeX?

In LaTeX, chemical formulas can be written using the \ce{} command from the mhchem package. This command allows you to easily type in chemical formulas and have them formatted correctly. For example, the chemical formula for water (\ce{H2O}) would be written as \ce{H2O} in LaTeX.

2. How do I include subscripts and superscripts in my chemical formulas?

To include subscripts and superscripts in your chemical formulas, you can use the _{} and ^{} commands respectively. For example, to write carbon dioxide (\ce{CO2}), you would type \ce{CO_2}. If you have multiple subscripts or superscripts, you can enclose them in curly braces to group them together.

3. How do I add charges to my chemical formulas?

To add charges to your chemical formulas, you can use the ^+ or ^- commands after the element symbol. For example, to write a magnesium ion (\ce{Mg^2+}), you would type \ce{Mg^{2+}}. You can also use the \ce{charge} command to specify the charge in parentheses, such as \ce{Fe^{3+}(aq)} for iron(III) in aqueous solution.

4. How do I write chemical equations in LaTeX?

To write chemical equations in LaTeX, you can use the \ce{->} command to indicate the direction of the reaction and the \ce{<=>} command for reversible reactions. You can also use the \ce{+} command to separate reactants and products. For example, the equation for the combustion of methane (\ce{CH4 + 2O2 -> CO2 + 2H2O}) would be written as \ce{CH4 + 2O2 -> CO2 + 2H2O} in LaTeX.

5. Are there any special packages or formatting options for writing chemical formulas in LaTeX?

Yes, there are several packages and formatting options specifically designed for writing chemical formulas in LaTeX, such as mhchem, chemformula, and chemmacros. These packages offer additional features such as customizable arrow styles, automatic balancing of chemical equations, and support for isotopes and nuclear reactions. You can also use the \ce{[...]} command to enclose text that should be formatted as a chemical formula, but without the chemical reactions arrows or balancing.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
252
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
841
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
385
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
793
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
495
Back
Top