-1

I have code, I didn't write and I don't understand. It works just fine, but the equation counter isn't correct in the list of equations. In the document the counter starts with 1, as I want it to. But in the list of equations the counter starts with 0. Could someone help and tell me, what I should add to solve that problem?

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

  • 4
    Can you please extend your code snippet to a minimal working example starting with \documentclass and ending with \end{document}. Currently I would guess, that you've made a mistake placing your \myequations{…} or \label or … to early (before the equation counter has been increased by the corresponding equation). A minimal working example would show, what you've done and so we won't need to guess, but could see and mostly indeed help. – cabohah Apr 25 '23 at 14:26
  • 1
    BTW: There are a lot of questions about list of equations. Maybe you can find your code and also how to use it correctly. Maybe you can even find other suggestions, that would help you. – cabohah Apr 25 '23 at 14:29
  • 1
    It looks like someone inherited a lot of LaTeX code which used the protocol \label{eq:...} and decide to remove the eq: using LaTeX rather than using the editor (change all). I would throw the whole thing out. But mostly you need to move \myequations after \oldequation. – John Kormylo Apr 25 '23 at 16:41
  • Welcome. // Did you check the wikibook on Latex? – MS-SPO Apr 26 '23 at 14:37
  • If you don't have to use that specific code, then this should be a solution for your question: Table of equations like list of figures. – dexteritas Apr 26 '23 at 15:17
  • And this might be the source of the code. – dexteritas Apr 26 '23 at 15:21
  • @dexteritas The code you suggested doesn't work for me. There are 100 error messages, I think that's too difficult for me to solve. Isn't it possible to use the code I already have and change the one thing of counting from 1? – Hanna Kretz Apr 27 '23 at 10:51

1 Answers1

2

It works with both codes if you use equation environment and place \myequations after the environment.

Adaptations

  • commented out unused packages

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

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

Result

enter image description here

dexteritas
  • 9,161