如何将 amsthm 标题放在文本的右侧

如何将 amsthm 标题放在文本的右侧

我怎样才能将定理环境的标题放在文本的右侧。

例子:

\begin{definition}[Titel]
Some Text
\end{definition}

结果看起来应该像这样。其中的图块是 Strukturbaum,并位于定义的右侧。

在此处输入图片描述

答案1

amsthm可以定义一种除了可选参数的处理之外与标准相同的样式。

\documentclass{article}
\usepackage{amsmath,amsthm}

\newtheoremstyle{arweddefinition}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\upshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  % CUSTOM-HEAD-SPEC follows
  {%
   \if\relax\detokenize{#3}\relax
     % no optional argument
   \else
     \makebox[0pt][l]{\hspace{\textwidth}\hspace{\marginparsep}\normalfont\itshape#3}%
   \fi
   \thmname{#1}\thmnumber{ #2}%
  }

\theoremstyle{arweddefinition}
\newtheorem{definition}{Definition}[section]

\begin{document}

\section{Test}

\begin{definition}[Foo]
A \emph{foo} is something very useful. We will use foos all the
time in this paper. This should be enough to wrap.
\end{definition}

\begin{definition}
A \emph{baz} is not very useful so we don't set it in the margin.
We will not be using any baz in the paper. This should be enough to wrap.
\end{definition}

\end{document}

在此处输入图片描述

使用破碎\parbox来适应更长的标题。

\documentclass{article}
\usepackage{amsmath,amsthm}

\newtheoremstyle{arweddefinition}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\upshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  % CUSTOM-HEAD-SPEC follows
  {%
   \if\relax\detokenize{#3}\relax
     % no optional argument
   \else
     \makebox[0pt][l]{%
       \hspace{\textwidth}\hspace{\marginparsep}\normalfont\itshape
       \smash{\parbox[t]{\marginparwidth}{\raggedright#3}}%
     }%
   \fi
   \thmname{#1}\thmnumber{ #2}%
  }

\theoremstyle{arweddefinition}
\newtheorem{definition}{Definition}[section]

\begin{document}

\section{Test}

\begin{definition}[Foo]
A \emph{foo} is something very useful. We will use foos all the
time in this paper. This should be enough to wrap.
\end{definition}

\begin{definition}
A \emph{baz} is not very useful so we don't set it in the margin.
We will not be using any baz in the paper. This should be enough to wrap.
\end{definition}

\begin{definition}[Strongly typed principal foo]
A \emph{strongly typed principal foo} is not very useful, but we set it in the
margin just by way of example. We will not be using themin the paper. 
This should be enough to wrap.
\end{definition}

\end{document}

在此处输入图片描述

相关内容