2

I want a result like this. Also, is it possible to force all text in certain math environment to be mathrm?

enter image description here

One solution is to use mhchem package with \ce command

\ce{6CO2 + H2O ->[sunlight][photosynthesis] C6H12O6 + 6O2}

The result is beautiful, but I will wait for enhanced answers

enter image description here

\documentclass{article}

\usepackage{mathtools}

\usepackage{mhchem}

\begin{document}
    
    \begin{alignat*}{2}
        6 \, \mathrm{CO_{2}} + \mathrm{H_{2}O} &\to \mathrm{C_{6}H_{12}O_{6}} + 6 \, \mathrm{O_{2}}
    \end{alignat*}
    
    \begin{equation*}
        \ce{6CO2 ->[sunlight][photosynthesis] C6H12O6 + 6O2}
    \end{equation*}
    
\end{document}

1 Answer 1

3

(Remark: I wrote and posted this answer before I noticed that the OP had rewritten the query to provide a solution based on the \ce macro.)

You should really familiarize yourself with one or more of the chemistry packages written for LaTeX. For instance, with the mhchem package and its \ce user macro, you could write the chemical reaction as

\ce{6CO2 + H2O ->[sunlight][photosynthesis] C6H12O6 + 6O2}

\ce produces the same output in both text and math mode.

Aside: I think it should say 6H2O, not just H2O, on the left hand side. That, or you're missing parentheses around CO2 + H2O.

Another well-known LaTeX package used for chemistry writing is chemformula.


enter image description here

\documentclass{article}
\usepackage[version=4]{mhchem}
\begin{document}
\ce{6CO2 + H2O ->[sunlight][photosynthesis] C6H12O6 + 6O2}
\end{document}
3
  • Thanks for the answer. I do not need to write chemical formulae. Is it possible to align multiple arrows below each other? :) Aug 16, 2022 at 15:16
  • Yes, you are right about this. Aug 16, 2022 at 15:23
  • @Al-MotasemAldaoudeyeh - Please study the section "Aligning equations" at the bottom of page 12 of the user guide of the mhchem package. (To open the user guide in a pdf browser, type texdoc mhchem in a command window.)
    – Mico
    Aug 16, 2022 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .