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)

\usepackage[headheight=18pt,a4paper, width=150mm, top=25mm, bottom=25mm, bindingoffset=6mm, headsep=18pt]{geometry}
%aca utilizo la geometría de la hoja 
%interprete de idioma castellano
\usepackage[utf8]{inputenc} %relacionado al input
{\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}
\intertext{Para 9.5 del cis dihidro dihidroxi imidazol}
\intertext{Para 6.2 del trans dihidro dihidroxi imidazol}
  • 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

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


\usepackage[utf8]{inputenc} %relacionado al input




\pH = \pKa + \log_{10}\left(\frac{[\ch{A}]}{[\ch{HA+}]}\right)
Para un \pKa{} de \num{14.0}, correspondiende a la guanidina sustituida
Para \num{9.5} del cis dihidro dihidroxi imidazol
Para \num{6.2} del trans dihidro dihidroxi imidazol


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