LaTeX forum ⇒ Text Formattingmhchem | Hide Subscript in chemical Formula

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

mhchem | Hide Subscript in chemical Formula

Postby ghostanime2001 » Thu Dec 15, 2011 9:48 pm

I just want to hide the "2" in HF (second chem reaction) in my document without changing the vertical alignment of the "acid" label under HF2. If that isn't clear enough:

Typeset "HF" like "HF2" without "2" in the first chem equation to keep labels consistent height.

MWE:
  1. \documentclass[fleqn]{article}
  2. \usepackage{amsfonts}
  3. \usepackage{amssymb}
  4. \usepackage{amstext}
  5. \usepackage{amsthm}
  6. \usepackage{array}
  7. \usepackage{booktabs}
  8. \usepackage{calc}
  9. \usepackage{cancel}
  10. \usepackage{chemfig}
  11. \usepackage{chemmacros}
  12. \usepackage[shortlabels,inline]{enumitem}
  13. \usepackage{fix-cm}
  14. \usepackage[T1]{fontenc}
  15. \usepackage{fouridx}
  16. \usepackage{fullpage}
  17. \usepackage[margin=1in]{geometry}
  18. \usepackage{graphicx}
  19. \usepackage[utf8]{inputenc}
  20. \usepackage{lewis}
  21. \usepackage{multienum}
  22. \usepackage{multirow}
  23. \usepackage{pbox}
  24. \usepackage{pgfkeys}
  25. \usepackage{pifont}
  26. \usepackage{pstricks}
  27. \usepackage{pst-node}
  28. \usepackage{pst-plot}
  29. \usepackage{tensor}
  30. \usepackage{textcomp}
  31. \usepackage{type1cm}
  32. \usepackage{ulem}
  33. \usepackage{wasysym}
  34. \setlength{\parindent}{0in}
  35. \setlength{\parskip}{0in}
  36. \setlength{\mathindent}{0in}
  37. \newlist{longenum}{enumerate}{6}
  38. \setlist[longenum,1]{label=\arabic*.}
  39. \setlist[longenum,2]{label=\alph*)}
  40. \setlist[longenum,3]{label=\alph*)}
  41. \setlist[longenum,4]{label=\alph*)}
  42. \setlist[longenum,5]{label=\alph*)}
  43. \setlist[longenum,6]{label=\alph*)}
  44. \newcommand{\since}{\raisebox{0.56pt}{\rotatebox[origin=c]{180}{$\Large\wasytherefore$}}}
  45. \newcommand{\thus}{\Large{\wasytherefore}}
  46. \newcommand{\s}{\par\medskip}
  47. \newcommand{\ssa}{\\ \addlinespace[\smallskipamount]}
  48. \newcommand{\msa}{\\ \addlinespace[\medskipamount]}
  49. \newcommand{\bsa}{\\ \addlinespace[\bigskipamount]}
  50. \allowdisplaybreaks
  51. \pagestyle{empty}
  52. \begin{document}
  53. Original: \ce{$\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{NH4+}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{F-}}$ <=> $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{NH3}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{HF}}$} \\ \\ \\
  54. Typset with a subscript of HF: \ce{$\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{NH4+}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{F-}}$ <=> $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{NH3}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{HF2}}$}
  55. \end{document}
Last edited by ghostanime2001 on Sat Dec 17, 2011 8:23 pm, edited 1 time in total.

Tags:

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Postby josephwright » Fri Dec 16, 2011 2:44 pm

Do you mean something like
  1. \documentclass{article}
  2. \usepackage{chemmacros}
  3. \begin{document}
  4. Original: \ce{$\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{NH4+}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{F-}}$ <=> $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{NH3}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{HF}}$} \\ \\ \\
  5. Typset with a subscript of HF: \ce{$\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{NH4+}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{F-}}$ <=> $\underset{\clap{\begin{tabular}[t]{@{}c@{}}base\end{tabular}}}{\ce{NH3}}$ + $\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{HF$\smash{_2}$}}$}
  6. \end{document}

perhaps?

BTW, it would be better to cut down your code to a minimal example before posting: there were a lot of excess packages in your preamble.
Joseph Wright

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

Postby ghostanime2001 » Fri Dec 16, 2011 9:08 pm

I think you may have misunderstood me. I wanted to type the "acid" under HF2 without smash like typing "acid" under HF

  1. \documentclass{article}
  2. \usepackage{chemmacros}
  3. \usepackage{mhchem}
  4. \begin{document}
  5. \ce{$\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{HF}}$} \qquad
  6. \ce{$\underset{\clap{\begin{tabular}[t]{@{}c@{}}acid\end{tabular}}}{\ce{HF2}}$}
  7. \end{document}

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

Postby cgnieder » Sat Dec 17, 2011 7:52 pm

You could add a phantom:
  1. \documentclass{article}
  2. \usepackage[version=3]{mhchem}
  3. \begin{document}
  4.  
  5. without phantom: $\underset{acid}{\ce{HCl}}$ $\underset{acid}{\ce{H2SO4}}$
  6.  
  7. with phantom: $\underset{acid}{\ce{HCl}\vphantom{\ce{H2}}}$ $\underset{acid}{\ce{H2SO4}}$
  8.  
  9. \end{document}
site moderator & package author


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 5 guests