productivity tools

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.

\begin{aligned} 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 % \end{aligned}

-
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 at 15:17
possibly helpful? tex.stackexchange.com/questions/44206/… – cmhughes Jan 29 at 15:29
Have a look at TexStudio's multicursor selection technics, it allows you to edit multiple equations at once. – thewaywewalk Jan 29 at 15:39

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:

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter

%% user macro translated into internal control sequence
%% to test whether short or long form.
\newcommand\intU{\ae@intU}
%% short form is flagged by a * immediately following
%% the control sequence.
\def\ae@intU{%%
\@ifstar{\ae@intU@short}
{\ae@intU@long}}

\def\ae@intU@short#1(#2){U^{(#2)}_{#1}}
%% 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.
\def\ae@intU@long#1(#2)_#3^#4{%%
\if#11\ae@intUa{#2}{#3}{#4}\fi
\if#12\ae@intUb{#2}{#3}{#4}\fi
\if#13\ae@intUc{#2}{#3}{#4}\fi}

%% #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 }

\makeatother

\begin{document}

\begin{aligned} 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} \\ \end{aligned}

\end{document}


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.

-
When people ask why TeX was designed as a macro-expansion language, this is why. – Andrew Cashner Jan 29 at 16:18
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 at 20:16