这是我的代码:
\documentclass[11pt, openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz-cd}
\usepackage{makecell}
\usepackage{mathtools}
\usepackage{commath}
\usepackage{bbm}
\usetikzlibrary{babel}
\usetikzlibrary{shapes.geometric}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{circledsteps}
\usepackage{ relsize, stackengine}
\usepackage[all,cmtip]{xy}
\usepackage[english]{babel}
\usepackage{xurl}
\usepackage{stmaryrd}
\usepackage[backend=biber,style=alphabetic,sorting=ynt]{biblatex}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usetikzlibrary{intersections}
\newtheorem{theorem}{Theorem}
\newtheorem{prop}{Proposition}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{example}{Example}
\newtheorem{cor}{Corollary}
\newtheorem{question}{Question}
\newtheorem{prob}{\emph{Problem}}
\usepackage[titles]{tocloft}
\usepackage{xcolor}
\makeatletter
\def\ps@headings{%
\def\@oddfoot{\normalfont\hfil\thepage\hfil}%
\def\@evenfoot{\normalfont\hfil\thepage\hfil}}
\def\@evenhead{\hfil\slshape\leftmark}%
\def\@oddhead{{\slshape\rightmark}\hfil%
\let\@mkboth\markboth
\def\chaptermark##1{%
\markboth {\MakeUppercase{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\@chapapp\ \thechapter. \ %
\fi
\fi
##1}}{}}%
\def\sectionmark##1{%
\markright {\MakeUppercase{%
\ifnum \c@secnumdepth >\z@
\thesection. \ %
\fi
##1}}}}
\makeatother
\pagestyle{headings}% apply new definitions
%\DeclareFontShape{U}{matha}{m}{n}{ <-6> matha5 <6-7> matha6 <7-8>
% matha7 <8-9> matha8 <9-10> matha9 <10-12> matha10 <12-> matha12 }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\nvartrianglelefteq}{\mathrel}{matha}{"9E}
\begin{document}
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\newgeometry{top=1.5in,hmargin=1in, bottom = 1.1 in}
%\pagenumbering{gobble}
\Large
\begin{center}
Assignment 5 \\
\hspace{10pt}
\large
Jack, \\
Nov. 10, 2021.
\end{center}
\textbf{\emph{Section 9.2}}
\setcounter{chapter}{3}
\setcounter{section}{2}
\begin{prob}[phantom=\setcounter{\tcbcounter}{19}]{}{}
$\quad$
\emph{ \lipsum[1]}
\end{prob}
\end{document}
但我不知道为什么这一行在我的代码中给出错误
\begin{prob}[phantom=\setcounter{\tcbcounter}{19}]{}{}
?有人能帮我修改这一行吗?我想每次都给我的问题编号(包括章节编号和节编号,例如 4.5.36)。
编辑:
我得到的错误是:
"argument> c@\tcbcounter
l.106 ...ob}[phantom=\setcounter{\tcbcounter}{19}]
{}{}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have"
答案1
你的例子可以简化为
\documentclass{article}
\newtheorem{prob}{Problem}
\begin{document}
\setcounter{\tcbcounter}{19}
\begin{prob}
aaa
\end{prob}
\end{document}
会产生同样的错误
! Undefined control sequence.
<argument> c@\tcbcounter
l.4 \setcounter{\tcbcounter}{19}
?
因为\tcbcounter
未定义。LaTeX 计数器是通过名称而不是命令序列引用的,这是你预期的\setcounter{tcbcounter}{19}
,但这会产生错误
! LaTeX Error: No counter 'tcbcounter' defined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 \setcounter{tcbcounter}{19}
?
因为该计数器未定义。
您可以添加
\newcounter{tcbcounter}
到序言部分,这将消除错误,但因为你从来没有使用过计数器,所以我认为这不是你想要的。
您已将问题定义为使用计数器prob
(第一个参数
\newtheorem{prob}{Problem}
所以我认为你只想将此计数器设置为 19
\documentclass{article}
\newtheorem{prob}{Problem}
\begin{document}
\setcounter{prob}{19}
\begin{prob}
aaa
\end{prob}
\end{document}
这导致问题编号为 20