# How can I make an array with all columns as wide as the widest one?

For example, let's say I wanted to make this diagram of a board in the game 2048:

$$\begin{array}{|r|r|} \hline 1024 & \color{white}{0}512 & \color{white}{00}16 & \color{white}{000}2 \\ \hline 2 & 2 & 4 & 2 \\ \end{array} \\ \text{(etc.)}$$

Here's the source for the first row:

1024 & \color{white}{0}512 & \color{white}{00}16 & \color{white}{000}2 \\


As you can see, it's very hacky, and coloring the zeroes white isn't the best solution since it won't work on sites with different backgrounds. (It's also extremely limited, and only works for purely numbers in the cells.)

Is there any way I could make these columns the same width, without having to add ugly invisible zeroes?

• You can use \phantom to make white space of a particular width, but it's not much less hacky than what you've done already. – Peter Phipps May 21 '14 at 13:06
• \phantom{whatever} is a better hack than \color{white}{whatever}. Imagine you highlight the text. – user1551 May 21 '14 at 13:56
• I know TeX lets you specify a template for each column; if that is supported here you could use \hphantom{0000} as the template. But I don't know if it is supported here. – MJD May 21 '14 at 20:16
• Interesting question. This is hard in TeX but trivial in MathML -- <mtable> comes with an equalcolumns attribute. You could file a feature request at MathJax's github tracker; not sure how we'd integrate it but it seems an interesting question. – Peter Krautzberger May 23 '14 at 13:10