3

I am trying to make a document and using \mathrm inside an align* environment. But it doesn't works, any help?

Here I paste a ME (it doesn't work but it is complete)

\documentclass[12pt,twoside]{report}
\usepackage{booktabs}
\usepackage[headheight=18pt,a4paper, width=150mm, top=25mm, bottom=25mm, bindingoffset=6mm, headsep=18pt]{geometry}
%aca utilizo la geometría de la hoja 
\usepackage[spanish,es-noquoting]{babel}
%interprete de idioma castellano
\usepackage[utf8]{inputenc} %relacionado al input
\usepackage[T1]{fontenc} 
\usepackage{enumitem} 
\begin{align*}
{\mathrm{pH}}={\mathrm{p}}K_{{\mathrm{a}}}+\log _{{10}}\left({\frac  {[{\mathrm{A}}]}{[{\mathrm{HA}^{+}}]}}\right)\\
\intertext{Para un pKa de 14.0, correspondiende a la guanidina sustituida}
{\mathrm{\num2.5e-7}}=\frac{[{\mathrm{A}}]}{[{\mathrm{HA}^{+}}]}\\
\intertext{Para 9.5 del cis dihidro dihidroxi imidazol}
{\mathrm{\num0.01}}=\frac{[{\mathrm{A}}]}{[{\mathrm{HA}^{+}}]}\\
\intertext{Para 6.2 del trans dihidro dihidroxi imidazol}
{\mathrm{\num15.85}}=\frac{[{\mathrm{A}}]}{[{\mathrm{HA}^{+}}]}\\
\end{align*}
  • 1
    There are three things missing here: 1) a document environment. 2) the amsmath package (which defines align). 2) the siunitx package (which defines \num) – Torbjørn T. Sep 27 '17 at 9:23
  • At the least you have too many braces. – egreg Sep 27 '17 at 9:25
  • yeah as I am almost a beginner with latex I make all kind of errors. @egreg – user134500 Sep 27 '17 at 9:26
  • @TorbjørnT. fixed with advice numer 2). Thanks! if you want answer or I can remove the question. – user134500 Sep 27 '17 at 9:27
  • Why are all those variables upright anyway? (just asking) – daleif Sep 27 '17 at 9:34
5

I don't think you need align and \intertext: the equations are mostly independent from each other.

\documentclass[12pt,twoside]{report}
\usepackage[
  a4paper,
  width=150mm,
  top=25mm,
  bottom=25mm,
  heightrounded,
  bindingoffset=6mm,
  headheight=18pt,
  headsep=18pt,
]{geometry}

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} %relacionado al input
\usepackage[spanish,es-noquoting]{babel}

\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{siunitx}
\usepackage{chemformula}

\newcommand{\pH}{\ensuremath{\mathrm{pH}}}
\newcommand{\pKa}{\ensuremath{\mathrm{p}K_{\mathrm{a}}}}

\begin{document}

\begin{equation*}
\pH = \pKa + \log_{10}\left(\frac{[\ch{A}]}{[\ch{HA+}]}\right)
\end{equation*}
Para un \pKa{} de \num{14.0}, correspondiende a la guanidina sustituida
\begin{equation*}
\num{2.5e-7}=\frac{[\ch{A}]}{[\ch{HA+}]}
\end{equation*}
Para \num{9.5} del cis dihidro dihidroxi imidazol
\begin{equation*}
\num{0.01}=\frac{[\ch{A}]}{[\ch{HA+}]}
\end{equation*}
Para \num{6.2} del trans dihidro dihidroxi imidazol
\begin{equation*}
\num{15.85}=\frac{[\ch{A}]}{[\ch{HA+}]}
\end{equation*}

\end{document}

Note how \ch makes it easier to input chemical formulas; I added definitions for \pH and \pKa so as to further simplify the input.

You were using \num wrongly.

enter image description here

Side note

Some might be surprised by my usage of \ensuremath in \pH and \pKa in comparison with my answer to When not to use \ensuremath for math macro?

Why do I deem it right here? The reason is simple. Neither macro is for mathematical text: the two symbols usually appear in text, but they can also appear in math. Using \ensuremath in the definition ensures uniform printing of these symbols that shouldn't change format depending on current conditions. Requiring $\pH$ if the symbol is in text would be unreasonable, because it is not math to begin with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy