经典案例
使用经典\newtheorem
命令amsthm
,可以得到以下结果可选参数:
来自此代码
\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem}
\end{document}
案子mdframed
我希望得到类似的结果mdframed
:括号内的可选参数,但不改变字体,末尾也没有点。但默认情况下,我得到的是:
从代码中
\documentclass{article}
\usepackage{mdframed}
\mdfdefinestyle{myFramedTheoremStyle}{%
frametitlealignment=\raggedright,
linecolor=red,
linewidth=4pt,
innertopmargin=0pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
frametitleaboveskip=5pt,
skipbelow=0pt,
font=\itshape
}
\mdtheorem[style=myFramedTheoremStyle]{theorem}{Theorem}
\begin{document}
\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem}
\end{document}
我目前发现
在文档中,我发现了以下选项(命令\mdfdefinestyle
):
theoremseparator、theoremtitlefont 和 theoremspace
但似乎有一个属性可以定义可选参数后面的内容。我正在寻找\mdfdefinestyle
可以调用的命令选项theoremtextafter
。
我的问题
我希望有类似的东西。你知道是否真的存在吗?如果没有,是否有可能找到一个简单的解决方案?
谢谢。
答案1
我不知道官方的做法,但这里有一个黑客它的作用是:
- 适用
theoremtitlefont=\normalfont
于获取标题中的正确字体 - 将定理重命名
mdframed
为MDtheorem
- 创建一个
\newenvironment
调用theorem
,将所需的(
和插入)
到定理名称中,然后将其传递给MDtheorem
。 - 创建一个
\newenvironment
调用theorem*
来提供相同的功能没有编号。
笔记:
- 对于带星号的版本,其风格
theorem*
似乎不够充分,因此必须添加手册。mdframe
theoremtitlefont=\normalfont
\normalfont
代码:
\documentclass{article}
\usepackage{mdframed}
\mdfdefinestyle{myFramedTheoremStyle}{%
frametitlealignment=\raggedright,
linecolor=red,
linewidth=4pt,
innertopmargin=0pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
frametitleaboveskip=5pt,
skipbelow=0pt,
theoremtitlefont=\normalfont,
font=\itshape
}
\mdtheorem[style=myFramedTheoremStyle]{MDtheorem}{Theorem}
\newcommand*{\Title}{}
\newenvironment{theorem}[1][]{%
\ifstrempty{#1}{\begin{MDtheorem}}{\begin{MDtheorem}[(#1)]}%
}{%
\end{MDtheorem}%
}%
\newenvironment{theorem*}[1][]{%
% Required `\normalfont` in `MDtheorem*`, but not in the `MDtheorem` environment
\ifstrempty{#1}{\begin{MDtheorem*}}{\begin{MDtheorem*}[\normalfont(#1)]}%
}{%
\end{MDtheorem*}%
}%
\begin{document}
\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem}
\begin{theorem}
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem}
\begin{theorem*}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem*}
\begin{theorem*}
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem*}
\end{document}
答案2
根据彼得的回答,
\documentclass{article}
\usepackage{mdframed}
\mdfdefinestyle{myFramedTheoremStyle}{%
frametitlealignment=\raggedright,
linecolor=red,
linewidth=4pt,
innertopmargin=0pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
frametitleaboveskip=5pt,
skipbelow=0pt,
theoremtitlefont=\normalfont,
font=\itshape
}
\mdtheorem[style=myFramedTheoremStyle]{MDtheorem}{Theorem}
\newcommand*{\Title}{}
\newenvironment{theorem}[1][]{%
\ifstrempty{#1}{\begin{MDtheorem}}%
{\begin{MDtheorem}[(#1)]}
}{%
\end{MDtheorem}%
}%
\begin{document}
\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem}
\begin{theorem}
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante.
\end{theorem}
\end{document}