TikZ 与特殊表的组合:难度

TikZ 与特殊表的组合:难度

参考前面两个问题精美表格的特定格式对漂亮的桌子进行一些调整 我的所有用户都给出了出色的答案,例如,我使用了@Zarko 和@marmot 的代码组合。
显然,我选择了很长的代码的一部分来创建可编译的 MWE。如果我编译此摘录,我已经出现错误:

LaTeX 错误:包 xcolor 的选项冲突。[\definecolor]

未定义控制序列。[\arrayrulecolor]

LaTeX 错误:缺少 \begin{document}。[\arrayrulecolor{t]

\documentclass[a4paper,12pt,italian]{article}
\usepackage{babel,newtxtext}
\usepackage{mathtools,amssymb,isotope,tikz}
\usepackage[svgnames,dvipsnames,table,x11names]{xcolor} 
\definecolor{mgreen}{RGB}{150,196,95}
\definecolor{nteal}{RGB}{60,172,147}
\usepackage[labelformat=simple]{caption}
\usepackage[labelformat=simple]{subcaption}
\definecolor{nteal}{RGB}{60,172,147}
%%%%%%%%%%%%%%% @Zarko code %%%%%%%%%%%%%%%

\usepackage{booktabs, makecell, threeparttable}       % <---
\setlength\heavyrulewidth{2pt}    % <---
\setlength\lightrulewidth{1.2pt}  % <---
\setcellgapes{3pt}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadgape{}
\arrayrulecolor{teal}
\usepackage[skip=0.5ex]{caption}
\DeclareCaptionLabelFormat{uc}{\MakeUppercase{#1}~#2} 
\DeclareCaptionFont{cond}{\color{nteal}\fontfamily{CabinCondensed-TLF}\selectfont}
\DeclareCaptionFont{teal}{\color{black}\fontfamily{ptm}\selectfont}
\captionsetup[table]{font={small},
                     labelformat=uc,
                     labelfont={cond,bf},
                     textfont=teal,
                     singlelinecheck=off}

%%%%%%%%%%%%%%% @marmot code %%%%%%%%%%%%%%%


\DeclareCaptionFormat{Sebastiano}{%#1#2\par
{\tikz[remember picture,baseline=-0.5ex]{%
\node[fill=mgreen,text=white,font=\bfseries\sffamily\large,rounded
corners=0.2em,minimum width=1.8em,minimum height=1.8em](M){#1};
\draw[very thick,mgreen] (M.west) -- ++ (-1,0);}}%
\hfill\hfill{\tikz[remember picture,overlay]{\coordinate(R);
\draw[very thick,mgreen] (M.east) -- (M.east-|R);
}}\par
#3} 
\DeclareCaptionFormat{Incredibile}{%#1#2\par
{\tikz{%
\node[text width=\linewidth-4pt,outer xsep=1.6pt,align=justify](MI){\textbf{\sffamily#1#2}#3};
\draw[very thick,mgreen] (MI.north west) -- (MI.south west)
(MI.north east) -- (MI.south east);
}}\par
} 
\captionsetup{format=Incredibile}
\captionsetup[sub]{format=Sebastiano}
\newcommand{\IncludeClippedGraphics}[2][]{\begin{tikzpicture} 
\node[rounded corners=5pt,clip,preaction={draw=mgreen,very thick},inner sep=-2pt]{%
\includegraphics[#1]{#2}}; 
\end{tikzpicture}}


\begin{document}
\begin{table}[htb]
\captionsetup{justification=centering}
\caption{Le quattro serie radioattive con $n\in \mathbb{N}$.}
\makegapedcells
\centering
\begin{tabular}{cccc}
\toprule
\thead{Numeri\\ di massa}
        & \thead{Elemento\\ chimico}
                        & \thead{Prodotto\\ iniziale}
                                                    & \thead{Prodotto\\ finale}\\
    \midrule
$4n$    &  Torio        &   \isotope[232][90]{Th}   &   \isotope[208][82]{Pb}   \\
$4n+1$  &  Neptunio     &   \isotope[237][93]{Np}   &   \isotope[209][83]{Bi}   \\
$4n+2$  &  Uranio       &   \isotope[238][92]{U}    &   \isotope[206][82]{Pb}   \\
$4n+3$  &  Attinio      &   \isotope[235][92]{U}    &   \isotope[207][82]{Pb}   \\
    \bottomrule
\end{tabular}
\end{table}
\end{document}

目前,我不知道如何修复错误,以及我是否忘记插入一些必不可少的包或宏。行没有颜色并非巧合。

在此处输入图片描述

我不明白的是,在我的structure.tex文件中,有所有的包和宏,在编译我的书的过程中,我发现没有加载字体CabinCondensed-TLF

在此处输入图片描述 使用此提取物

\DeclareCaptionLabelFormat{uc}{\MakeUppercase{#1}~#2} 
\DeclareCaptionFont{cond}{\color{nteal}\fontfamily{CabinCondensed-TLF}\selectfont}
\DeclareCaptionFont{teal}{\color{black}\fontfamily{ptm}\selectfont}
\captionsetup[table]{font={small},
                     labelformat=uc,
                     labelfont={cond,bf},
                     textfont=teal,
                     singlelinecheck=off}

一个月前一切都运行正常,但现在我不明白动机以及如何解决问题。

答案1

以下是标签字体和选项冲突的解决方案:

    \documentclass[a4paper, 12pt ,italian]{article}
    \usepackage{babel,newtxtext}
    \PassOptionsToPackage{svgnames, dvipsnames, table, x11names}{xcolor}
    \usepackage{mathtools, amssymb, isotope, tikz}

    \definecolor{mgreen}{RGB}{150,196,95}
    \definecolor{nteal}{RGB}{60,172,147}
    \usepackage[labelformat=simple]{caption}
    \usepackage[labelformat=simple]{subcaption}
    \definecolor{nteal}{RGB}{60,172,147}
    %%%%%%%%%%%%%%% @Zarko code %%%%%%%%%%%%%%%

    \usepackage{booktabs, makecell, threeparttable} % <---
    \setlength\heavyrulewidth{2pt} % <---
    \setlength\lightrulewidth{1.2pt} % <---
    \setcellgapes{3pt}
    \renewcommand\theadfont{\normalsize\bfseries}
    \renewcommand\theadgape{}
    \arrayrulecolor{teal}
    \usepackage[skip=0.5ex]{caption}
    \DeclareCaptionLabelFormat{uc}{\MakeUppercase{#1}~#2}
    %\DeclareCaptionFont{cond}{\color{nteal}\fontfamily{CabinCondensed-TLF}\selectfont}
    \DeclareCaptionFont{cond}{\color{nteal}\usefont{T1}{Cabin-TLF}{condensed}{sc}}
    \DeclareCaptionFont{teal}{\color{black}\fontfamily{ptm}\selectfont}
    \captionsetup[table]{font={small},
                         labelformat=uc,
                         labelfont={cond,bf},
                         textfont=teal,
                         singlelinecheck=off}

    %%%%%%%%%%%%%%% @marmot code %%%%%%%%%%%%%%%


    \DeclareCaptionFormat{Sebastiano}{%#1#2\par
    {\tikz[remember picture,baseline=-0.5ex]{%
    \node[fill=mgreen,text=white,font=\bfseries\sffamily\large,rounded
    corners=0.2em,minimum width=1.8em,minimum height=1.8em](M){#1};
    \draw[very thick,mgreen] (M.west) -- ++ (-1,0);}}%
    \hfill\hfill{\tikz[remember picture,overlay]{\coordinate(R);
    \draw[very thick,mgreen] (M.east) -- (M.east-|R);
    }}\par
    #3}
    \DeclareCaptionFormat{Incredibile}{%#1#2\par
    {\tikz{%
    \node[text width=\linewidth-4pt,outer xsep=1.6pt,align=justify](MI){\textbf{\sffamily#1#2}#3};
    \draw[very thick,mgreen] (MI.north west) -- (MI.south west)
    (MI.north east) -- (MI.south east);
    }}\par
    }
    \captionsetup{format=Incredibile}
    \captionsetup[sub]{format=Sebastiano}
    \newcommand{\IncludeClippedGraphics}[2][]{\begin{tikzpicture}
    \node[rounded corners=5pt,clip,preaction={draw=mgreen,very thick},inner sep=-2pt]{%
    \includegraphics[#1]{#2}};
    \end{tikzpicture}}

    \begin{document}

    \begin{table}[htb]
    \captionsetup{justification=centering}
    %\caption{\fontfamily{CabinCondensed-TLF}\selectfont Le quattro serie radioattive con $n ∈ \mathbb{N}$.}
    \caption{Le quattro serie radioattive con $n ∈ \mathbb{N}$.}
    \makegapedcells
    %\caption{\fontfamily{CabinCondensed-TLF}\selectfont Le quattro serie radioattive con $n ∈ \mathbb{N}$.}
    \centering
    \begin{tabular}{cccc}
    \toprule
    \thead{Numeri\\ di massa}
            & \thead{Elemento\\ chimico}
                            & \thead{Prodotto\\ iniziale}
                                                        & \thead{Prodotto\\ finale}\\
        \midrule
    $4n$ & Torio & \isotope[232][90]{Th} & \isotope[208][82]{Pb} \\
    $4n+1$ & Neptunio & \isotope[237][93]{Np} & \isotope[209][83]{Bi} \\
    $4n+2$ & Uranio & \isotope[238][92]{U} & \isotope[206][82]{Pb} \\
    $4n+3$ & Attinio & \isotope[235][92]{U} & \isotope[207][82]{Pb} \\
        \bottomrule
    \end{tabular}
    \end{table}

    \end{document} 

在此处输入图片描述

答案2

第一个错误消息是

l.5 \definecolor
                {mgreen}{RGB}{150,196,95}
? h
The package xcolor has already been loaded with options:
  []
There has now been an attempt to load it with options
  [svgnames,dvipsnames,table,x11names]
Adding the global options:
  ,svgnames,dvipsnames,table,x11names
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.
? 

实际上问题是 xcolor 是由 tikz 加载的,因此您无法稍后使用不同的选项加载它,而应尽早加载它:

\usepackage[svgnames,dvipsnames,table,x11names]{xcolor} 
\usepackage{mathtools,amssymb,isotope,tikz}

然后文档就会正常运行。

相关内容