我正在从 Mathematica 生成 LaTeX 代码,我必须将其插入到我的输入 .tex 文件中。问题是方程式太长,无法在页面上显示,而且拆分它们需要很长时间。有没有办法快速拆分这么长的方程式?
输入如下:
\left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5
\right)
+g_2 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5
\right){}^{\wedge}2
+g_3 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5
\right){}^{\wedge}3
+ g_4 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5\right){}^{\wedge}4
+g_5 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5\right){}^{\wedge}5
+g_6 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5\right){}^{\wedge}6
+g_7 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5\right){}^{\wedge}7
+g_8 \left(
\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+
\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5
\right){}^{\wedge}8
答案1
所有这些\left
使\right
公式不可拆分。如果您的公式都具有该格式,则可以这样做:
\documentclass{article}
\usepackage{lipsum} % just for the example
\newenvironment{mathematica}
{\begin{quote}%
% neutralize \left and \right
\def\left{}\def\right{}%
% add some space around operation signs
\medmuskip=4mu plus 2mu minus 2mu
% correct the horrible ^{\wedge}<exponent>
\def\wedge{\aftergroup{\aftergroup}\aftergroup^}%
$}
{$\end{quote}}
\begin{document}
\lipsum*[3]
\begin{mathematica}
\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+\epsilon
^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5\right)+g_2\left(\epsilon
^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi _4+\epsilon ^5 \phi
_5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi _5\right){}^{\wedge}2
+g_3\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3 +\epsilon ^4 \phi
_4+\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8 \phi
_5\right){}^{\wedge}3 + g_4\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi _3
+\epsilon ^4 \phi _4+\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8
\phi _5\right){}^{\wedge}4+g_5\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi
_3 +\epsilon ^4 \phi _4+\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8
\phi _5\right){}^{\wedge}5+g_6\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi
_3 +\epsilon ^4 \phi _4+\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8
\phi _5\right){}^{\wedge}6+g_7\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi
_3 +\epsilon ^4 \phi _4+\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8
\phi _5\right){}^{\wedge}7+g_8\left(\epsilon ^1 \phi _1+ \epsilon ^2 \phi _2 + \epsilon ^3 \phi
_3 +\epsilon ^4 \phi _4+\epsilon ^5 \phi _5+\epsilon ^6 \phi _5+\epsilon ^7 \phi _5+\epsilon ^8
\phi _5\right){}^{\wedge}8
\end{mathematica}
\lipsum[4]
\end{document}
答案2
这只是你问题的一个边缘问题,但请不要让你的读者也这么认为;我在解析你的数学表达式时差点睡着了。为什么不使用求和的方式,以更紧凑的形式来写呢?
\documentclass{article}
\usepackage{amssymb}
\begin{document}
\[
\left(
\sum_{j=1}^4 \epsilon^j \phi_j +
\left(
\sum_{k=5}^8 \epsilon^k
\right) \phi_5
\right)
+ \sum_{i=2}^8 g_i
\left(
\sum_{j=1}^4 \epsilon^j \phi_j +
\left(
\sum_{k=5}^8 \epsilon^k
\right) \phi_5
\right)^i
\]
\vspace{3em}
\noindent
Alternatively:
\[
x + \sum_{i=2}^8 g_i x^i \,,
\]
where
\[
x \triangleq
\sum_{j=1}^4 \epsilon^j \phi_j +
\left(
\sum_{k=5}^8 \epsilon^k
\right) \phi_5 \,.
\]
\end{document}