我正在用 LaTeX 写论文。
问题如下:我试图引用附录中的公式,但命令\eqref
给了我错误的数字。
我在整个文档中都使用了该命令\numberwithin{equation}{section}
,但是公式
\appendix
\begin{fleqn}
\begin{equation}\label{app:eq_gamma-exp}
\Gamma(1+\epsilon) = 1 - \gamma\epsilon + O(\epsilon^2)
\end{equation}
\end{fleqn}
在我的文中编号为 (B.2.6),仅称为 (B.2)。
有人能帮我吗?
这里我举了一个重现我的问题的例子
\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}
我注意到以下代码不会重现错误,但会使新命令\mathinhead
未定义。然后,我认为这是软件包问题,但我不知道如何处理它。
\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}
答案1
答案2
这个答案是错误的。请参阅下面@egerg 的评论。
- 根据nccmath:fleqn 编号,
nccmath
应该加载后hyperref
。 - 在这种情况下,似乎也
amsmath
应该在 之后加载。这意味着移动所有在 之后hyperref
隐式加载的包。amsmath
hyperref
以下是调整后的(部分)订单:
\usepackage{amssymb}
% ...
\usepackage{hyperref}
% ...
\usepackage{amsmath,commath,nccmath}
\numberwithin{equation}{section}
\usepackage{physics}