3

I link two questions below because I use their solution, to number my equations and generate a list of my equations.

Although they might not be directly relevant, I mention I use them because I am not sure if this messes up possible solutions.

Below my MWE. This works fine so far (Figures attached).

But I want the "list name" of my equation (in this case: \myequations{PDE of the diffsion process}) to be available as a kind of variable so that I can refer to it as "The \XXX is given by", where \XXX is a command giving me the Name (\myequations{...}) of the equation I refer to (e.g., \tag{\ref{eq:litdiff}}).

I hope my equation is clear, if not, please tell.

MWE:

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

List of Equations Equation

2 Answers 2

3

Here is one way to incorporate \mylabel into \myequation. The \makeatletter...\makeatother is needed due to the @ symbols used in \protected@write and \@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}
5

You can include this into your \myequation command.

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

super label

5
  • I fell I see that this is the solution to my problem. But i tried and failed in editing it into my special problem.
    – user69453
    Apr 3, 2015 at 18:20
  • For \xxx you could use \ref{name}. Of course, you would either need to add a name to \myequation or use something like {equ:\theequation} as a name. Apr 3, 2015 at 19:46
  • Sry I seem to be too stupid to get this. Where do i place the \protected@write\@auxout{}{\string\newlabel{#1}{{#2}{\thepage}}} from your code in my \newcommand{\myequations}[1]{ ...} code? Or is your suggestion to add another label to the equation?
    – user69453
    Apr 4, 2015 at 9:02
  • That depends on whether you want to reference the equation either by its number or description, or just one way. Apr 4, 2015 at 14:39
  • i want both. As shown in the example i want to refer as "... of Eq.~\eqref{eq:litdiff} ..." where i get the number as. But i also want to refer to the name as shwon in the example i attached as figure. I would really like it, if you give me a working example with your code, since i can not get it to work.
    – user69453
    Apr 6, 2015 at 8:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .