Wrapfigure 和 tcolorbox

Wrapfigure 和 tcolorbox

我想將 tcolorbox 放入包裝圖中,如下所示:

\begin{wrapfigure}{r}{0.4\textwidth}
    \vspace{-8mm}
    \begin{tcolorbox}[width=\linewidth,
        colback=cyan!10!white,
        colframe=white,
        colbacktitle=cyan!30!white,
        fonttitle=\bfseries,
        coltitle=black!20!black,
        title= \vspace{1mm}My title,
        titlerule=1mm,
        titlerule style=cyan
        segmentation style={cyan, line width=1.5pt, solid}
        ]
        Just some text, but the titlerule is not working :(
        \tcblower
        More text, but the segmentation style is not working neither.
    \end{tcolorbox}
\end{wrapfigure}

不幸的是,標題規則不起作用(我只得到一個白色的標題規則)。有人可以跟我解釋為什麼嗎?

我也嘗試過這個MWE:

\documentclass[12pt,a4paper, xcolor=dvipsnames]{scrartcl}
\PassOptionsToPackage{svgnames}{xcolor}

\usepackage[ngerman]{babel}             
\usepackage[T1]{fontenc}            
\usepackage[utf8]{inputenc} 

\usepackage{tcolorbox}
\usepackage{blindtext}
\usepackage{wrapfig}

\begin{document}
    \begin{wrapfigure}{r}{0.4\textwidth}
        \begin{tcolorbox}[width=\linewidth,
            %enhanced jigsaw,
            colback=cyan!10!white,
            colframe=white,
            colbacktitle=cyan!30!white,
            fonttitle=\bfseries,
            coltitle=black!20!black,
            title= \vspace{1mm}My title,
            titlerule=3mm,
            titlerule style=red,
            segmentation style={cyan, line width=1.5pt, solid}
            ]
            Just some text, but the titlerule is not working :(
            \tcblower
            More text, but the segmentation style is not working neither.
        \end{tcolorbox}
    \end{wrapfigure}
\blindtext

\end{document}

但是titlerule style仍然segmentation style不起作用......

答案1

您應該將兩件事添加到程式碼中以使選項titlerule style可用segmentation style:1)您需要添加\tcbuselibrary{skins}到序言中,2)您需要添加enhanced到樣式選項中。

所以,完整的程式碼應該是這樣的:

\documentclass[12pt]{article}

\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{wrapfig}

\usepackage{blindtext}

\begin{document}

\begin{wrapfigure}{r}{0.4\textwidth}
    \begin{tcolorbox}[
        width=\linewidth,
        enhanced,
        colback=cyan!10!white,
        colframe=white,
        colbacktitle=cyan!30!white,
        fonttitle=\bfseries,
        coltitle=black!20!black,
        title={\vspace{1mm}My title},
        titlerule=3mm,
        titlerule style=cyan,
        segmentation style={cyan, line width=1.5pt, solid}
    ]
        Just some text, now the titlerule is working :)
        \tcblower
        More text, and the segmentation style is also working.
    \end{tcolorbox}
\end{wrapfigure}

\blindtext

\end{document}

在此輸入影像描述

抱歉,我首先沒有發現您程式碼中的問題!

相關內容