Math & Science ⇒ Typesetting "pH"
Typesetting "pH"
Sorry for asking a mundane question, but it's quite difficult to search for a two letter term.
Should I typeset "pH" in mathmode, or is it ok to use textmode? Technically it's a mathmatical function but I'm not sure...!
Thanks
Should I typeset "pH" in mathmode, or is it ok to use textmode? Technically it's a mathmatical function but I'm not sure...!
Thanks
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Typesetting "pH"
In which mode ever you have to typeset it, you should the excellent siunitx package. The units of chemical or physical quantities are always typeset upright. The package will take care of the correct formatting.
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Typesetting "pH"
Thanks localghost.
Turns out I already had siunitx installed - quite new to all this! But, it doesn't seem to recognise "pH" as a unit and I couldn't find any information about it in the instructions [just to check i tried "\si{\meter}" and that works]. I guess I should just leave it as normal text in a paragraph, the paper I'm reading at the moment has it formatted as normal text so I'm sure it's ok.
Turns out I already had siunitx installed - quite new to all this! But, it doesn't seem to recognise "pH" as a unit and I couldn't find any information about it in the instructions [just to check i tried "\si{\meter}" and that works]. I guess I should just leave it as normal text in a paragraph, the paper I'm reading at the moment has it formatted as normal text so I'm sure it's ok.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Typesetting "pH"
You can define arbitrary units. Try something like this.
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\DeclareSIUnit{\pH}{pH}
\begin{document}
\SI{7}{\pH}
\end{document}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Typesetting "pH"
May I cite the IUPAC Green Book:
Regards
BTW: the pH is not a unit! The Green Book again (emphasis by me): “The quantity pH is defined […]”
That being said, chemmacros offers commands for pH as well as for pKa and pKb and other uses of the p operator:The operator p [...] shall be printed in Roman type. (p 103)
Code: Select all
\documentclass{article}
\usepackage{chemmacros,siunitx}
\begin{document}
The \pH\ of the solution is $\pH = \num{4.3}$
The \pKa of acetic acid is $\pKa = \num{4.7}$
\begin{align*}
\Ka \times \Kb &= 10^{-14} \\
\pKa + \pKb &= 14
\end{align*}
\end{document}
BTW: the pH is not a unit! The Green Book again (emphasis by me): “The quantity pH is defined […]”
site moderator & package author
Typesetting "pH"
that looks great cgnieder. Only problem is I keep getting errors when I put
Console says:
\usepackage{chemmacros}
in the preamble and I can't figure it out.Console says:
Code: Select all
Runaway argument?
{\(\underset {\bool_if:NF \l_chemformula_name_width_bool {\width_to_dim:Nn \ETC
.
! File ended while scanning use of \NewDocumentCommand.
<inserted text>
\par
l.43 \bool_new:N
\l_chemmacros_version_one_bool
?
Last edited by cgnieder on Fri Sep 28, 2012 12:38 pm, edited 1 time in total.
Re: Typesetting "pH"
Which version do you have? The newest one is v3.4 released about two weeks ago.
Regards
Regards
site moderator & package author