mdframed 标题后没有换行符(即内联标题)

mdframed 标题后没有换行符(即内联标题)

mdframed我在所有类似定理的环境中使用它。默认情况下,mdframed标题显示在正文上方。我希望我的一个mdtheorem环境将正文与标题放在同一行,这是 LaTeX 默认命令的行为newtheorem

(对于搜索引擎:这意味着我想要一个内联标题,因此标题后没有换行符。)我在框架标题的文档中找不到正确的选项。

梅威瑟:

\documentclass{article}

\usepackage{mdframed}
\mdtheorem[font=\slshape, linewidth=1pt]{exercise}{Exercise}[section]

\begin{document}

\begin{exercise}
Sketch a decider machine for the halting problem.
\end{exercise}

\end{document}

答案1

如果您使用以下内容,则默认为运行标题\newmdtheorem

示例输出

\documentclass{article}

\usepackage{mdframed}
\mdtheorem[font=\slshape, linewidth=1pt]{exercise}{Exercise}[section]

\newmdtheoremenv[linewidth=1pt]{exercisetwo}{Exercise}[section]

\begin{document}

\begin{exercise}
Sketch a decider machine for the halting problem.
\end{exercise}

\begin{exercisetwo}
Sketch a decider machine for the halting problem.
\end{exercisetwo}

\end{document}

但是,如您所见,默认也使用斜体字体,而不是倾斜字体。添加font=\slshape还会改变标题的形状Exercise,这可能是您不想要的。加载amsthm包, mdframed,有机会定义新的风格,看看文档。例如,通过定义样式来给出倾斜字体,标题前没有垂直空间,标题后没有标点符号myexercise,并在中使用exercisethree

第二个示例

\documentclass{article}

\usepackage{amsthm}
\usepackage{mdframed}
\mdtheorem[font=\slshape, linewidth=1pt]{exercise}{Exercise}[section]

\newmdtheoremenv[linewidth=1pt]{exercisetwo}{Exercise}[section]

\newtheoremstyle{myexercise}{-\topsep}{}{\slshape}{}{\bfseries}{}{.5em}{}
\theoremstyle{myexercise}
\newmdtheoremenv[linewidth=1pt]{exercisethree}{Exercise}[section]

\begin{document}

\begin{exercise}
Sketch a decider machine for the halting problem.
\end{exercise}

\begin{exercisetwo}
Sketch a decider machine for the halting problem.
\end{exercisetwo}

\begin{exercisethree}
Sketch a decider machine for the halting problem.
\end{exercisethree}

\end{document}

相关内容