(updated to incorporate the comments by @egreg, barbara beaton, and @DCh)
I assume your document uses a roman (serif) font rather than a sans-serif font for mathematics. To ensure that constants are typeset consistently using upright Roman letters, it's handy to create a dedicated macro named, say, \ct
that uses the following macros in a nested fashion: \text
(from the amsmath
package), \rmfamily
(just in case the surrounding material is non-roman), and \upshape
.
\newcommand\ct[1]{\text{\rmfamily\upshape #1}}
Then, use this macro to typeset an equation such as
$\ct{e}^{\ct{i}\pi}-1=0$
Suppose, furthermore, that your documents contains two frequently-occurring constants named ab-cd
and fi-fi
. (You did say that the names of the constants might contain ligatures...) To help speed up typing, you could define two macros \abcd
and \fifi
as follows:
\newcommand*{\abcd}{\ct{ab-cd}}
\newcommand*{\fifi}{\ct{fi-fi}}
The result of a full MWE:
\DeclareSymbolFont{AMSb}{U}{msb}{m}{n}
\documentclass[noamsfonts]{amsart} \usepackage[bitstream-charter]{mathdesign}
%% use the \ct macro to define math constants
\newcommand\ct[1]{\text{\rmfamily\upshape #1}}
%% define two math constants with rather contrived names...
\newcommand{\abcd}{\ct{ab-cd}}
\newcommand{\fifi}{\ct{fi-fi}}
\begin{document}
\sffamily % switch to sans-serif for main text font
$\ct{e}^{\ct{i}\piup}-1=0$,
$(\abcd)^2-\ct{e}^{(\fifi^3)}=0$
not in math mode: ab-cd, fi-fi
\end{document}
I managed to resolve this issue myself, and thought I'd share my solution. Thanks to @clemens for the package suggestions.
An MWE is below, along with an image of the produced output. The result shows some alignment issues which I have chosen not to correct for this example as they're separate to the main issue here, and the solution I used just obfuscates the code for the diagrams, and is therefore inappropriate for an MWE. The way I've chosen to call the different packages in the preamble resolves the issue I reported earlier of clashing packages, while still loading the same packages and settings.
\documentclass{article}
\usepackage{chemmacros}
\chemsetup{formula=mhchem,modules=newman} % Loads mhchem package and newman module
\begin{document}
\begin{figure}
\centering
\caption{Newman projections of the four butane conformational isomers.}
\newman{\hspace*{3mm} \ce{CH3},H,H,\hspace*{3mm} \ce{CH3},H,H}
\newman(73){\hspace*{3mm} \ce{CH3},H,H,\ce{CH3},H,H}
\newman(120){\hspace*{3mm} \ce{CH3},H,H,\ce{CH3},H,H}
\newman(193){\hspace*{3mm} \ce{CH3},H,H,\ce{H3C} \hspace*{3mm},H,H}
\end{figure}
\end{document}
Best Answer
The answer depends a bit on what you actually need. If all your formulae are as simple as AgBr or FeO there is no need for any package and you can just type them as they are. If you want some macro for marking the formulae in your source something like
would suffice. Or - if you plan to use it in math mode, too -
The second version would even allow you to typeset formulae like AlBr3 and even simple reaction equations:
Only if you need more complicated features or if you have to type a lot of those formulae and not just some ten or twenty then one of the chemistry packages will start to bring you benefits. There are two packages to consider:
mhchem
chemformula
The differences between both of them are