我正在使用\documentclass{book}
。我还使用下面的代码来创建定理样式,但是,它只将标题放在顶部。我想修改代码,以便获得 => 定理 ch. no. 定理编号,然后是标题。(例如 => 定理 1.1 标题)。有什么想法可以修改代码吗?这是一个 MWE。[注意:\tcolorbox
对我不起作用,这就是我使用以下代码的原因 :-)] 我想要一些类似于下图但没有的东西\tcolorbox
。
\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{tabularx,booktabs}
\usepackage{blindtext}
\def\myindent{1.5ex}
\def\rulethk{1.0pt}
\definecolor{myblue}{RGB}{32,92,195}
\newenvironment{mybox}[1]
{\par\medskip\noindent\arrayrulewidth=2pt\arrayrulecolor{myblue}%
\tabularx{\linewidth}{!{\color{myblue}\hspace{\myindent}\vrule width \rulethk} X @{}}
\multicolumn{1}{@{}l}{\tabular{@{}l@{}}\textbf{#1}\\\hline\endtabular}\\}
{\\\color{myblue}\hspace{\myindent}\smash{\rule[.5pt]{10ex}{\rulethk}}\endtabularx\par\smallskip}
\begin{document}
\begin{mybox}{The title with some more text in the title}
Only some text here
\end{mybox}
\blindtext
\begin{mybox}{The title}
\blindtext
\end{mybox}
\blindtext
\end{document}
答案1
好吧,就像我们可以用适合定理和那些东西的包做什么的一个例子一样,只需添加一些内容即可属于您的 MWE:
\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{tabularx,booktabs}
\usepackage{amsmath,amssymb,latexsym} % necessary for maths
\usepackage{ntheorem} % One of the best packages for write theorems, proofs, defintions, etc.
\theorembodyfont{\normalfont} % For modify the body font in the theorems
\theoremstyle{break} % One of the styles for theorems
\usepackage{blindtext}
\def\myindent{1.5ex}
\def\rulethk{1.0pt}
\definecolor{myblue}{RGB}{32,92,195}
\newenvironment{mybox}[1]
{\par\medskip\noindent\arrayrulewidth=2pt\arrayrulecolor{myblue}%
\tabularx{\linewidth}{!{\color{myblue}\hspace{\myindent}\vrule width \rulethk} X @{}}
\multicolumn{1}{@{}l}{\tabular{@{}l@{}}\textbf{#1}\\\hline\endtabular}\\}
{\\\color{myblue}\hspace{\myindent}\smash{\rule[.5pt]{10ex}{\rulethk}}\endtabularx\par\smallskip}
\newtheorem{theo}{Theorema}[section] % Definition of the sets of theorems we need. Notice the option section, necessary for what you want
\newtheorem{proof}{Proof}[section]
\newtheorem{define}{Definition}[section]
\begin{document}
\chapter{Theorems}
\begin{mybox}{}
\section{The title with some more text in the title}
Only some text here
\end{mybox}
\blindtext
\begin{mybox}{}
\begin{define}[Tautology]\label{def:tautology}
A \emph{tautology} is a proposition that is always true for any value of its variables.
\end{define}
\begin{define}[Contradiction]\label{def:contradiction}
A \emph{contradiction} is a proposition that is always false for any value of its variables.
\end{define}
\end{mybox}
\begin{mybox}{}
\section{The title}
\blindtext
\end{mybox}
\blindtext
\begin{mybox}{}
\begin{theo}
If proposition $P$ is a tautology then $\sim P$ is a contradiction, and conversely.
\begin{proof}
If $P$ is a tautology, then all elements of its truth table are true (by Definition~\ref{def:tautology}), so all elements of the truth table for $\sim P$ are false, therefore $\sim P$ is a contradiction (by Definition~\ref{def:contradiction}).
\end{proof}
\end{theo}
\end{mybox}
\end{document}
为了更好地理解我所做的事情,请检查包装文档.我使用了示例从这里(清单 13)。请注意,我没有使用standard
包的选项(该选项会加载一些基本和标准的名称),而是创建了自己的选项。
我使用了您的mybox
环境而不是\newframedtheorem
包的(第 2.3.7 节),因为它需要加载包pstricks
,而我没有使用它。唯一的修改是我让环境的第二个参数为空,因为对于这个我不需要它,但我没有修改代码。
我发现你很固执,不想添加任何定理包。没关系,这是你的决定,我只是想展示这个包的可能性,但如果你更喜欢继续手动解决这个问题,我祝你好运和耐心,你会需要它们的。