# How to change horizontal spacing in arrays?

$$\begin{array}{lcr} & \text{A} & \\[-0.1cm] & | & \\[-0.1cm] \text{C} & \text{B} & \text{D} \\[-0.1cm] & | & \\[-0.1cm] & \text{E} & \\ \end{array}$$ How do I edit the spacing between $\text{C}$ and $\text{B}$ (as well as $\text{B}$ and $\text{D}$)? In $\LaTeX$, one can do it by following this, but it does not work for MathJax. Any ideas on how to edit the array horizontal spacing?

## 2 Answers

This method feels kinda "hacky," but you could use LaTeX math mode spacing commands like \,, \:, \;, \enspace, \quad or \qquad within the cells of the array. Right click on the diagram below and select Show Math As -> TeX Commands to see what I mean.

\begin{array}{lcr} & \text{A} & \\[-0.1cm] & | & \\[-0.1cm] \text{C}\quad & \text{B} & \quad\text{D} \\[-0.1cm] & | & \\[-0.1cm] & \text{E} & \\ \end{array}

But of course this would be a burden to do manually for larger arrays.

• What about in case you want to shorten the spacing? – Siddharth Venu Jan 24 '18 at 18:58
• @SiddharthVenu there's another spacing command \! that creates a negative thin space. But it's pretty thin. You'd have to add a bunch of those to get any dramatic effect. – Mike Pierce Jan 24 '18 at 18:59
• I guess I will have to use it even though it is clumsy. Thank you! – Siddharth Venu Jan 24 '18 at 19:02
• Another "clumsy" technique is to create alternating array entries with "phantom" characters with specified horizontal and/or vertical spacing. See How do I create an invisible character? These work for me in MathJax. – hardmath Jan 25 '18 at 15:38

An easier way to do this is to use \hspace as follows:

\begin{array}{lcr}
& \text{A} & \\[-0.1cm]
& | & \\[-0.1cm]
\text{C} \hspace{0.9cm}& \text{B} &\hspace{0.9cm} \text{D} \\[-0.1cm]
& | & \\[-0.1cm]
& \text{E} & \\
\end{array}
`

gives

\begin{array}{lcr} & \text{A} & \\[-0.1cm] & | & \\[-0.1cm] \text{C} \hspace{0.9cm}& \text{B} &\hspace{0.9cm} \text{D} \\[-0.1cm] & | & \\[-0.1cm] & \text{E} & \\ \end{array}