Instead of writting very long lines to create complex equations it would be great to use variables to substitute smaller chunks...

A simple example:

\frac{ \sqrt{ \mu(i)^{ \frac{3}{2}} (i^{2} -1) } }
{ \sqrt[3]{\rho(i) - 2} + \sqrt[3]{\rho(i) - 1} }

It would be done something like this:

A = \sqrt{ \mu(i)^{ \frac{3}{2}} (i^{2} -1) }
B = \sqrt[3]{\rho(i) - 2} 
C = \sqrt[3]{\rho(i) - 1} 
\frac{ A } { B + C }

And the result would be the same but the code easier to read with more complex examples.

How can I define easily these substitutions or parameters? or using any specialized package?

PD: there are other questions at Tex.StackExchange asking how to split an equation in several lines, but this is not the same.


You sure can, because TeX is a macro expansion language:

\newcommand\cA{\sqrt{ \mu(i)^{ \frac{3}{2}} (i^{2} -1) }}
\newcommand\cB{\sqrt[3]{\rho(i) - 2}}
\newcommand\cC{\sqrt[3]{\rho(i) - 1}}
\frac{ \cA } { \cB + \cC }

I prefer using a prefix for the “chunks” in order not to clobber already defined macros (you'd be warned anyway, because of \newcommand).

Since \[...\] forms a group, those macros will become undefined at the end of the display.

A different option, with math active characters (but more risky):


  % #1 is a letter, #2 the replacement text



\chunk{A}{\sqrt{ \mu(i)^{ \frac{3}{2}} (i^{2} -1) }}
\chunk{B}{\sqrt[3]{\rho(i) - 2}}
\chunk{C}{\sqrt[3]{\rho(i) - 1}}
\frac{ A } { B + C }

\begin{abbrev}% defining \chunk in align wouldn't work
x &= A\\
y &= B


enter image description here

  • Thanks. I didn't thought "newcommand" was used here because I don't want to define a "new command". I'll try. Any other option? – skan Sep 25 '15 at 11:03
  • @skan Do you like the addition? – egreg Sep 25 '15 at 11:13
  • Yes, thanks, I won't even wait for other replies. I prefer the first answer, the second one makes it much more complex unnecessarily. When I said a different approach I meant different commands or maybe an specialized package. – skan Sep 25 '15 at 11:39

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.