从 1 开始计数,而不是从 0 开始,方程式列表

从 1 开始计数,而不是从 0 开始,方程式列表

我有代码,不是我写的,我看不懂。它运行正常,但方程式列表中的方程式计数器不正确。在文档中,计数器从 1 开始,正如我想要的那样。但在方程式列表中,计数器从 0 开始。有人能帮我告诉我,我应该添加什么来解决这个问题吗?

\documentclass[twoside,a4paper,11pt,openright]{report}

\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 
\usepackage{newtxtext, newtxmath} 
\usepackage[T1]{fontenc}    
\usepackage{amsmath}        
\usepackage{microtype}  
\usepackage[inner=25mm,outer=35mm,top=20mm,bottom=30mm,]{geometry}  
\usepackage{array}  
\usepackage[pdftex]{graphicx}   
\usepackage{float}  
\selectlanguage{german}

\usepackage{siunitx}  
\usepackage{chemformula} 
\usepackage{tocloft} % eigene "list of things"
\usepackage{caption}

\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}

% redefinition of \equation for convenience
\let\oldequation = \equation
\let\endoldequation = \endequation
\AtBeginDocument{\let\oldlabel = \label}
\newcommand{\mynewlabel}[1]{%
  \StrBehind{#1}{eq:}[\Str]% remove "eq:" from labels
  \edef\temp{\noexpand\myequations{\Str\noexpand\quad\expandonce{\@currentlabel}}}% add tag to the entry in the list of equations
\temp % execute the command
  \oldlabel{#1} % call the original label command
  \myequations{\Str}\oldlabel{#1}}
  \renewenvironment{equation}{%
  \oldequation
  \let\label\mynewlabel
}{\endoldequation}

%\newcommand{\listequationsname}{} %Formelverzeichnis
\newlistof{myequations}{equ}{Formelverzeichnis}
\newcommand{\myequations}[1]{%
      \addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsnumwidth}{3em}

\makeatother

\begin{document}

\begin{align}
Q(t) = Q(t_0) + \int\limits_{t_0}^{t} I(t)\ \mathrm{d}t
 \myequations{elektrische Ladung}
\end{align}

\begin{align}
R_i = {\frac {U_0 - U_l}{I_l}}
 \myequations{Innenwiderstand} %\nomenclature
\end{align}

\newpage
\listofmyequations 

\end{document}

答案1

equation如果您使用环境并\myequations在环境之后放置,它可以与这两种代码一起使用。

改编

  • 注释掉未使用的包

代码 1

\documentclass[twoside,a4paper,11pt,openright]{report}
\usepackage{tocloft}
\usepackage{amsmath}
\usepackage[inner=25mm,outer=35mm,top=20mm,bottom=30mm,]{geometry}  

%%gmedina solution
\newcommand{\listequationsname}{Formelverzeichnis}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.5em}% Width of equation number in List of Equations

\begin{document}

\begin{equation}
    Q(t) = Q(t_0) + \int\limits_{t_0}^{t} I(t)\ \mathrm{d}t
\end{equation}
\myequations{elektrische Ladung}

\begin{equation}
    R_i = {\frac {U_0 - U_l}{I_l}}
\end{equation}
\myequations{Innenwiderstand} %\nomenclature

\newpage
\listofmyequations 

\end{document}

代码 2

\documentclass[twoside,a4paper,11pt,openright]{report}

\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 
%\usepackage{newtxtext, newtxmath} 
\usepackage[T1]{fontenc}    
\usepackage{amsmath}        
%\usepackage{microtype}  
\usepackage[inner=25mm,outer=35mm,top=20mm,bottom=30mm,]{geometry}  
%\usepackage{array}  
%\usepackage[pdftex]{graphicx}   
%\usepackage{float}  
\selectlanguage{german}

%\usepackage{siunitx}  
%\usepackage{chemformula} 
\usepackage{tocloft} % eigene "list of things"
%\usepackage{caption}

\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}

% redefinition of \equation for convenience
\let\oldequation = \equation
\let\endoldequation = \endequation
\AtBeginDocument{\let\oldlabel = \label}
\newcommand{\mynewlabel}[1]{%
  \StrBehind{#1}{eq:}[\Str]% remove "eq:" from labels
  \edef\temp{\noexpand\myequations{\Str\noexpand\quad\expandonce{\@currentlabel}}}% add tag to the entry in the list of equations
\temp % execute the command
  \oldlabel{#1} % call the original label command
  \myequations{\Str}\oldlabel{#1}}
  \renewenvironment{equation}{%
  \oldequation
  \let\label\mynewlabel
}{\endoldequation}

%\newcommand{\listequationsname}{} %Formelverzeichnis
\newlistof{myequations}{equ}{Formelverzeichnis}
\newcommand{\myequations}[1]{%
      \addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsnumwidth}{3em}

\makeatother

\begin{document}

\begin{equation}
Q(t) = Q(t_0) + \int\limits_{t_0}^{t} I(t)\ \mathrm{d}t
\end{equation}
\myequations{elektrische Ladung}

\begin{equation}
R_i = {\frac {U_0 - U_l}{I_l}}
\end{equation}
\myequations{Innenwiderstand} %\nomenclature

\newpage
\listofmyequations 

\end{document}

结果

在此处输入图片描述

相关内容