TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm trying to make my own command to make matrices less painful

My current command is:


with the intention to use it as:


producing the same thing as

1 & 0 \\
0 & 1

But I keep getting the message "Missing } inserted." I think it doesn't like the \\ in the command argument.

Any suggestions?

Edit: Fixed it. Removed the brace group from the macro

share|improve this question
See the tabstackengine package. It does this already. Either \tabularCenterstack or \parenMatrixstack should do the trick. See tex.stackexchange.com/questions/139771/…, and tex.stackexchange.com/questions/148669/… – Steven B. Segletes Mar 5 '14 at 2:07
Thanks, but I'm also just curious as to why this isn't working – sicklybeans Mar 5 '14 at 2:10
This may very well not be the problem, but I really don't think you should wrap #2 in a brace group. (And welcome to TeX.SX!) I don't think \\ likes being in a brace group. – Sean Allred Mar 5 '14 at 2:34
thank you. Getting rid of the brace group fixed the problem! – sicklybeans Mar 5 '14 at 2:36
A general view of matrix construction is available in Where is the \matrix command? – Werner Mar 5 '14 at 17:07

Remove the spurious braces in your definition:

\[ \mat{c}{2\\3} \]

Why is this necessary?

Brace groups are kind of a special thing in TeX (take a look at TeX by Topic for detailed information; run texdoc texbytopic in your terminal). When you put something in a brace group, you are asking TeX to process it as a unit. The problem is, with array there are many things that need to be dealt with as individual units inside, such as rows. (The real reason actually has to do with things like 'vertical mode' and 'horizontal mode', but the above explanation will hold for many other things.)

share|improve this answer
But this approach still will not work with alignment tabs (&) though, or am I missing something? – Steven B. Segletes Mar 5 '14 at 3:06
@StevenB.Segletes it does work. – azetina Mar 5 '14 at 3:22
@StevenB.Segletes The real problem is that TeX is switching from horizontal mode into vertical mode when it encounters the break—this can't really be done in a brace group to the best of my understanding. The alignment character doesn't switch modes, so it's alright. – Sean Allred Mar 5 '14 at 5:58

The tabstackengine package does this already, as I mentioned in my comment. The first form gives the parens with the stack, but all columns must be of the same alignment. The second form needs the parens added separately, but allows each column to have its own alignment.

The examples below are not pretty, but are merely meant to demonstrate these alignment variations.

\parskip 1ex
$\parenMatrixstack[r]{1 & 23 \\34 & 1}$\par
$\left(\tabularCenterstack{lc}{1 & 23 \\34 & 1} \right)$

enter image description here

share|improve this answer
If possible though, I'd like to be able to do it using vanilla latex. Making my own macros is about getting better at latex as much as it is about anything else – sicklybeans Mar 5 '14 at 2:22
@sicklybeans Understood. Best wishes. Welcome to the site. – Steven B. Segletes Mar 5 '14 at 2:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.