This question already has an answer here:

I am trying to create two new macros:

  • braces: compiles some text between curly brackets
  • squakets: compiles text between two square brackets

I defined as follows.



\newcommand{\squakets}[1]{$\Big[ #1 \Big]$}


\squakets{\squakets{\braces{$\sqrt{}$}{$\alpha$} \braces{$x$}{$\beta$}} \braces{$y$}{$\gamma$}} $\rightarrow$ \braces{$\sqrt{}$}{$\alpha$} -- \braces{$x$}{$\beta$} -- \braces{$y$}{$\gamma$}


Console still compiles, even though it warns me that:

Missing $ inserted.

I was curious of understanding how to fix this. I guess it is something related to the fact I am embedding multiple squakets command in one another, but can someone help figure that out?

marked as duplicate by Werner macros Jan 28 '18 at 4:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    I'd call the second macro squaces ;o) – Bernard Jan 28 '18 at 1:22
  • 3
    You are using the wrong approach here. What solves your problem is \ensuremath{..} rather than $..$. But still, if it's math, it should be in math mode, and not (ab)use \ensuremath. – Manuel Jan 28 '18 at 1:22
  • 2
    You cannot nest $...$. You should either change them to \ensuremath{} or, preferably, remove them. Then use your macro inside math mode only. – Phelype Oleinik Jan 28 '18 at 1:24
  • Why not use array instead of tabular? – Bernard Jan 28 '18 at 1:24
  • @Manuel And if it isn't maths .... – cfr Jan 28 '18 at 1:26




  \squakets{\squakets{\braces{\sqrt{}}{\alpha} \braces{x}{\beta}} \braces{y}{\gamma}}
  \braces{\sqrt{}}{\alpha} - \braces{x}{\beta} - \braces{y}{\gamma}

  • Thank you, @Manuel! However, your solution compiles something a bit different from what I had in mind. – RobertP. Jan 28 '18 at 3:05

Thank you for all of your help!

This is the solution I came up with:


As suggested in the comments above, \ensuremath{} instead of $...$ solves the issue.

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