这行代码有什么问题?

这行代码有什么问题?

我有此代码但无法编译。这是怎么回事?

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

相关内容