\documentclass[a4paper]{article} \usepackage{tikz} \usepackage{amsmath} \usepackage{amsmath,amssymb}% pour les maths \usepackage{enumitem} \usepackage{varwidth} \usetikzlibrary{calc} \newcommand{\mybox}[4][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-2mm]{% \begin{figure}[!h] \centering \begin{tikzpicture} \node[line width=.5mm, rounded corners, draw=#2, inner ysep=10pt, text width=#1, outer sep=0] (one) {\vspace*{15pt}\\\begin{varwidth}{\textwidth}#4\end{varwidth}}; \node[text=white,anchor=north east,align=center, minimum height=20pt] (two) at (one.north east) {#3 \hspace*{.5mm}}; \path[fill=#2] (one.north west|-two.west) -- ($(two.west)+(-1.5cm,0)$) to[out=0,in=180] (two.south west) -- (two.south east) [rounded corners] -- (one.north east) -- (one.north west) [sharp corners] -- cycle; \node[text=white,anchor=north east,align=center, minimum height=20pt, text height=2ex] (three) at (one.north east) {#3 \hspace*{.5mm}}; \end{tikzpicture} \end{figure} } \begin{document} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae augue feugiat, ultrices nunc et, maximus nisl. Etiam in dolor id lacus semper luctus eu vitae sem. Pellentesque pharetra urna in magna sagittis dignissim. Morbi nec urna sagittis, eleifend erat id, varius est. \mybox[5cm]{red!70!black}{Fancy Title}{Duis id dolor et ligula eleifend imperdiet. Mauris luctus, quam vitae viverra sagittis, dolor nibh imperdiet augue, eu venenatis eros augue et nisl. Vivamus nec fermentum est.} \mybox{green!70!black}{Super Mega Ultra Long Fancy Title}{ \begin{enumerate} \item Show that\\ $\displaystyle D_2f(x,y) = \frac{\partial {}}{\partial{y}} \biggl( \int_0^xg_1 (t,0) \ dt + \int_0^y g_2(x,s) \ ds \biggr)$ \item prove that\\ $\displaystyle \biggl(\forall x\in\mathbb{R} \biggr)\biggl(\forall y \in \mathbb{R} \biggr) x\neq y\, \text{ and } \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y$ \end{enumerate}} Nullam libero augue, luctus et est vitae, fermentum aliquet libero. Maecenas dictum placerat eros, eu fermentum sem fermentum dapibus. Quisque non tellus nec magna feugiat luctus. \end{document}
选自:http://tex.stackexchange.com/questions/281375/inspired-beautiful-box-from-indesign
发表评论 取消回复