\label{}
所以我的问题是,我的序言和and命令之间似乎存在冲突\ref{}
。当我在定义环境中引用时,一切都很顺利,但每当我尝试在方程环境中标记某些内容时,引用就会变得未定义,无论方程位于定义/定理环境中还是仅位于文档中。
以下是我的序言以及一个例子:
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{paralist}
\usepackage{fancyhdr}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{mathtools}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[framed, thmmarks, standard]{ntheorem}
\usepackage{framed}
\usepackage{pstricks}
\pagestyle{fancy}
\fancyhf{}
\rfoot{page \thepage}
\renewcommand{\headrulewidth}{0pt}
\numberwithin{equation}{section}
\definecolor{lightgray}{gray}{0.94}
\theoremseparator{:}
\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\normalfont}
\theoremsymbol{\nolinebreak[1]\hspace*{.5em plus 1fill}\ensuremath{\Box}}
\newtheorem{myproof}{Proof}
\theoremstyle{break}
\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
\theoremseparator{}
\theoremsymbol{}
\shadecolor{lightgray}
\newshadedtheorem{thm}{Theorem}[section]
\theoremstyle{break}
\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
\theoremseparator{}
\theoremsymbol{}
\shadecolor{lightgray}
\newshadedtheorem{mydef}{Definition}[section]
\begin{document}
\section{First section}
\begin{mydef}[Something]
\label{def:something}
We will now define something. It has a property:
\begin{equation}
\label{eq:first}
x+y=z
\end{equation}
\end{mydef}
Now I want to reference it. according to definition
\ref{def:something} we have..
If we look at equation \ref{eq:first}...
Also we have another equation:
\begin{equation}
\label{eq:second}
z>0
\end{equation}
I also want to talk about equation \ref{eq:second}
\end{document}
有人能看出问题出在哪里吗?提前致谢。
答案1
根据文档第 3.2.1 节,如果加载该包,则应ntheorem
添加选项:amsmath
thmmarks
amsmath
\usepackage[amsmath,thmmarks]{ntheorem}
完整示例:
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{paralist}
\usepackage{fancyhdr}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{mathtools}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[amsmath,framed, thmmarks, standard]{ntheorem}
\usepackage{framed}
\usepackage{pstricks}
\pagestyle{fancy}
\fancyhf{}
\rfoot{page \thepage}
\renewcommand{\headrulewidth}{0pt}
\numberwithin{equation}{section}
\definecolor{lightgray}{gray}{0.94}
\theoremseparator{:}
\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\normalfont}
\theoremsymbol{\nolinebreak[1]\hspace*{.5em plus 1fill}\ensuremath{\Box}}
\newtheorem{myproof}{Proof}
\theoremstyle{break}
\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
\theoremseparator{}
\theoremsymbol{}
\shadecolor{lightgray}
\newshadedtheorem{thm}{Theorem}[section]
\theoremstyle{break}
\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
\theoremseparator{}
\theoremsymbol{}
\shadecolor{lightgray}
\newshadedtheorem{mydef}{Definition}[section]
\begin{document}
\section{First section}
\begin{mydef}[Something]
\label{def:something}
We will now define something. It has a property:
\begin{equation}
\label{eq:first}
x+y=z
\end{equation}
\end{mydef}
Now I want to reference it. according to definition
\ref{def:something} we have..
If we look at equation \ref{eq:first}...
Also we have another equation:
\begin{equation}
\label{eq:second}
z>0
\end{equation}
I also want to talk about equation \ref{eq:second}
\end{document}
答案2
使用更简化的示例,您可以看到thmmarks
导致问题的是选项
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage
%[thmmarks]
{ntheorem}
\numberwithin{equation}{section}
\newtheorem{mydef}{Definition}[section]
\begin{document}
\section{First section}
\begin{mydef}[Something]
\label{def:something}
We will now define something. It has a property:
\begin{equation}
\label{eq:first}
x+y=z
\end{equation}
\end{mydef}
Now I want to reference it. according to definition
\ref{def:something} we have..
If we look at equation \ref{eq:first}...
Also we have another equation:
\begin{equation}
\label{eq:second}
z>0
\end{equation}
I also want to talk about equation \ref{eq:second}
\end{document}
尚未准确追踪标签的位置,如果使用该选项,它根本不会写入辅助文件。