我怎样才能在不在 mdframed 中创建新行的情况下进行对齐?

我怎样才能在不在 mdframed 中创建新行的情况下进行对齐?
 \begin{mdframed}[backgroundcolor=green]     
 \textbf{Theorem:}     
 \begin{center} A set $E$ is {\bf open} $\iff E^c$ is {\bf closed} \end{center}      
 \centerline{or equivalently,} 
 \centerline{A set $E$ is {\bf open} $\iff E^c$ is {\bf closed} }
\end{mdframed}

所以基本上我想Theorem在同一行上对齐\begin{center} A set $E$ is {\bf open} $\iff E^c$ is {\bf closed} \end{center}而不产生另一条新行。flushleft在中心环境内添加没有效果。

答案1

尝试使用仅有的 center然后\phantom对第一行进行一些框控制(通过):

在此处输入图片描述

\documentclass{article}
\usepackage{xcolor,mdframed}% http://ctan.org/pkg/{xcolor,mdframed}
\begin{document}
% Original layout/use
\begin{mdframed}[backgroundcolor=green]
  \textbf{Theorem:}
  \begin{center} A set $E$ is {\bf open} $\iff E^c$ is {\bf closed} \end{center}
  \centerline{or equivalently,}
  \centerline{A set $E$ is {\bf open} $\iff E^c$ is {\bf closed} }
\end{mdframed}

\bigskip

% Updated layout/use
\begin{mdframed}[backgroundcolor=green]
\begin{center}
  \textbf{Theorem:} \hfill A set~$E$ is \textbf{open} $\iff E^c$ is \textbf{closed} \hfill \phantom{\textbf{Theorem:}} \\
  or equivalently, \\
  A set~$E$ is \textbf{open} $\iff E^c$ is \textbf{closed}
\end{center}
\end{mdframed}

\end{document}

第一行设置为全宽,使用显示的定理:左边是\phantom 定理:在右侧。

相关内容