发布时间:2011-06-13 01:55:03文章类别:TeX绘图原文地址:http://blog.sina.com.cn/s/blog_5e16f177010172lr.html
QQ群:91940767/145316219/141877998/80300084/194770436淘宝店:http://latexstudio.taobao.com
代码如下:
\usepackage{tikz} \usetikzlibrary{shapes,shadows} \tikzstyle{abstractbox} = [draw=black, fill=white, rectangle, inner sep=10pt, style=rounded corners, drop shadow={fill=black, opacity=1}] \tikzstyle{abstracttitle} =[fill=white] \newsavebox{\myabstractbox} \providecommand{\abstractnode}[2]{\begin{tikzpicture}% \node [abstractbox, fill=#1] (box)% {#2};% \node[abstracttitle, right=10pt] at (box.north west) {Abstract}; \end{tikzpicture}} \newenvironment{abstractbox}[1][white]{ \begin{center}% \def\abs@bgcol{#1}% \begin{lrbox}{\myabstractbox}\begin{minipage}{.80\linewidth}% % \parindent2em% } {\end{minipage}\end{lrbox}\par% \abstractnode{\abs@bgcol}{\usebox{\myabstractbox}}% \end{center}% }
测试代码如下:
\documentclass{article} \usepackage{xcolor} \usepackage{tikz} \usetikzlibrary{shapes,shadows} \tikzstyle{abstractbox} = [draw=black, fill=white, rectangle, inner sep=10pt, style=rounded corners, drop shadow={fill=black, opacity=1}] \tikzstyle{abstracttitle} =[fill=white] \newsavebox{\myabstractbox} \providecommand{\abstractnode}[2]{\begin{tikzpicture}% \node [abstractbox, fill=#1] (box)% {#2};% \node[abstracttitle, right=10pt] at (box.north west) {Abstract}; \end{tikzpicture}} \newenvironment{abstractbox}[1][white]{ \begin{center}% \def\abs@bgcol{#1}% \begin{lrbox}{\myabstractbox}\begin{minipage}{.80\linewidth}% % \parindent2em% } {\end{minipage}\end{lrbox}\par% \abstractnode{\abs@bgcol}{\usebox{\myabstractbox}}% \end{center}% } \begin{document} \begin{abstractbox} Recently a friend of mine asked me if I could help him creating a boxed abstract. Normally a \verb|\framebox{}| would have done the trick, but he wanted the word ``Abstract'' in the top left corner of the box. I tried a few variations on his start, but in the end I realised I could try my newly developped tikz skills on it. Together with Google I came up with the following solution that loads the tikz package and then defines the command. \end{abstractbox} \begin{abstractbox}[gray!5] Recently a friend of mine asked me if I could help him creating a boxed abstract. Normally a \verb|\framebox{}| would have done the trick, but he wanted the word ``Abstract'' in the top left corner of the box. I tried a few variations on his start, but in the end I realised I could try my newly developped tikz skills on it. Together with Google I came up with the following solution that loads the tikz package and then defines the command. \end{abstractbox} \end{document}
发表评论 取消回复