灵感来自 Indesign 的精美盒子

灵感来自 Indesign 的精美盒子

我在数学电子书中发现了这些漂亮的盒子,它们是由Adobe Indesign,我累了mdframedtcolorbox但我没有尝试 Tikz。

在此处输入图片描述 在此处输入图片描述

在此处输入图片描述

那么有人可以使用 LaTeX 创建它们吗?

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}

\tcbset{
    lemmastyle/.style={enhanced, colback=white, colframe=blue!50, arc=0pt, 
                       fonttitle=\bfseries, description color=Maroon,  
                       colbacktitle=white, coltitle=DarkOliveGreen,    
                       top=\tcboxedtitleheight,
                       boxed title style={arc=0pt},
                       attach boxed title to top right={yshift=-\tcboxedtitleheight/3, 
                                                                                                      xshift=-2mm}%
                      },
}

\newtcbtheorem{myLemma}{Type Text Here Without counter }{lemmastyle}{thm}

\usepackage{pifont}

\begin{document}

\begin{myLemma}{}{}
\end{myLemma}
\end{document}

更新:

谢谢,但是当我使用@代码时阿莱南诺,方程式不适合这个框。它比框宽。即使我放了长文本,框仍然太紧。我试图修复它,但没有成功。你能试试吗?你能让它可分解吗?(我说的“可分解”是指如果框包含长文本,内容可以在两页之间分解。)

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amsmath,amssymb}%      pour les maths
\usepackage{enumitem}


\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{tikz}

\tcbset{
    lemmastyle/.style={enhanced, colback=white, colframe=blue!20, arc=0pt, 
                       fonttitle=\bfseries, description color=Maroon,  
                       colbacktitle=white, coltitle=DarkOliveGreen,    
                       top=\tcboxedtitleheight,
                       boxed title style={arc=0pt},
                       attach boxed title to top left={yshift=-\tcboxedtitleheight/2,
                                                       xshift=4mm}%
                      },
}

\newtcbtheorem{myLemma}{Long text here without counter }{lemmastyle}{thm}

\usetikzlibrary{calc, fit}



