Math & Sciencemultiple newcommands with matrices inside equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
kaltsoplyn
Posts: 3
Joined: Tue Jul 20, 2010 2:53 am

multiple newcommands with matrices inside equation

Post by kaltsoplyn »

Hello all,

I'm writing a thesis in physics. I need to use the, so called, 3-J, 6-J and 9-J symbols (please feel free to google). Instead of typing in matrices in every equation, I define these commands for the 3-J, 6-J and 9-J symbols, respectively:

Code: Select all

\newcommand{\tj}[9]{ \begin{pmatrix}
  #1 & #2 & #3 \\
  #4 & #5 & #6 
 \end{pmatrix}}

\newcommand{\Gj}[6]{ \begin{Bmatrix}
  #1 & #2 & #3 \\
  #4 & #5 & #6 
 \end{Bmatrix}}

\newcommand{\gj}[9]{ \begin{Bmatrix}
  #1 & #2 & #3 \\
  #4 & #5 & #6 \\
  #7 & #8 & #9
 \end{Bmatrix}}
Each one is working fine on its own inside an equation environment. However, when two of them are present in the same equation, I get an error (unless it is the same command twice).
For example, this does not work:

Code: Select all

\begin{equation}
    \gj{1}{2}{3}{4}{5}{6}{7}{8}{9} \tj{1}{2}{3}{4}{5}{6}
\end{equation}
Any ideas?
Last edited by kaltsoplyn on Tue Jul 20, 2010 6:37 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

multiple newcommands with matrices inside equation

Post by gmedina »

Hi,

there's an inconsistency in the definition of \tj; you declare nine arguments but you are using only six in the definition. Changing

Code: Select all

\newcommand{\tj}[9]{ \begin{pmatrix}
  #1 & #2 & #3 \\
  #4 & #5 & #6 
\end{pmatrix}}
to

Code: Select all

\newcommand{\tj}[6]{ \begin{pmatrix}
  #1 & #2 & #3 \\
  #4 & #5 & #6 
\end{pmatrix}}
solves the problem with the code you provided.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
kaltsoplyn
Posts: 3
Joined: Tue Jul 20, 2010 2:53 am

Re: multiple newcommands with matrices inside equation

Post by kaltsoplyn »

hahaha, wasn't this a genuine sample of pure stupidity or what?!? :D
Poor me, I want to write a thesis in physics, too?
who am I kidding? maybe I should become a surgeon instead...

Anyway, thanks for wasting your time on me. Your answer, obviously, solved the problem.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

multiple newcommands with matrices inside equation

Post by localghost »

Now that the problem is solved, please mark the topic as accordingly as described in Section 3 of the Board Rules.


Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply