為什麼第 345 頁上的 tcolorbox 範例不起作用

為什麼第 345 頁上的 tcolorbox 範例不起作用

我希望能提高我關於tcolorbox.. 的(非常基礎的)知識,所以我嘗試編譯第 345 頁中的範例(第 18 章:庫「hooks」)。編譯它我收到警告:

\RequiredPackage{minted}{2011/09/17]

我已經透過 MikTeX 套件管理器安裝了它,然後在強制編譯後詢問

\minted@appathifexist=

ETC

我使用最新的具有管理權限的 64 位元 MikTeX 和 WinEdt 作為編輯器。範例程式碼如下:

\documentclass{article}
\usepackage[all]{tcolorbox}
    \usepackage{array,tabularx}%,longtable,tabu

    \begin{document}
    \newcolumntype{Y}{>{\raggedleft\arraybackslash}X}% see tabularx
\tcbset{enhanced,fonttitle=\bfseries\large,
        fontupper=\normalsize\sffamily,
        colback=yellow!10!white,colframe=red!50!black,
        colbacktitle=orange!30!white,%=Salmon!30!white
        coltitle=black,center title,
    tabularx={X||Y|Y|Y|Y||Y},% this sets ’before upper’ and ’after upper’
        before upper app={Group & One & Two & Three & Four & Sum\\
                          \hline\hline} }
\begin{tcolorbox}[title=My table]
Red & 1000.00 & 2000.00 & 3000.00 & 4000.00 & 10000.00\\\hline
Green & 2000.00 & 3000.00 & 4000.00 & 5000.00 & 14000.00\\\hline
Blue & 3000.00 & 4000.00 & 5000.00 & 6000.00 & 18000.00\\\hline\hline
Sum & 6000.00 & 9000.00 & 12000.00 & 15000.00 & 42000.00
\end{tcolorbox}
    \end{document}

最後我上面的程式碼產生了以下圖片:

在此輸入影像描述

我希望這會像手冊中的其他一些示例一樣“開箱即用”,所以不知道我做錯了什麼或錯過了什麼。

答案1

如果我不加載,我會得到與你相同的輸出colortbl:錯誤是!

Undefined control sequence.
\tcb@after@box ->\endtabularx \arrayrulecolor 
                                              {black}
l.20 \end{tcolorbox}

並且\arrayrulecolor是 的命令colortbl

如果我添加colortbl到包列表(或者,正如 Gonzalo Medina 建議的那樣,添加table到 的選項\documentclass),輸出為

在此輸入影像描述

沒有任何錯誤。

相關內容