引用方程的“名称”,同时使用这些名称生成方程列表

引用方程的“名称”,同时使用这些名称生成方程列表

我在下面链接了两个问题,因为我使用它们的解决方案来编号我的方程式并生成我的方程式列表。

尽管它们可能没有直接相关性,但我提到我使用它们是因为我不确定这是否会扰乱可能的解决方案。

在我的 MWE 之下。到目前为止,它运行良好(附图)。

但是我希望我的方程的“列表名称”(在本例中为\myequations{PDE of the diffsion process})可以作为一种变量使用,这样我就可以将其称为“由...\XXX给出”,其中\XXX一个命令为我提供\myequations{...}我所引用的方程的名称()(例如\tag{\ref{eq:litdiff}})。

我希望我的等式是清楚的,如果不清楚,请告知。

梅威瑟:

\documentclass[12pt]{report}
\usepackage{tocloft}
\usepackage{amsmath}
\usepackage{physics}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}

\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.5em}

\newcommand{\subs}{\text{s}}

\begin{document}

\listofmyequations

\chapter{Diffsion}

The PDE of the diffsion process is given by
\begin{subequations}\label{eq:litdiff}
\begin{equation}
\pdv{}{t} (\widetilde{c}_{\subs}(r,z,t)+c_{\subs,0})=\frac{D_{\subs}}{r^{2}}\pdv{}{r} \left(r^{2}\frac{\partial (\widetilde{c}_{\subs}(r,z,t)+c_{\subs,0})}{\partial r}\right)
\tag{\ref{eq:litdiff}}
\end{equation}
\myequations{PDE of the diffsion process}
\noindent The boundary conditions of Eq.~\eqref{eq:litdiff} are given by
\begin{align}
D_{\subs}\pdv{}{r} \widetilde{c}_{\subs}(0,z,t) &= 0 \label{eq:diffusionpartialdiff_boundaries0}\\
D_{\subs}\pdv{}{r} \widetilde{c}_{\subs}(R_{\subs},z,t) &= -j(z,t)\label{eq:diffusionpartialdiff_boundariesRs}
\end{align}
and the initial condition is given by
    \begin{equation}
        \widetilde{c}_{\subs}(r,z,0) = 0 \quad r\in [0;R_{\subs}].
    \label{eq:diffusionpartialdiff_init}
    \end{equation}
\end{subequations}

\end{document}

方程式列表 方程

答案1

这是将其合并\mylabel到 中的一种方法\myequation\makeatletter...\makeatother由于\protected@write和中使用了 @ 符号,因此需要\@auxout

\documentclass[12pt]{report}
\usepackage{tocloft}
\usepackage{amsmath}
\usepackage{physics}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}

\makeatletter
\@ifpackageloaded{hyperref}%
  {\newcommand{\mylabel}[2]% #1=name, #2 = contents
    {\protected@write\@auxout{}{\string\newlabel{#1}{{#2}{\thepage}%
      {\@currentlabelname}{\@currentHref}{}}}}}%
  {\newcommand{\mylabel}[2]% #1=name, #2 = contents
    {\protected@write\@auxout{}{\string\newlabel{#1}{{#2}{\thepage}}}}}
\makeatother

\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[2][\empty]{% #1 = label (optional), #2 = description
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#2}%
\ifx#1\empty\else\mylabel{#1}{#2}}
\setlength{\cftmyequationsnumwidth}{2.5em}

\newcommand{\subs}{\text{s}}

\begin{document}

\listofmyequations

\chapter{Diffsion}

The \ref{desc:litdiff} is given by
\begin{subequations}\label{eq:litdiff}
\begin{equation}
\pdv{}{t} (\widetilde{c}_{\subs}(r,z,t)+c_{\subs,0})=\frac{D_{\subs}}{r^{2}}\pdv{}{r} \left(r^{2}\frac{\partial (\widetilde{c}_{\subs}(r,z,t)+c_{\subs,0})}{\partial r}\right)
\tag{\ref{eq:litdiff}}
\end{equation}
\myequations[desc:litdiff]{PDE of the diffsion process}% to avoid adding an extra space
\medskip% same effect as \par\noindent
The boundary conditions of Eq.~\eqref{eq:litdiff} are given by
\begin{align}
D_{\subs}\pdv{}{r} \widetilde{c}_{\subs}(0,z,t) &= 0 \label{eq:diffusionpartialdiff_boundaries0}\\
D_{\subs}\pdv{}{r} \widetilde{c}_{\subs}(R_{\subs},z,t) &= -j(z,t)\label{eq:diffusionpartialdiff_boundariesRs}
\end{align}
and the initial condition is given by
    \begin{equation}
        \widetilde{c}_{\subs}(r,z,0) = 0 \quad r\in [0;R_{\subs}].
    \label{eq:diffusionpartialdiff_init}
    \end{equation}
\end{subequations}

\end{document}

答案2

您可以将其包含到您的 \myequation 命令中。

\documentclass[12pt]{article}

\makeatletter
\newcommand{\mylabel}[2]% #1 = label name, #2 = text for \ref
{\protected@write\@auxout{}{\string\newlabel{#1}{{#2}{\thepage}}}}
\makeatother

\begin{document}
\mylabel{eq:name}{almost anything}

You can use this to reference \ref{eq:name}.
\end{document}

超级标签

相关内容