fancytheorem-1代码实现如下:

\documentclass{article}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{ifmtarg}% http://ctan.org/pkg/ifmtarg
\usepackage{xifthen}% http://ctan.org/pkg/xifthen
\usepackage{environ}% http://ctan.org/pkg/environ
\usepackage{multido}% http://ctan.org/pkg/multido
\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\makeatletter%
\newcommand{\theoremhang}{% top theorem decoration
  \begingroup%
  \setlength{\unitlength}{.005\linewidth}% \linewidth/200
    \begin{picture}(0,0)(1.5,0)%
      \linethickness{0.45pt} \color{black!50}%
      \put(-3,2){\line(1,0){206}}% Top line
      \multido{\iA=2+-1,\iB=50+-10}{5}{% Top hangs
        \color{black!\iB}%
        \put(-3,\iA){\line(0,-1){1}}% Top left hang
        \put(203,\iA){\line(0,-1){1}}% Top right hang
      }%
    \end{picture}%
  \endgroup%
}%
\newcommand{\theoremhung}{% bottom theorem decoration
  \nobreak
  \begingroup%
    \setlength{\unitlength}{.005\linewidth}% \linewidth/200
    \begin{picture}(0,0)(1.5,0)%
      \linethickness{0.45pt} \color{black!50}%
      \put(-3,0){\line(1,0){206}}% Bottom line
      \multido{\iA=0+1,\iB=50+-10}{5}{% Bottom hangs
        \color{black!\iB}%
        \put(-3,\iA){\line(0,1){1}}% Bottom left hang
        \put(203,\iA){\line(0,1){1}}% Bottom right hang
      }%
    \end{picture}%
  \endgroup%
}%

\newcounter{theorem}
\renewcommand{\thetheorem}{\arabic{theorem}}
\NewEnviron{theorem}[1][]{%
    \par\noindent\theoremhang\par\nobreak\noindent%\addvspace{-.5ex}
    \refstepcounter{theorem}\postdisplaypenalty=10000 %
    {\sffamily\bfseries\upshape Theorem \thetheorem\@ifnotmtarg{#1}{\ (#1)}}\ \ \itshape\ignorespaces%
    \BODY % Typeset theorem body/content
    \par\addvspace{-1ex}\nobreak\noindent\theoremhung\par\addvspace{.4ex}%
}
\makeatother

\begin{document}

\lipsum[1]

\begin{theorem}[Special theorem]
\lipsum[2]
\end{theorem}

And then there is also

\begin{theorem}[Short theorem]
This is just a short theorem description.
\end{theorem}

\lipsum[3]

\end{document}

选自:http://tex.stackexchange.com/questions/11098/nice-formatting-for-theorems

点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部