使用 \declaretheorem[]{} 时缺少文档开头的错误

使用 \declaretheorem[]{} 时缺少文档开头的错误

当我在 \declaretheorem[]{} 中使用 numberlike= 或 brothers= 之类的代码时,会出现缺少 \begin{document} 的错误,我不明白为什么(我想要定理、定义、命题使用相同的编号……)。我在论文中使用了下一个 latex 代码:

\documentclass[12pt, oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[english]{babel}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[mono=false]{libertine}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{cite}
\usepackage{mathrsfs}
\usepackage{parskip}
\usepackage[pdftex]{hyperref}
\hypersetup{colorlinks=true,linkcolor=black} 
\usepackage{float}
\providecommand{\norm}[1]{\lVert#1\rVert}
\usepackage[]{amsmath}
\usepackage[]{amsthm}
\usepackage[]{mathtools}
\usepackage[]{bm}
\usepackage[]{thmtools}
\DeclareMathOperator{\sign}{sign}
\newcommand{\marcador}{\vrule height 10pt depth 2pt width 2pt \hskip .5em\relax}
\newcommand{\cabeceraespecial}{\color{Color}\normalfont\bfseries}
\declaretheoremstyle[
spaceabove=\medskipamount,
spacebelow=\medskipamount,
headfont=\cabeceraespecial\marcador,
notefont=\cabeceraespecial,
notebraces={(}{)},
bodyfont=\normalfont\itshape,
postheadspace=1em,
headindent=0pt,
headpunct={.}
]{importante}
\declaretheoremstyle[
spaceabove=\medskipamount,
spacebelow=\medskipamount,
headfont=\normalfont\itshape\color{Color},
notefont=\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
headindent=0pt,
headpunct={.}
]{normal}
\declaretheoremstyle[
spaceabove=\medskipamount,
spacebelow=\medskipamount,
headfont=\normalfont\itshape\color{Color},
notefont=\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
headindent=0pt,
headpunct={.},
numbered=no,
qed=\color{Color}QED
]{demostracion}
\declaretheorem[name=Theorem,style=importante,numberwithin=chapter]{theorem}
\declaretheorem[name=Remark,style=normal,numberwithin=chapter]{remark}
\declaretheorem[name=Corollary,style=normal]{corollary}
\declaretheorem[name=Proposition,style=importante,numberwithin=chapter,sibling=theorem]{proposition}
\declaretheorem[name=Lemma,style=importante,numberwithin=chapter,sibling=theorem]{lemma}
\declaretheorem[name=Example,style=normal,numberwithin=chapter,sibling=theorem]{ej}
\declaretheorem[name=Definition,style=importante,numberwithin=chapter,sibling=theorem]{definition}
\let\proof=\undefined
\declaretheorem[name=Proof,style=demostracion]{proof}

答案1

如果你添加

\begin{document}

\end{document}

获取完整的文档

并在序言开头添加

\everypar{}

消除开始文档错误(有时对调试有用,但不是一个好

生产文件中的想法)然后你得到

在此处输入图片描述

它给出了指向错误的指针。

\newtheorem有一个可选参数表示重新使用现有计数器,还有一个不同的可选参数表示重置父计数器下的计数器,但是您不能同时使用这两个参数。如果您这样做,则第二个([chapter])尾随可选参数不会被拾取,而只是排版为文本,从而导致显示的错误。如果您同时使用和,thm-toolskeyval 包装器可能应该会发出警告并给出更好的错误消息siblingcounterwithin

\documentclass[12pt, oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[english]{babel}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[mono=false]{libertine}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{cite}
\usepackage{mathrsfs}
\usepackage{parskip}
\usepackage[pdftex]{hyperref}
\hypersetup{colorlinks=true,linkcolor=black} 
\usepackage{float}
\providecommand{\norm}[1]{\lVert#1\rVert}
\usepackage[]{amsmath}
\usepackage[]{amsthm}

\usepackage[]{mathtools}
\usepackage[]{bm}
\usepackage[]{thmtools}
\DeclareMathOperator{\sign}{sign}
\newcommand{\marcador}{\vrule height 10pt depth 2pt width 2pt \hskip .5em\relax}
\newcommand{\cabeceraespecial}{\color{Color}\normalfont\bfseries}
\declaretheoremstyle[
spaceabove=\medskipamount,
spacebelow=\medskipamount,
headfont=\cabeceraespecial\marcador,
notefont=\cabeceraespecial,
notebraces={(}{)},
bodyfont=\normalfont\itshape,
postheadspace=1em,
headindent=0pt,
headpunct={.}
]{importante}
\declaretheoremstyle[
spaceabove=\medskipamount,
spacebelow=\medskipamount,
headfont=\normalfont\itshape\color{Color},
notefont=\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
headindent=0pt,
headpunct={.}
]{normal}
\declaretheoremstyle[
spaceabove=\medskipamount,
spacebelow=\medskipamount,
headfont=\normalfont\itshape\color{Color},
notefont=\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
headindent=0pt,
headpunct={.},
numbered=no,
qed=\color{Color}QED
]{demostracion}

\declaretheorem[name=Theorem,style=importante,numberwithin=chapter]{theorem}

\declaretheorem[name=Remark,style=normal,sibling=theorem]{remark}

\declaretheorem[name=Corollary,style=normal,sibling=theorem]{corollary}


\declaretheorem[name=Proposition,style=importante,sibling=theorem]{proposition}



\declaretheorem[name=Lemma,style=importante,sibling=theorem]{lemma}
\declaretheorem[name=Example,style=normal,sibling=theorem]{ej}
\declaretheorem[name=Definition,style=importante,sibling=theorem]{definition}
\let\proof=\undefined
\declaretheorem[name=Proof,style=demostracion]{proof}



\begin{document}

\end{document}

相关内容