I am using latex to write a mathematically dense document which has several hundred differential forms and products. There must be better ways than just typing out the whole equations line by line. Can any body suggest me some better productivity techniques which could reduce some of the work of debugging some of the equations.

I am pasting a part of equations which I have to write.

    Energy^{(i)} & =   U^{(i)}_{1} + U^{(i)}_{2} + U^{(i)}_{3}\\
    U^{(1)}_{1} & =  \int_{a}^{b} \int_{0}^{\sigma_{rr}^{(1)}} \Big(\frac{(1+\nu)(\sigma_{rr}^{(1)})}{E1} - \frac{\nu (2(\sigma_{rr}^{(1)})+ \sigma_{z})}{E1} \Big) d(\sigma_{rr}^{(1)}) r dr dz \\
    U^{(1)}_{2} & = \int_{a}^{b} \int_{0}^{\sigma_{rz}^{(1)}} (1+\nu)\frac{(\sigma_{rz}^{(1)})}{E1} d(\sigma_{rz}^{(1)}) r dr dz \\
    U^{(1)}_{3} & =  \int_{a}^{b} \int_{0}^{\sigma_{zz}^{(1)}} \Big(\frac{(1+\nu)\sigma_{zz}^{(1)}}{2E1} -  \frac{\nu ((\sigma_{zz}^{(1)})+ 2\sigma_{rr}^{(1)})}{2 E1} \Big) d(\sigma_{zz}^{(1)}) r dr dz \\
    % End of 1
    U^{(2)}_{1} & =  \int_{b}^{c} \int_{0}^{\sigma_{rr}^{(2)}} \Big(\frac{(1+\nu)(\sigma_{rr}^{(2)})}{E2} - \frac{\nu (2(\sigma_{rr}^{(2)})+ \sigma_{z})}{E2} \Big) d(\sigma_{rr}^{(2)}) r dr dz \\
    U^{(2)}_{2} & = \int_{b}^{c} \int_{0}^{\sigma_{rz}^{(2)}} (1+\nu)\frac{(\sigma_{rz}^{(2)})}{E2} d(\sigma_{rz}^{(2)}) r dr dz \\
    U^{(2)}_{3} & =  \int_{b}^{c} \int_{0}^{\sigma_{zz}^{(2)}} \Big(\frac{(1+\nu)\sigma_{zz}^{(2)}}{2E2} -  \frac{\nu ((\sigma_{zz}^{(2)})+ 2\sigma_{rr}^{(2)})}{2 E2} \Big) d(\sigma_{zz}^{(2)}) r dr dz \\
    % End of 2
    U^{(3)}_{1} & =  \int_{c}^{d} \int_{0}^{\sigma_{rr}^{(3)}} \Big(\frac{(1+\nu)(\sigma_{rr}^{(3)})}{E3} - \frac{\nu (2(\sigma_{rr}^{(3)})+ \sigma_{z})}{E3} \Big) d(\sigma_{rr}^{(3)}) r dr dz \\
    U^{(3)}_{2} & = \int_{c}^{d} \int_{0}^{\sigma_{rz}^{(3)}} (1+\nu)\frac{(\sigma_{rz}^{(3)})}{E3} d(\sigma_{rz}^{(3)}) r dr dz \\
    U^{(3)}_{3} & =  \int_{c}^{d} \int_{0}^{\sigma_{zz}^{(3)}} \Big(\frac{(1+\nu)\sigma_{zz}^{(3)}}{2E3} -  \frac{\nu ((\sigma_{zz}^{(3)})+ 2\sigma_{rr}^{(3)})}{2 E3} \Big) d(\sigma_{zz}^{(3)}) r dr dz \\
    % End of 3
  • 1
    Equations look similar. Copy-And-Paste would be my preferred method here to reduce typing work. I would try to get the first equation into a satisfactory state, then do a Copy-And-Paste, which is followed by modifying the copy.
    – AlexG
    Jan 29, 2016 at 15:17
  • possibly helpful? tex.stackexchange.com/questions/44206/…
    – cmhughes
    Jan 29, 2016 at 15:29
  • 1
    Have a look at TexStudio's multicursor selection technics, it allows you to edit multiple equations at once. Jan 29, 2016 at 15:39

2 Answers 2


I would define some macros to handle the parts of the code that don't change.

Here's an example of something you can do:



%% user macro translated into internal control sequence
%% to test whether short or long form.
%% short form is flagged by a `*` immediately following
%% the control sequence.

%% There are three different forms the integral can take in the        
%% long form.  By testing on the first argument, we can determine      
%% which integral form to use.  This could have been handled using     
%% \ifcase.  I chose not to use \ifcase because it only works          
%% on numbers.  If you have integrals somehow indexed by some of token 
%% then this approach *should* work.                                   

%% #1 superscript (<num>)
%% #2 lower bound of integration
%% #3 upper bound of integration
\def\ae@intUa#1#2#3{  \int_{#2}^{#3} \int_{0}^{\sigma_{rr}^{(#1)}} \Big(\frac{(1+\nu)(\sigma_{rr}^{(#1)})}{E#1} - \frac{\nu (2(\sigma_{rr}^{(#1)})+ \sigma_{z})}{E#1} \Big) d(\sigma_{rr}^{(#1)}) r dr dz }
\def\ae@intUb#1#2#3{  \int_{#2}^{#3} \int_{0}^{\sigma_{rz}^{(#1)}} (1+\nu)\frac{(\sigma_{rz}^{(#1)})}{E#1} d(\sigma_{rz}^{(#1)}) r dr dz  }
\def\ae@intUc#1#2#3{  \int_{#2}^{#3} \int_{0}^{\sigma_{zz}^{(#1)}} \Big(\frac{(1+\nu)\sigma_{zz}^{(#1)}}{2E#1} -  \frac{\nu ((\sigma_{zz}^{(#1)})+ 2\sigma_{rr}^{(#1)})}{2 E#1} \Big) d(\sigma_{zz}^{(#1)}) r dr dz }



    Energy^{(i)} & =  \intU*1(i) + \intU*2(i) + \intU*3(i) \\
    \intU*1(1)   & = \intU1(1)_{a}^{b}                     \\
    \intU*2(1)   & = \intU2(1)_{a}^{b}                     \\
    \intU*3(1)   & = \intU3(1)_{a}^{b}                     \\
    % End of 1
    \intU*1(2)   & = \intU1(2)_{b}^{c}                     \\
    \intU*2(2)   & = \intU2(2)_{b}^{c}                     \\
    \intU*3(2)   & = \intU3(2)_{b}^{c}                     \\


enter image description here

Since the integrands change and I don't really know what all of this is about, there could be a better way to write this, but I think the above example conveys the general idea.

I'm using a few TeX tricks here. At a minimum I'm trying to let the syntax of command sequence match what's needed: the superscripting with (<num>) and the bounds of integration.

  • 8
    When people ask why TeX was designed as a macro-expansion language, this is why. Jan 29, 2016 at 16:18
  • 8
    Great answer. Math nits: thin spaces in r \, dr \, dz (or \mathrm{d} if you prefer); proper kerning in \mathit{Energy} or \mathrm{Energy} or just E. And you probably want subscripts on E_1 and friends, even though the OP was missing these as well.
    – wchargin
    Jan 29, 2016 at 20:16

I've found the mathpix is great for boosting latex productivity as it enables you to derive latex from an image and then that can be used as a template for further copy/pasting.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .