在編寫高階偏導數時如何處理多個上標?

在編寫高階偏導數時如何處理多個上標?

我有一組偏微分方程,我正在嘗試輸入,其中某些高階項已經有上標。

我正在使用physicspackage 函數\pdv[n]{}{},這是我編寫的程式碼

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{physics}

\numberwithin{equation}{section}
\begin{document}

\newcommand\vt{v_{\theta}}
\newcommand\vr{v_{r}}
\newcommand\vx{v_{x}}
\newcommand\vts{v_{\theta}^{*}}
\newcommand\vrs{v_{r}^{*}}
\newcommand\vxs{v_{x}^{*}}
\newcommand\ts{t^{*}}
\newcommand\rs{r^{*}}
\newcommand\xs{x^{*}}

\section{Governing Equations}

\begin{multline}
\pdv{\vrs}{\ts}+\vrs\pdv{\vrs}{\rs}+\vts\frac{1}{\rs}\pdv{\vrs}{\ts}+\vxs\pdv{\vrs}{\xs}-\frac{\vt^{*^2}}{\rs}= \\ -\frac{1}{\rho}\pdv{p^{*}}{\rs}+\frac{1}{\mu}\left[\frac{1}{\rs}\pdv{\vrs}{\rs}+\pdv[2]{\vxs}{\rs}+\frac{1}{\rs}\pdv[2]{\vxs}{\theta}+\pdv[2]{\vxs}{\vxs}\right]
\end{multline}
\end{document}

當我嘗試編譯這個時,我收到一條錯誤訊息

 "! Double superscript.\l__deriv_p_denom_tl ...ariable:nn {pdv}{\xs }\sp{2} \end{multline} ".

如何解決這個問題?我相信這源自於高階偏微分方程項。

答案1

您需要的是花括號的一些策略性放置。

基本上,你不能只輸入a^b^cLaTeX,因為它無法理解整個b^c部分應該是上標。相反,您必須將其括在大括號中,如下所示:a^{b^c}

同樣的事情也發生在你的等式中——你只需要再撒上一些大括號。最簡單的解決方案是在每個\newcommand包含^.

\newcommand\vt{v_{\theta}}
\newcommand\vr{v_{r}}
\newcommand\vx{v_{x}}
\newcommand\vts{{v_{\theta}^{*}}} % extra {}
\newcommand\vrs{{v_{r}^{*}}}      % extra {}
\newcommand\vxs{{v_{x}^{*}}}      % extra {}
\newcommand\ts{{t^{*}}}           % extra {}
\newcommand\rs{{r^{*}}}           % extra {}
\newcommand\xs{{x^{*}}}           % extra {}

答案2

我追蹤問題如下:

當您定義newcommands 時,命令不是單一標記,因此如果存在另一個超級索引,則無法放置超級索引。

您需要在newcommands 定義中新增額外的大括號

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{physics}

\numberwithin{equation}{section}
\begin{document}

\newcommand\vt{{v_{\theta}}}
\newcommand\vr{{v_{r}}}
\newcommand\vx{{v_{x}}}
\newcommand\vts{{v_{\theta}^{*}}}
\newcommand\vrs{{v_{r}^{*}}}
\newcommand\vxs{{v_{x}^{*}}}
\newcommand\ts{{t^{*}}}
\newcommand\rs{{r^{*}}}
\newcommand\xs{{x^{*}}}

\section{Governing Equations}

\begin{multline}
\pdv{\vrs}{\ts}
+\vrs \pdv{\vrs}{\rs}
+\vts \frac{1}{\rs} \pdv{\vrs}{\ts}
+\vxs \pdv{\vrs}{\xs}
-\frac{\vt^{*2}}{\rs}= \\ 
-\frac{1}{\rho}\pdv{p^{*}}{\rs}+\frac{1}{\mu}\left[\frac{1}{\rs}\pdv{\vrs}{\rs}+\pdv[2]{\vxs}{\rs}+\frac{1}{\rs}\pdv[2]{\vxs}{\theta}+\pdv[2]{\vxs}{\vxs}\right]
\end{multline}
\end{document}

然後一切都會如預期進行。

相關內容