1

I got a few commands that are nested, two of which work, but the last one does not.

\newcommand{\trine}[3]
{
    {#1} \times {#2} \times {#3}
}
\newcommand{\MchainSub}[9]
{
    k &= {#2} &\to M[{#1},{#2}] &+& M[{#3},{#4}] &+& {#5} \\[-1em]
      &       &    {#6} &+& {#7} &+& {#8} &=& {#9}\\
}
\newcommand{\Mchain}[2]
{
    \begin{aligned}
        \begin{aligned}
            {#1}
        \end{aligned} &=\left\{
        \begin{aligned}
            {#2}
        \end{aligned} \right.
    \end{aligned}
}

Does not work:

\[
\begin{array}{l}
    \Mchain{
        M[i, j] \\[-1em]
        A, k=i
    }{
        \MchainSub{i}{k}{l}{j}{ \trine{a}{b}{c} }{x}{y}{z}{w}
        \MchainSub{i}{k}{l}{j}{ \trine{a}{b}{c} }{x}{y}{z}{w}
    } %<- here is error
\end{array}
\]

Does work:

\[
\begin{array}{l}
    \begin{aligned}
    \begin{aligned}
        M[i, j] \\[-1em]
        A, k=i
    \end{aligned} &=\left\{
    \begin{aligned}
        \MchainSub{i}{k}{l}{j}{ \trine{a}{b}{c} }{x}{y}{z}{w}
        \MchainSub{i}{k}{l}{j}{ \trine{a}{b}{c} }{x}{y}{z}{w}
    \end{aligned} \right.
    \end{aligned}
\end{array}
\]

enter image description here

Why does the first one not work? Since I will be repeating the \Mchain with the nested \MchainSub's and \trine's many times my macro method would be far faster to work with.

I keep on getting eror missing }. missing { ...

  • unrelated to the error but are you sure you want &=& and &+& etc in an aligned you haven't provided a usable example so I haven't seen the output but I would assume this makes rather odd spacing: alignment cells are aligned alternately left and right. – David Carlisle Dec 14 '17 at 1:07
  • I added an image to show you what It comes out as. And since I am doing about 25 more of these, with more than 2 nested \MchainSubs, doing a macro is necessary. – Drew Dec 14 '17 at 1:09
2

you have {#2} with unwanted braces so after #2 is \MchainSub which inserts & you end up with { in the first cell and } in the last which is an error.

You should probably remove all the braces around your #2 etc, as even when not generating errors, extra braces in math mode affect the spacing.

  • Well, I feel dumb, my habit of wrapping all my args like that just bit me in the ass. Thanks though. – Drew Dec 14 '17 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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