我用tcolorbox
它来围绕定理画框。这个包还可以选择将定理编号放在页边距中,如下面的 MWE 所示;请参阅第 342 页手册更多细节。
问题是,即使像我的例子一样设置得非常普通,定理的编号也会与框重叠。我找不到调整这个问题的选项,但我确信一定有办法。
有人知道如何将定理编号放置在离定理框较远的地方吗?
请注意,我想使用tcolorbox
,所以请不要建议使用不同的包来实现类似的效果的解决方案。
编辑:如果我没说清楚,我需要将编号放在边距内、框外、框左侧。我并不要求将编号放回框中,只需删除样式即可margin apart
。
\documentclass{article}
\usepackage[theorems]{tcolorbox}
\usepackage{xcolor}
\newtcbtheorem[number within=subsection]%
{theorem} % \begin..
{Theorem} % Title
{theorem style = margin apart, % Style
colback=white,
colframe=lightgray,
coltitle=black}
{theo} % label prefix; cite as ``theo:yourlabel''
\usepackage{lipsum}
\begin{document}
\section{My section}
\subsection{My subsection}
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}
\end{document}
答案1
这是可能的,用一种theorem name
风格和转移一个overlay
开箱即用overlay={\node[...]}
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{xcolor}
\newtcbtheorem[number within=subsection]%
{theorem} % \begin..
{Theorem} % Title
{%theorem style = margin apart, % Style
enhanced,
colback=white,
colframe=lightgray,
theorem name,
coltitle=black,%
overlay={\node[xshift=-20pt] (A) at (title.west) {\bfseries \thetcbcounter};},
left=2mm,
}
{theo} % label prefix; cite as ``theo:yourlabel''
\usepackage{lipsum}
\begin{document}
\section{My section}
\subsection{My subsection}
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}
\end{document}
答案2
根据 Christian 的解决方案,我引入了一个神奇的数字,left skip
结果如下:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{xcolor}
\newtcbtheorem[number within=subsection]%
{theorem} % \begin..
{Theorem} % Title
{%theorem style = margin apart, % Style
enhanced,
colback=white,
colframe=lightgray,
theorem name,
coltitle=black,%
overlay={\node[xshift=-20pt] (A) at (title.west) {\bfseries \thetcbcounter};},
left=2mm,
% show bounding box,
% width=\linewidth,
left skip=32pt
}
{theo} % label prefix; cite as ``theo:yourlabel''
\usepackage{lipsum}
\begin{document}
\section{My section}
\subsection{My subsection}
\lipsum[1]
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}
\end{document}