tcolorbox 文件:防止頭部和身體之間存在空間

tcolorbox 文件:防止頭部和身體之間存在空間

我用來tcolorbox記錄一些命令,並且我想在命令解釋的正文上有輕微的背景顏色。我有下面的 MWE 通過將主體包裝在它自己的 tcolorbox 中來顯示這一點colback

但是,我想刪除頭部和身體之間的空白,以便它們直接連接。我嘗試透過nobeforeafter和s調整盒子,before/after skip但沒有成功。

我懷疑主體(以及我用before/after doc body序言中的鍵創建的 tcolorbox)被包裹在某些東西中,但我不知道如何訪問和更改它。

例子

\documentclass{article}

\usepackage{tcolorbox}
\tcbuselibrary{documentation}

\tcbset{
    doc head={
        interior style={fill,color=blue!10},
        boxsep=2pt,
        after skip=0pt,
        nobeforeafter,
        %show bounding box,
    },
    before doc body={
        \begin{tcolorbox}[
            colback=blue!5,
            colframe=blue!5,
            arc=0pt,
            outer arc=0pt,
            before skip=0pt,
            nobeforeafter,
        ]
    },
    after doc body={\end{tcolorbox}},
}


\begin{document}

\begin{docCommand}
    {myCommand}
    {\marg{argument}}
    Some description of the command. Blah blah blah.
\end{docCommand}

\end{document}

答案1

文檔頭tcolorbox放置在 a 內tcbraster,跳過後預設為 4.1pt。需要使用以下方法將其設為 0pt doc raster={raster after skip=0pt},然後刪除間隙:

\documentclass{article}

\usepackage{tcolorbox}
\tcbuselibrary{documentation}

\tcbset{
    doc head={
        interior style={fill,color=blue!10},
        boxsep=2pt,
    },
    doc raster={raster after skip=0pt},
    before doc body={
        \begin{tcolorbox}[
            colback=blue!5,
            colframe=blue!5,
            arc=0pt,
            outer arc=0pt,
            before skip=0pt,
        ]
    },
    after doc body={\end{tcolorbox}},
}


\begin{document}

\begin{docCommand}
    {myCommand}
    {\marg{argument}}
    Some description of the command. Blah blah blah.
\end{docCommand}

\end{document}

輸出

相關內容