我正在使用 latex 编写一个数学密集的文档,其中包含数百个微分形式和乘积。一定有比逐行输入整个方程式更好的方法。有人能给我推荐一些更好的生产力技巧吗,可以减少调试某些方程式的工作量。
我正在粘贴我必须写的一部分方程式。
\begin{equation}
\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}
\end{equation}
答案1
我会定义一些宏来处理代码中不会改变的部分。
以下是您可以执行的操作的示例:
\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{equation}
\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{equation}
\end{document}
由于被积函数发生了变化,而且我不太清楚这一切是怎么回事,所以可能有更好的方法来写这个,但我认为上面的例子传达了一般的想法。
我在这里使用了一些 TeX 技巧。至少我尝试让命令序列的语法符合需要:上标(<num>)
和积分的界限。
答案2
我发现 mathpix 非常适合提高乳胶的生产效率,因为它可以让你从图像中获取乳胶,然后可以将其用作进一步复制/粘贴的模板。