I'm writing my thesis on LaTeX.
The problem is the following: I'm trying to refer to an equation in the appendix, but the command \eqref gives me the wrong number.
I use the command \numberwithin{equation}{section} all over the document, but the equation
\appendix
\begin{fleqn}
\begin{equation}\label{app:eq_gamma-exp}
\Gamma(1+\epsilon) = 1 - \gamma\epsilon + O(\epsilon^2)
\end{equation}
\end{fleqn}
which in my text is numbered as (B.2.6), is referred only as (B.2).
Can someone help me?
Here I put an example that reproduces my problem
\documentclass[a4paper,12pt,twoside,openany]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[lighttt]{lmodern}
\usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath,nccmath}
\numberwithin{equation}{section}
\usepackage{siunitx}
\usepackage{physics}
\usepackage{float}
\usepackage{wrapfig}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={My title}, % title
pdfauthor={Author}, % author
pdfsubject={Subject}, % subject of the document
pdfcreator={Creator}, % creator of the document
pdfproducer={Producer}, % producer of the document
pdfkeywords={keyword1, key2, key3}, % list of keywords
pdfnewwindow=true, % links in new PDF window
colorlinks=false, % false: boxed links; true: colored links
linkcolor=cyan, % color of internal links (change box color with linkbordercolor)
linkbordercolor = blue,
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=red % color of external links
}
\usepackage{textcomp}
\usepackage{setspace}
\onehalfspacing
\usepackage{caption}
%caption customization
\captionsetup {
format=plain,
width=0.80\textwidth,
font=normal,
labelfont=bf,
figurename = Fig. ,
tablename = Tab.
}
\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{multicol}
\usepackage[sorting=none]{biblatex}
\usepackage{fancyhdr}
\fancypagestyle{mainmatter}{%
\renewcommand{\headrulewidth}{.4pt}% Header rule
\renewcommand{\footrulewidth}{0pt}% No Footer rule
\fancyhf{}% Clear header/footer
\fancyhead[LE]{\itshape\nouppercase\leftmark}
\fancyhead[RO]{\itshape\nouppercase\rightmark}
\fancyhead[RE,LO]{\thepage}%
}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[R]{\thepage}
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\raggedbottom
\usepackage{titlesec}
\titleformat{name=\chapter}[display]
{\Large\ttfamily}
{{\chaptertitlename} \thechapter}
{2ex}
{\bfseries\filcenter\Huge
}
\titleformat{\section}[block]
{\ttfamily\bfseries\boldmath\Large}
{\thesection}{1em}{}
\titleformat{\subsection}[block]
{\ttfamily\bfseries\large}
{\thesubsection}{1em}{}
\titlespacing{\chapter}{0pt}{-10pt}{40pt}
\DeclareSIUnit{\erg}{erg}
\DeclareSIUnit\CoolR{\erg \centi \metre \cubed \per \second}
\newcommand*\mathinhead[2]{\texorpdfstring{$#1$}{#2}}
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
\title{problem}
\date{May 2020}
\begin{document}
\maketitle
\chapter{Renormalization}
\section{Classical physics example}
In order the renormalize the potential, $V_D(y)$ might be expanded around the correct dimension of the problem $D = 1 + \epsilon$. Then, for $\epsilon\to 0$ one has:
\begin{equation}
\left\{
\begin{aligned}\label{eq:3_expansion}
\left(\frac{\mu}{y}\right)^{1-D} & = \exp(-\epsilon\ln\frac{\mu}{y}) = 1 - \epsilon\ln\frac{\mu}{y} + O(\epsilon^2) \\
\pi^{(D-1)/2} & = \exp(\frac{\epsilon}{2}\ln\pi) = 1 + \frac{\epsilon}{2}\ln\pi + O(\epsilon^2)\\
\Gamma\left(\frac{1-D}{2}\right) & = -\frac{2}{\epsilon}\Gamma\left(1 - \frac{\epsilon}{2} \right) = -\frac{2}{\epsilon}\left(1 + \frac{\gamma}{2}\epsilon + O(\epsilon^2)\right)
\end{aligned}
\right.
\end{equation}
where $\gamma$ is the Euler--Mascheroni constant and the last expansion is the same of \eqref{app:eq_gamma-exp}.
\appendix
\chapter{Special functions}
\section{\mathinhead{\Gamma}{gamma}-function} \label{app:gamma_func}
If $\epsilon \ll 1$
\begin{fleqn}
\begin{equation}\label{app:eq_gamma-exp}
\Gamma(1+\epsilon) = 1 - \gamma\epsilon + O(\epsilon^2)
\end{equation}
\end{fleqn}
\end{document}
I noticed that the following code does not reproduce the error but makes the new command \mathinhead undefined. Then, I think it's a packages problem but I don't know how to manage it.
\documentclass[a4paper,12pt,twoside,openany]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[lighttt]{lmodern}
\usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath,nccmath}
\numberwithin{equation}{section}
\usepackage{siunitx}
\usepackage{physics}
%\newcommand*\mathinhead[2]{\texorpdfstring{$#1$}{#2}}
\title{problem}
\date{May 2020}
\begin{document}
\maketitle
\chapter{Renormalization}
\section{Classical physics example}
In order the renormalize the potential, $V_D(y)$ might be expanded around the correct dimension of the problem $D = 1 + \epsilon$. Then, for $\epsilon\to 0$ one has:
\begin{equation}
\left\{
\begin{aligned}\label{eq:3_expansion}
\left(\frac{\mu}{y}\right)^{1-D} & = \exp(-\epsilon\ln\frac{\mu}{y}) = 1 - \epsilon\ln\frac{\mu}{y} + O(\epsilon^2) \\
\pi^{(D-1)/2} & = \exp(\frac{\epsilon}{2}\ln\pi) = 1 + \frac{\epsilon}{2}\ln\pi + O(\epsilon^2)\\
\Gamma\left(\frac{1-D}{2}\right) & = -\frac{2}{\epsilon}\Gamma\left(1 - \frac{\epsilon}{2} \right) = -\frac{2}{\epsilon}\left(1 + \frac{\gamma}{2}\epsilon + O(\epsilon^2)\right)
\end{aligned}
\right.
\end{equation}
where $\gamma$ is the Euler--Mascheroni constant and the last expansion is the same of \eqref{app:eq_gamma-exp}.
\appendix
\chapter{Special functions}
\section{\mathinhead{\Gamma}{gamma}-function} \label{app:gamma_func}
If $\epsilon \ll 1$
\begin{fleqn}
\begin{equation}\label{app:eq_gamma-exp}
\Gamma(1+\epsilon) = 1 - \gamma\epsilon + O(\epsilon^2)
\end{equation}
\end{fleqn}
\end{document}

\documentclass{...}and end with\end{document}, and (of course) it should reproduce your problem. – Vincent May 14 '20 at 20:33equationenvironment, so it's just anfleqnenvironment? – Werner May 14 '20 at 21:38commath: it adds nothing but bugs. Also I cannot recommendphysics. – egreg May 14 '20 at 23:02