我有這段程式碼,但它無法編譯。它有什麼問題嗎?
%% AMS-LaTeX Created with the Wolfram Language : www.wolfram.com
\documentclass{article}
\usepackage{amsmath, amssymb, graphics, setspace}
\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}
\newcounter{mathematicapage}
\begin{document}
<<\text{Units$\grave{ }$}\\
\text{ppgfttoPSI}=0.0519481;
Dado PI e PO, rint e rext, faz o c{\' a}lculo da tens{\~ a}o radial e tangencial
\text{ComputeRadialAndTangetialStress}[\text{r$\_$},\text{ri$\_$},\text{re$\_$},\text{PI$\_$},\text{PO$\_$}]\text{:=}\text{Block}[\{\text{sigr},\text{sigtheta}\},\\
\text{sigr}=(\text{PI} (r{}^{\wedge}2-\text{re}{}^{\wedge}2) \text{ri}{}^{\wedge}2+\text{PO} \text{re}{}^{\wedge}2 (-r{}^{\wedge}2+\text{ri}{}^{\wedge}2))/(r{}^{\wedge}2
(\text{re}{}^{\wedge}2-\text{ri}{}^{\wedge}2));\\
\text{sigtheta}=(\text{PI}(r{}^{\wedge}2+\text{re}{}^{\wedge}2) \text{ri}{}^{\wedge}2-\text{PO} \text{re}{}^{\wedge}2 (r{}^{\wedge}2+\text{ri}{}^{\wedge}2))/(r{}^{\wedge}2
(\text{re}{}^{\wedge}2-\text{ri}{}^{\wedge}2));\\
\{\text{sigr},\text{sigtheta}\}\text{//}N\\
];
\end{document}
答案1
如果不從頭開始重寫,就很難改進如此糟糕的程式碼。即使在適當的位置添加也$
不會產生與排版輸出真正相似的結果,而只是彼此相鄰的字母和符號,沒有任何理解代碼的線索。
$<<\text{Units$\grave{ }$}\\
\text{ppgfttoPSI}=0.0519481;$
Dado PI e PO, rint e rext, faz o c{\' a}lculo da tens{\~ a}o radial e tangencial
$\text{ComputeRadialAndTangetialStress}[\text{r$\_$},\text{ri$\_$},\text{re$\_$},\text{PI$\_$},\t$
\text{sigr}=(\text{PI} (r{}^{\wedge}2-\text{re}{}^{\wedge}2) \text{ri}{}^{\wedge}2+\text{PO} \tex$
(\text{re}{}^{\wedge}2-\text{ri}{}^{\wedge}2));\\
\text{sigtheta}=(\text{PI}(r{}^{\wedge}2+\text{re}{}^{\wedge}2) \text{ri}{}^{\wedge}2-\text{PO} \$
(\text{re}{}^{\wedge}2-\text{ri}{}^{\wedge}2));\\
\{\text{sigr},\text{sigtheta}\}\text{//}N\\
];$
就像是
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{verbatim}
<<Units`
ppgfttoPSI=0.0519481;
Dado PI e PO, rint e rext, faz o cálculo
da tensão radial e tangencial
ComputeRadialAndTangetialStress}[r_,ri_,re_,PI_,PO_]:=
Block[{sigr,sigtheta},
sigr=PI(r^2-re^2) ri^2+PO re^2 (-r^2+ri^2))/(r^2(re^2-ri^2));
sigtheta=(PI(r^2+re^2) ri^2-PO re^2 (r^2+ri^2))/(r^2(re^2-ri^2));
{sigr,sigtheta}//N
];
\end{verbatim}
\end{document}
複製和貼上可能會更好,甚至更簡單。
答案2
這個 tex 程式碼仍然很差,但是運行沒有錯誤,並且可能是手動修正生成的程式碼的開始。
\documentclass{article}
\usepackage{amsmath, amssymb, graphics, setspace}
\usepackage[T1]{fontenc}
\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}
\newcounter{mathematicapage}
\begin{document}
<<\text{Units$\grave{ }$}\\
\text{ppgfttoPSI}=0.0519481;
Dado PI e PO, rint e rext, faz o c\'{a}lculo da tens\~{a}o radial e tangencial
\begin{multline}
\text{ComputeRadialAndTangetialStress}[\text{r$\_$},\text{ri$\_$},\text{re$\_$},\text{PI$\_$},\text{PO$\_$}]\text{:=}\\
\text{Block}[\{\text{sigr},\text{sigtheta}\},\\
\text{sigr}=(\text{PI} (r{}^{\wedge}2-\text{re}{}^{\wedge}2) \text{ri}{}^{\wedge}2+\text{PO} \text{re}{}^{\wedge}2 (-r{}^{\wedge}2+\text{ri}{}^{\wedge}2))/(r{}^{\wedge}2
(\text{re}{}^{\wedge}2-\text{ri}{}^{\wedge}2));\\
\text{sigtheta}=(\text{PI}(r{}^{\wedge}2+\text{re}{}^{\wedge}2) \text{ri}{}^{\wedge}2-\text{PO} \text{re}{}^{\wedge}2 (r{}^{\wedge}2+\text{ri}{}^{\wedge}2))/(r{}^{\wedge}2
(\text{re}{}^{\wedge}2-\text{ri}{}^{\wedge}2));\\
\{\text{sigr},\text{sigtheta}\}\text{//}N\\
];
\end{multline}
\end{document}