为什么节和小节之间有一个双点?

为什么节和小节之间有一个双点?

我定义了以下框:

 \documentclass[a4paper,14pt,twoside,reqno]{extbook}
    \usepackage[tmargin=28mm,bmargin=28mm,lmargin=28mm,rmargin=28mm]{geometry}
    \usepackage{amsmath, amsfonts,amssymb,amstext,amsthm,mathpazo, xfp, latexsym}
    \usepackage[many]{tcolorbox}
    \usepackage{lipsum}
    
    \definecolor{mygrey}{RGB}{99,99,99}
    
    \newtcolorbox[auto counter,number within=section]{mytheorem}[3][]{
        enhanced jigsaw,colback=white,colframe=mygrey,coltitle=mygrey
        ,
        fonttitle=\bfseries\sffamily,
        sharp corners,
        detach title,
        leftrule=30mm,
        underlay unbroken and first={\node[below,text=white,font=\sffamily\bfseries,align=center]
            at ([xshift=-15mm,yshift=-1mm]interior.north west) {THEOREM\\\thetcbcounter};},
        breakable,pad at break=1mm,
        #1,
        code={\ifdefempty{\tcbtitletext}{}{\tcbset{before upper={\tcbtitle\par\medskip}}}},
    }
    
    
    \begin{document}
        
        \section{Test section}
        
        \begin{mytheorem}[title=Normal Sampling Distributions]
            \lipsum[1]
        \end{mytheorem}
        
        \begin{mytheorem}
            \lipsum[2]
        \end{mytheorem}
        
        \begin{mytheorem}[title=Test]
            \lipsum[3-5]
        \end{mytheorem}
        
    \end{document}

chapter.section.subsection 的编号正确

但是当我在另一个文档中插入这个定义时,我得到了 chapter.section.subsection 编号的结果:

为什么在节和小节之间有这个双点?

我的代码中有这些定义:

`% Section style definition
\titleformat{\section}[runin]
{\normalsize \bfseries}
{\color{black} \S \hspace{.6pt} \thesection}
{1ex}{\color{black}}[\quad]

% Subsection style definition
\titleformat{\subsection}[runin]
{\normalsize \bfseries}
{\color{black} $ \bullet $ \thesubsection}
{1ex}{\color{black}}[\quad]

\renewcommand\thepart{\Roman{part}.}
\renewcommand\thesection{\thechapter.\arabic{section}.}
\renewcommand\thesubsection{\thesection\arabic{subsection}.}`\usepackage[many]{tcolorbox}

这是我为小节定义的格式

答案1

您正在命令中添加结尾句点\the<counter>。请不要这样做。

\documentclass[a4paper,14pt,twoside,reqno]{extbook}
\usepackage[tmargin=28mm,bmargin=28mm,lmargin=28mm,rmargin=28mm]{geometry}
\usepackage{amsmath,amssymb,amsthm,mathpazo,xfp}
\usepackage[many]{tcolorbox}
\usepackage{titlesec}

\usepackage{lipsum}

\definecolor{mygrey}{RGB}{99,99,99}

\titleformat{\section}[runin]
  {\normalsize \bfseries}
  {\color{black} \S \hspace{.6pt} \thesection.}
  {1ex}
  {\color{black}}
  [\quad]

% Subsection style definition
\titleformat{\subsection}[runin]
  {\normalsize \bfseries}
  {\color{black}$\bullet$ \thesubsection.}
  {1ex}
  {\color{black}}
  [\quad]

\renewcommand\thepart{\Roman{part}}
\renewcommand\thesection{\thechapter.\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}

\newtcolorbox[auto counter,number within=section]{mytheorem}[1][]{
  enhanced jigsaw,
  colback=white,
  colframe=mygrey,
  coltitle=mygrey,
  fonttitle=\bfseries\sffamily,
  sharp corners,
  detach title,
  leftrule=30mm,
  underlay unbroken and first={
    \node[below,text=white,font=\sffamily\bfseries,align=center]
      at ([xshift=-15mm,yshift=-1mm]interior.north west) {THEOREM\\\thetcbcounter};
  },
  breakable,
  pad at break=1mm,
  #1,
  code={\ifdefempty{\tcbtitletext}{}{\tcbset{before upper={\tcbtitle\par\medskip}}}},
}

\begin{document}

\section{Test section}
Some text to show runin

\section{Test subsection}
Some text to show runin

\begin{mytheorem}[title=Normal Sampling Distributions]
    \lipsum[1][1-5]
\end{mytheorem}

\begin{mytheorem}
    \lipsum[2][1-5]
\end{mytheorem}

\begin{mytheorem}[title=Test]
    \lipsum[3][1-5]
\end{mytheorem}

\end{document}

如您所见,在中添加了尾随句点\titleformat

在此处输入图片描述

注意:不应加载较新的文档latexsym;很快就会amstext加载。随着 2021 年 10 月发布的 LaTeX,不再需要加载。amsmathamsfontsamssymbxfp

您使用 进行定义mytheorem[3][]这意味着一个可选参数(空值默认值)和两个强制参数。我在 中修复了这个问题[1][]

相关内容