LaTeX forum ⇒ Math & Sciencemhchem | Retain chemical State Symbol

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

mhchem | Retain chemical State Symbol

Postby ghostanime2001 » Thu Dec 08, 2011 11:12 am

How to retain the formatting of the gaseous symbol from normal water style to cancel water style ? I just want to show the cancellation of the water compound except the physical state.

MWE:
  1. \documentclass{article}
  2. \usepackage{cancel}
  3. \usepackage[version=3]{mhchem}
  4. \begin{document}
  5. \noindent Normal water style: \ce{H2O_{(g)}} \\
  6. Cancel water style: \ce{\cancel{\ce{H2O}}_{(g)}}
  7. \end{document}

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 9572
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Dec 08, 2011 11:17 am

You could add a \ce for the subscript:
  1. \ce{\cancel{\ce{H2O}}_\ce{(g)}}


Stefan
LaTeX.org admin

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Postby ghostanime2001 » Thu Dec 08, 2011 11:37 am

The depth of the subscript changes is there a way to have it remain absolutely unchanged?

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Sun Feb 12, 2012 2:33 pm

mhchem usually requires a space after a command to return to upright font. Including chemmacros' possibilities this gives you several solutions:
  1. \documentclass{article}
  2.  
  3. \usepackage{cancel}
  4. \usepackage[method=mhchem]{chemmacros}
  5.  
  6. \begin{document}
  7.  
  8. \noindent Normal water style: \ce{H2O_{(g)}} \\
  9. cancelled wrong: \ce{\cancel{\ce{H2O}}_{(g)}} \\
  10. cancelled with \verb=\ce=: \ce{\cancel{\ce{H2O}}_\ce{(g)}} \\ % Stefan's suggestion
  11. cancelled with space: \ce{\cancel{\ce{H2O}} _{(g)}}
  12.  
  13. Or the chemmacros solution:\chemsetup[phases]{pos=sub}
  14. % setup needed with most recent version of chemmacros (v3.0d)
  15.  
  16. \noindent Normal water style: \ce{H2O\gas} \\
  17. Cancel water style: \ce{\cancel{\ce{H2O}}\gas}
  18.  
  19. \end{document}

retain_state.png
retain_state.png (22.87 KiB) Viewed 2947 times


Regards
site moderator & package author


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 5 guests