\newcommand{\mybox}[4][8cm]{
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\node[line width=0.5mm, rounded corners, text width=#1, draw=#2] (one) {\vspace{25pt}\\ #4};
\node[text=white,anchor=north east,align=center, minimum height=20pt] (two) at (one.north east) {#3};
\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=25pt, text height=2ex] (three) at (one.north east) {#3 \hspace*{.5mm}};
\end{tikzpicture} 
\end{figure}
}

\usepackage{pifont}

\begin{document}


\mybox[6cm]{green!70!black}{Long Fancy Title}{
\begin{enumerate}
\item Show that 
${\displaystyle D_2f(x,y) = \frac{\partial {}}{\partial{y}} \left ( \int_0^xg_1 (t,0) \ dt + \int_0^y g_2(x,s) \ ds \right)}$
\item prove that 
${ \displaystyle \left(\forall x\in\mathbb{R}  \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y }$ 
\end{enumerate}
}

\begin{myLemma}{}{}
\begin{enumerate}
\item Show that 
${\displaystyle D_2f(x,y) = \frac{\partial {}}{\partial{y}} \left ( \int_0^xg_1 (t,0) \ dt + \int_0^y g_2(x,s) \ ds \right)}$
\item prove that 
${ \displaystyle \left(\forall x\in\mathbb{R}  \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y }$ 
\end{enumerate}
\end{myLemma}

\mybox[6cm]{blue!70!black}{Very Very Long 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.}

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}

在此处输入图片描述

答案1

这是使用 Tikz 实现此目的的一种方法。我只用常规文本测试了它,但作为节点,它应该也可以与其他图形元素配合使用。

编辑:varwidth我已经通过添加包和修复可选参数对您的方程式(以及可能的未来用途)进行了修复。

如果不指定参数,框将横跨整个textwidth。如果要使其更短,只需添加一个值,如\mybox[5cm]{...示例中的红色框所示。

输出

在此处输入图片描述

代码

\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}

答案2

以下代码显示了如何使用 来定义这些框(如 Alenanno 的解决方案中tcolorbox所示TiKZ)。这样,框就可以在页面之间分隔。

\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\makeatletter
\newtcolorbox{mytcbox}[2][]{%
enhanced, 
breakable,
colback=white,
colframe=blue!30!black,
attach boxed title to top right={yshift=-2pt}, title={#2},
boxed title size=standard,
boxrule=0pt,
boxed title style={%
    sharp corners, 
    rounded corners=northeast, 
    colback=tcbcol@frame, 
    boxrule=0pt},
sharp corners=north,
overlay unbroken={%
    \path[fill=tcbcol@back] 
        ([xshift=2pt]title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west) |- 
        ([xshift=2pt]title.south west)--cycle;
    \path[fill=tcbcol@frame] (title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west)
        [rounded corners=\kvtcb@arc] |- 
        (title.north-|frame.north) 
        [sharp corners] -| (title.south west);
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcol@frame] 
        (title.north east) rectangle 
        (frame.south west);
}, 
overlay first={%
    \path[fill=tcbcol@back] 
        ([xshift=2pt]title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west) |- 
        ([xshift=2pt]title.south west)--cycle;
    \path[fill=tcbcol@frame] (title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west)
        [rounded corners=\kvtcb@arc] |- 
        (title.north-|frame.north) 
        [sharp corners] -| (title.south west);
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcol@frame] 
        (frame.south west) |- (title.north) -| 
        (frame.south east);
}, 
overlay middle={%
    \draw[line width=.5mm, tcbcol@frame] 
    (frame.north west)--(frame.south west) 
    (frame.north east)--(frame.south east);
}, 
overlay last={%
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcol@frame] 
        (frame.north west) |- (frame.south) -|
        (frame.north east);
}, 
#1
}
\makeatother

\begin{document}

\begin{mytcbox}{Long fancy title}
\begin{enumerate}
\item Show that 
\[D_2f(x,y) = \frac{\partial{}}{\partial{y}} \left ( \int_0^xg_1 (t,0)\ dt + \int_0^y g_2(x,s)\ ds \right)\]
\item Prove that 
\[\left(\forall x\in\mathbb{R}  \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y\] 
\end{enumerate}
\end{mytcbox}

\begin{mytcbox}[width=6cm, colback=blue!20, colframe=red!70!black]{Long fancy title}
\lipsum[1-3]
\end{mytcbox}

\end{document}

在此处输入图片描述

更新:v4.20 的代码

自 v4.20 以来,tcolorboxes 颜色已记录(第 9.5 节),可轻松用于覆盖或底层定义。此更改与使用低级名称的旧版本代码不兼容。

例如,框架的颜色在内部被命名tcbcol@frame,现在为tcbcolframe。其他颜色也应进行类似的更改。

以前更新至 v4.20 的代码如下:

\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\makeatletter
\newtcolorbox{mytcbox}[2][]{%
enhanced, 
breakable,
colback=white,
colframe=blue!30!black,
attach boxed title to top right={yshift=-2pt}, title={#2},
boxed title size=standard,
boxrule=0pt,
boxed title style={%
    sharp corners, 
    rounded corners=northeast, 
    colback=tcbcolframe, 
    boxrule=0pt},
sharp corners=north,
overlay unbroken={%
    \path[fill=tcbcolback] 
        ([xshift=2pt]title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west) |- 
        ([xshift=2pt]title.south west)--cycle;
    \path[fill=tcbcolframe] (title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west)
        [rounded corners=\kvtcb@arc] |- 
        (title.north-|frame.north) 
        [sharp corners] -| (title.south west);
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcolframe] 
        (title.north east) rectangle 
        (frame.south west);
}, 
overlay first={%
    \path[fill=tcbcolback] 
        ([xshift=2pt]title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west) |- 
        ([xshift=2pt]title.south west)--cycle;
    \path[fill=tcbcolframe] (title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west)
        [rounded corners=\kvtcb@arc] |- 
        (title.north-|frame.north) 
        [sharp corners] -| (title.south west);
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcolframe] 
        (frame.south west) |- (title.north) -| 
        (frame.south east);
}, 
overlay middle={%
    \draw[line width=.5mm, tcbcolframe] 
    (frame.north west)--(frame.south west) 
    (frame.north east)--(frame.south east);
}, 
overlay last={%
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcolframe] 
        (frame.north west) |- (frame.south) -|
        (frame.north east);
}, 
#1
}
\makeatother

