If I understand you just want ~ in your mathematical expression. But as it is interpreted by LaTeX to set an unbreakable space, you must type something like this :
\[L \sim N(\mu ,{\sigma ^2})\]
The error occurs at the first \lim
right after \begin{alignat*}
. This environment expects an argument, the number of "equation columns". Since \lim
is not a number, TeX throws the error.
Unless you have redefined \(
and \)
, they will cause further trouble, because they are usually used for inline math mode. Therefore I have replaced them by normal parentheses. I do not think, that \left
and \right
are needed here despite the index of the limes. The normal parentheses look better here IMHO.
Full example (two LaTeX runs are needed):
\documentclass{article}
\usepackage{ifthen}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\newlength{\currentsidemargin}
\newlength{\argwidth}
\newlength{\whatsleft}
\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
\path
(current page.north west) ++(\hoffset, -\voffset)
node[
anchor=north west,
shape=rectangle,
inner sep=0,
minimum width=\paperwidth,
minimum height=\paperheight
] (pagearea) {}
;
\path
(pagearea.north west)
++(1in+\currentsidemargin,-1in-\topmargin-\headheight-\headsep)
node[
anchor=north west,
shape=rectangle,
inner sep=0,
minimum width=\textwidth,
minimum height=\textheight
] (textarea) {}
;
\path
let \p0 = (0,0),
\p1 = (textarea.east)
in
[/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}]
;
\end{tikzpicture}%
}
\newcommand{\cm}[1]{%
&\quad
&\hspace{1.3mm}%
\measureremainder{\whatsleft}%
\settowidth{\argwidth}{#1}%
\ifthenelse{\lengthtest{\argwidth < \whatsleft}}{%
\text{#1}
}{%
\begin{minipage}[c]{\whatsleft}
\raggedright
#1\par
\vspace{2mm}%
\end{minipage}%
}%
}
\begin{document}
\begin{alignat*}{2}
\lim_{x \to 3} (x^2 - 4x + 3) &= \lim_{x \to 3} x^2 - \lim_{x \to 3} 4x +
\lim_{x \to 3} 3 \cm{Using the sum rule} \\
&= (\lim_{x \to 3} x)
(\lim_{x \to 3} x)
- 4(\lim_{x \to 3} x) +
\lim_{x \to 3} 3 \cm{Using the product rule} \\
&= 3 \cdot 3 - 4 \cdot 3 + 3 \\
&= 0
\end{alignat*}
\end{document}

Best Answer
This is how you should be using it.
Note:
subfigure
is outdated and new one issubfig
which introducessubfloat
command. You may consider usingsubfig
instead ofsubfigure
.