MATLAB: How to align TeX equations when using the publish functionality of the MATLAB Editor

MATLAB

I would like to align the = and the minus sign in 
k = a +b
  – c+d
so that they are below each other in TeX/LaTeX formatted comments when using the publish functionality of the MATLAB Editor.

Best Answer

In order to obtain the alignment you would like to have, please use the following code:
%%
% $$

% \begin{array}{cl}
% k&=a+b\\
% &+c+d\end{array}
% $$
Note that using LaTeX commands from the amsmath package like eqnarray or equation are not supported by the "publish" function.