解决方案

解决方案

在我的论文中我尝试对列出的研究进行编号。

为此,我使用了自定义定理样式:

\newtheorem{study}{Study}

首要问题

然后我想在我的章节标题中使用它,这样章节标题看起来就会像这样5.2 学习1. 这是一个测试

为了实现这一点,我使用以下代码

\section[This is a test]{\protect\begin{study}This is a test\protect\end{study}}

这既混乱,又意味着研究编号不会出现在我的目录中。有没有更好的方法将定理包含在章节标题中?

第二期

定理课程在研究的上方和下方设置了换行符,这意味着标题的格式在章节编号后有一个换行符,如下所示:

5.2

研究1。这是一个测试

我尝试通过修改 theoremstyle 来解决这个问题,但没有成功。我希望它停止换行,并将 Study 1 之后的文本加粗。我尝试使用的代码如下

\newtheoremstyle{study2}
  {0} % Space above
  {0} % Space below
  {} % Body font
  {} % Indent amount
  {\bfseries} % Theorem head font
  {:} % Punctuation after theorem head
  {.5em} % Space after theorem head
  {} % Theorem head spec (can be left empty, meaning `normal')

  \theoremstyle{study2} \newtheorem{study}{Study}

我怎样才能删除这个换行符,怎样才能使整个部分标题变为粗体?

非常感谢您提供的任何建议。

工作示例

\documentclass{report}
\usepackage{amsthm}

\newtheoremstyle{study2}
  {0} % Space above
  {0} % Space below
  {} % Body font
  {} % Indent amount
  {\bfseries} % Theorem head font
  {:} % Punctuation after theorem head
  {.5em} % Space after theorem head
  {} % Theorem head spec (can be left empty, meaning `normal')

\theoremstyle{study2} \newtheorem{study}{Study}


\begin{document}
\section[This is a test]{\protect\begin{study}This is a test\protect\end{study}}
\end{document}

预期结果模型

期望结果模型

解决方案

我最终使用了以下代码:

 \newenvironment{study}
  {\enskip\refstepcounter{studyish}\textbf{Study~\thestudyish:\space}}% \begin{shortthm}
  {\enskip}% \end{shortthm}
\makeatother

 \newtheorem{studyish}{Study}

这解决了换行问题。并允许在目录中列出研究编号。新的章节标题如下所示:

\section{\protect\begin{study}\label{study:FirstStudy}This is a test\protect\end{study}}

答案1

你走错路了。;-)只需设置一个新的计数器并使用它。

\documentclass{book}
\usepackage{xparse}

\newcounter{study}
\NewDocumentCommand{\study}{om}{%
  \refstepcounter{study}\IfValueT{#1}{\label{#1}}%
  \section{Study \thestudy: #2}%
}

\begin{document}
\frontmatter
\tableofcontents

\mainmatter
\chapter{Title}

\section{A regular section}\label{sec:reg}

We'll see in study~\ref{st:first} (see section~\ref{sec:st})
that we're doing interesting things.

\study[st:first]{This is a test}\label{sec:st}

Whatever.

\end{document}

研究编号的标签作为可选参数给出\study

目录

在此处输入图片描述

第一页

在此处输入图片描述

相关内容