Background:
I would like to improve my matlab function mat2lat(A):
https://github.com/KasparJohannesSchneider/mat2lat/issues/1
Problem:
For complex matrices, the alignment mode {c} doesn't look very good because the + and - signs in between the real and the imaginary part are not aligned, see screenshot below.
Because the LaTex code is created programmatically, it wouldn't be a problem to just create a separate column for the sign, however, this results in a weird-looking space to the left and right of this column, see "Ugly workaround" below.
Question:
First of all, I would strongly prefer not to include any packages other than \usepackage{amsmath}.
What is the best solution for displaying complex matrices in LaTex?
Minimal Working Example:
\documentclass[11pt, titlepage, oneside, a4paper]{article}
\usepackage{amsmath}
\begin{document}
\textbf{Works for real matrices:}
$$\left[\begin{array}{ccc}
{64+2.828i} & {1+1i} & {36+2.449i} \\
{9+1.732i} & {25+2.236i} & {49+2.646i} \\
{16+2i} & {81+3i} & {4+1.414i}
\end{array}\right]$$
\textbf{Ugly workaround:}
$$\left[\begin{array}{rclcrclcrcl}
64&+&2.828i && 1&+&1i && 36&+&2.449i \\
9&+&1.732i && 25&+&2.236i && 49&+&2.646i \\
16&+&2i && 81&+&3i && 4&+&1.414i
\end{array}\right]$$
\end{document}




$$...$$for the Minimal Working Example, usually, I use\begin{equation}...\end{equation}.arraypackage you can attach an empty group before and after theccolumn in order to get the correct spacing. It's not per se more elegant but it wouldn't require knowledge of which\XXXmuskipyou need. And you are absolutely right with your third comment: accepting the answer right away discourages others from posting alternatives, I believe. – campa Oct 21 '19 at 15:06