使用 tcolorbox 进行格式化

使用 tcolorbox 进行格式化

我想使用在网站上找到的照片中显示的格式。但是,由于该网站是中文的,我无法下载。您能帮助我获取格式或找到其他来源吗?在此处输入图片描述 代码网站:https://www-latexstudio-net.translate.goog/index/details/index/mid/2452?_x_tr_sl=en&_x_tr_tl=fr&_x_tr_hl=fr&_x_tr_pto=wapp

答案1

提出了一些可用于提供与这些框非常相似的东西的代码软件包 pgfkeys:我不知道密钥“/tcb/O”,我将忽略它。我修改了此代码以提供此处所见的内容:带有尖角的框、连续枚举、调整到左上角的标题以及使用断开的左箭头制作可破坏框的选项。

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum,lmodern}

\newcounter{myboxcounter}

\tcbset{
    myboxstyle/.style={
        enhanced, breakable,
        sharp corners,
        left skip=8mm,
        attach boxed title to top left={yshift*=-\tcboxedtitleheight/2},
        boxed title style={colframe=#1!40, height=6mm, bean arc, boxrule=1pt},
        colback=#1!10, colframe=#1!30, boxrule=1pt,
        coltitle=black, colbacktitle=#1!10,
        fonttitle=\bfseries,
        underlay boxed title={%
            \node[circle, fill=#1!10, draw=#1!40, inner sep=1pt, minimum size=6mm, line width=1pt, font=\bfseries] (boxnumber) at ([xshift=-6mm]title.west) {\thetcbcounter};
        },
        underlay unbroken={%
            \draw[#1!40, line width=1pt] (title.west)--(boxnumber);
            \draw[#1!40, -{stealth}, line width=1pt] (boxnumber)--(boxnumber|-frame.south);
        },
        underlay first={%
            \draw[#1!40, line width=1pt] (title.west)--(boxnumber);
            \draw[#1!40, line width=1pt] (boxnumber)--(boxnumber|-frame.south);
        },
        underlay middle={%
            \draw[#1!40, line width=1pt] (boxnumber|-frame.north)--(boxnumber|-frame.south);
        },
        underlay last={%
            \draw[#1!40, -{stealth}, line width=1pt] (boxnumber|-frame.north)--(boxnumber|-frame.south);
        },
    }
}

\newtcolorbox[use counter=myboxcounter]{example}[2][]{%
    myboxstyle=#2, title=Example, #1
}

\newtcolorbox[use counter=myboxcounter]{solution}[2][]{%
    myboxstyle=#2, title=Solution, #1
}

\begin{document}

\lipsum[1]

\begin{example}{blue}
    \lipsum[1][1-2]
\end{example}

\begin{solution}{red}
    \lipsum[2]
\end{solution}

\begin{example}{green}
    \lipsum[3-7]
\end{example}

\begin{solution}{yellow}
    \lipsum[1-5]
\end{solution}

\end{document}

在此处输入图片描述

相关内容