在禁忌中使用 makecell:與 tcolorbox 和 todonotes 套件不相容

在禁忌中使用 makecell:與 tcolorbox 和 todonotes 套件不相容

tabu我在使用makecell 和tcolorbox的包時遇到問題todonotes。這是我的最小範例程式碼:

\documentclass[a4paper]{scrreprt}
\usepackage{tcolorbox}
\usepackage{todonotes}
\usepackage{tabu,makecell}
\begin{document}
\noindent \begin{tabu} to \textwidth {@{}lXX}
normal line & A & B \\
line with makecell & \makecell[tl]{A\\C} & \makecell[tl]{B\\D\\E}
\end{tabu}
\todo{To Do: ...}
\end{document}

當我排除 行時\makecell,一切正常。此外,當我排除套件todotcolorbox(當然,還有帶有\todo命令的行,但保留帶有 的行\makecell)時,一切正常。

當我至少包含一個包tcolorboxtodonotes.然後我收到以下錯誤:

./test-tabu.tex:9: Improper \prevdepth.
\tabu@verticalspacing ...tempdimc \the \prevdepth 
                                              \@tempdima \dimexpr \ht 
\t...
l.9 \end{tabu}

解決方案也來自禁忌:更新後出錯沒有幫助。

有誰知道如何解決這個問題?

這是日誌檔案的第一行:

這是 pdfTeX,版本 3.14159265-2.6-1.40.19 (TeX Live 2018)(預先載入格式=pdflatex)

答案1

新的 LaTeX3 包tabularray是過時軟體包的替代方案tabu

\documentclass[a4paper]{scrreprt}

\usepackage{tcolorbox}
\usepackage{todonotes}
\usepackage{tabularray}

\begin{document}

\noindent
\begin{tblr}{
  width = \textwidth,
  colspec = {@{}lXX},
}
  normal line        & A                   & B \\
  line with makecell & \SetCell{t,l}{A\\C} & \SetCell{t,l}{B\\D\\E} \\
\end{tblr}
\todo{To Do: ...}

\end{document}

在此輸入影像描述

答案2

以下是您可以使用{NiceTabular}of執行的操作nicematrix(與tcolorbox和相容todonotes)。

\documentclass[a4paper]{scrreprt}

\usepackage{tcolorbox}
\usepackage{todonotes}
\usepackage{nicematrix}

\begin{document}

\noindent
\begin{NiceTabular}{@{}lXX}
  normal line        & A                   & B \\
  line with makecell & \Block[t,l]{}{A\\C} & \Block[t,l]{}{B\\D\\E} \\
\end{NiceTabular}

\bigskip
\todo{To Do: ...}

\end{document}

您需要多次編譯(因為nicematrix在背景使用 PGF/Tikz 節點)。

上述程式碼的輸出

相關內容