\begin{document}

\begin{mytcbox}{Long fancy title}
\begin{enumerate}
\item Show that 
\[D_2f(x,y) = \frac{\partial{}}{\partial{y}} \left ( \int_0^xg_1 (t,0)\ dt + \int_0^y g_2(x,s)\ ds \right)\]
\item Prove that 
\[\left(\forall x\in\mathbb{R}  \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y\] 
\end{enumerate}
\end{mytcbox}

\begin{mytcbox}[width=6cm, colback=blue!20, colframe=red!70!black]{Long fancy title}
\lipsum[1-3]
\end{mytcbox}

\end{document}

答案3

使用 Tikz 的盒子

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[x11names,usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\usetikzlibrary{calc}
%-----------
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
%----------
\definecolor{azzul}{RGB}{6,96,167}
%----------
\newcommand{\syBrisse}[6][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-4mm]{%
\begin{center}
\par\bigskip%
\begin{tikzpicture}
\node[rounded corners, text width=#1, align=justify, inner sep=8pt, outer sep=0] (one)
{\medskip\parbox[t]{\textwidth}{\vspace*{22pt}\par#6}};
\node[text=black,anchor=north east,align=center, minimum height=20pt, inner xsep=5pt] (two) at (one.north east) {#5 \hspace*{.5mm}};
\path[fill=#2,draw=#2]
    ($(one.north west)+(0ex,-4.5pt)$) [rounded corners=3pt] --
    ($(two.north west)+(-22pt,-4.5pt)$) --
    ($(two.south west)+(-4pt,0pt)$) [sharp corners] --
    (two.south east) [rounded corners] --
    (one.north east) --
    (one.north west) [sharp corners] -- cycle;
\node[text=black,anchor=north west,align=center, minimum height=20pt, text height=2ex,inner sep=8pt, inner ysep=3pt] (three) at ($(one.north west)+(0,-3pt)$) {#4};
\node[text=white,anchor=north east,align=center, minimum height=20pt, inner sep=8pt,inner ysep=6.5pt] (for) at ($(one.north east)+(0,1.5pt)$) {#5\hspace*{0.8mm}};
\path[draw=#2,line width=0.8pt]
    (one.south west) [rounded corners] --
    (one.south east) [rounded corners] --
    (one.north east) --
    (one.north west) [rounded corners] -- cycle;
\foreach \x in {10,20,...,100}
\path[opacity=\x*0.01]
    ($(one.north west)+(0.4pt,-6.5pt+\x/100)$) [rounded corners=3pt,draw=gray!\x] --
    ($(two.north west)+(-23.3pt+\x/100,-6.5pt+\x/100)$) [rounded corners=3.5pt,draw=gray!\x] --
    ($(two.south west)+(-5.3pt+\x/100,-1.9pt+\x/100)$) --
    ($(two.south east)+(-0.4pt,-1.9pt+\x/100)$);
\path[draw=white,line width=1.1pt]
    ($(one.north west)+(0.4pt,-5.2pt)$) [rounded corners=3pt] --
    ($(two.north west)+(-22.3pt,-5.2pt)$) [rounded corners=3.5pt] --
    ($(two.south west)+(-4.3pt,-0.6pt)$) --
    ($(two.south east)+(-0.4pt,-0.6pt)$);
\begin{pgfonlayer}{background}
\path[fill=#3!5]
    (one.south west) [rounded corners] --
    (one.south east) [rounded corners] --
    (one.north east) --
    (one.north west) [rounded corners] -- cycle;
\path[opacity=0.5, top color=#3!5,bottom color=#3,middle color=#3!30]
    (one.south west) [rounded corners] --
    (one.south east) [sharp corners] --
    ($(one.south east)+(0ex,0.8cm)$) --
    ($(one.south west)+(0ex,0.8cm)$) [rounded corners] -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{center}
}

\begin{document}
\section{Cuadro con syBrisse}
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.

\syBrisse[10cm]{Crimson}{Crimson}{}{\bf Note:}{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.}

\syBrisse{azzul}{azzul}{\it Text}{\bf 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 \bigl(\forall x\in\mathbb{R}  \bigr)\bigl(\forall y \in \mathbb{R} \bigr) 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.
}

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} 

结果

相关内容