# How do I align these equations by the first letter?

This code is only for use on stackexchange, it's not a document. Unsure of how to align these equations.

codereview.stackexchange only supports mathjaxx in $$..$$ format not $..$.

$$\lambda = \small{ \text{[m]} } \tiny{ \text{metres} }$$

$$\text{E} = \small{ \text{[J]} } \tiny{ \text{joules} }$$

$$\text{h} = \small{ \text{[J]} } \tiny{ \text{joules} }\cdot \small{ [\text{s}^{\tiny{-1}}] } \tiny{ \text{seconds} }$$

$$\text{c} = \small{ \text{[m]} } \tiny{ \text{metres} }\cdot \small{ [\text{s}^{\tiny{-1}}] } \tiny{ \text{seconds} }$$

$$N_A = \small{ [\text{mol}^{\tiny{-1}}] } \tiny{ \text{Avogadro's number} }$$

$$\text{c} = \small{ 299792600\ \text{m} \cdot \text{s}^{-1} }$$

$$N_A = \small{ 6.0221415\ \cdot\ 10^{23} }$$

$$\text{h} = \small{ 6.62607600\ \cdot\ 10^{-34}\ \text{J} \cdot \text{s}^{-1} }$$


It is not displaying here, maybe the site requires it in document format?

### Screenshot

• size commands like \small do not take an argument so \small xz not \small {xyz} and they may not be used in math mode. (note mathjax specific questions are off topic here) Jul 4, 2023 at 19:35
• use \begin{align} to align equations (it works in mathjax) Jul 4, 2023 at 19:37
• thanks @DavidCarlisle I'll try that, and sorry I thought this was for all latex type stuff Jul 4, 2023 at 19:55
• on stackexchange you have to use \small{} like a function with args Jul 4, 2023 at 19:56
• @DavidCarlisle I don't think I can align that way as the mathjaxx in stackexchange is started with $$..$$ rather than being a document, at least in the other stackexchanges. Jul 4, 2023 at 19:59

You can not use size commands in math, and they do not take an argument.

You want align* here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
\lambda &=
\mathrm{[m]}
_{\mathrm{metres}}
\\
\mathrm{E} &=
\mathrm{[J]}
_{\mathrm{joules}}
\\
\mathrm{h} &=
\mathrm{[J]}
_{\mathrm{joules}}
\cdot
[\mathrm{s}^{-1}]
_{\mathrm{seconds}}
\\
\mathrm{c} &=
\mathrm{[m]}
_{\mathrm{metres}}
\cdot
[\mathrm{s}^{-1}]
_{\mathrm{seconds}}
\\
N_A &=
[\mathrm{mol}^{-1}]
\\
\mathrm{c} &=
299792600
\mathrm{m} \cdot \mathrm{s}^{-1}
\\
N_A &=
6.0221415 \cdot 10^{23}
\\
\mathrm{h} &=
6.62607600 \cdot 10^{-34}
\mathrm{J} \cdot \mathrm{s}^{-1}
\end{align*}
\end{document}

• the reason I changed sizes is because of the formatting issues look at the \cdot with seconds, this is much cleaner, I'll write my mathjaxx like this, thank you. Very nice formatting I thought everyone just wrote the code in one line. Jul 4, 2023 at 20:10
• @Nickotine I don't understand the comment, but anyway they are a syntax error (mathjax only has one x) Jul 4, 2023 at 20:12
• look at how the variables in [] align with the text, and compare to my screenshot then look at h= and c= the \cdot doesn't align properly to seconds. Compare my screenshot to your output you'll see they're different. I was just complimenting you on how good and readable your code looks, usually examples I've seen have everything in one line with the $$..$$ syntax Jul 4, 2023 at 20:19
• well I just learned I'm not using real latex/mathjaxx (depending on which you wrote) much appreciated, can you help me out with the variable formatting problem I mentioned? Jul 4, 2023 at 20:20
• @Nickotine you are using mathjax, but mathjax is javascript not tex Jul 4, 2023 at 20:22