下面是我的代码,其中 myBox 定义与我为样式定义的标题颜色相冲突part
。知道为什么 \part 标题中的水平线会变成蓝色吗?我希望它是黑色。看起来 myBox 定义中的某些内容在之后强制使用蓝色。
\documentclass[draft]{book}
\usepackage[table]{xcolor}'
\usepackage{epigraph}
\usepackage{tabularx,booktabs}
\usepackage{blindtext}
\setlength\epigraphwidth{.6\textwidth}
\definecolor{myBlue}{RGB}{32,92,195}
\newenvironment{myBox}[1]
{\par\medskip\noindent\arrayrulewidth=1.5pt\arrayrulecolor{myBlue}%
\hfill\tabularx{0.95\textwidth}{!{\color{myBlue}\vrule width 1.5pt} X @{}}
\multicolumn{1}{@{}l} {\tabular{@{}l}\kern\tabcolsep\textbf{#1}\\\hline\endtabular}\\}
{\endtabularx\par\medskip}
\makeatletter
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\thispagestyle{epigraph}
\refstepcounter{part}%
\addcontentsline{toc}{part}{\partname~\thepart:\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
\markboth{}{}%
\reset@font
\parindent \z@
\vspace*{-400\p@}%
\hbox{%
\vbox{%
\hsize=7mm%
\makebox(0,0){\put(10,-100){\fbox{\phantom{\rule[-4cm]{7mm}{4cm}}}}}%
\begin{tabular}{@{}p{7mm}@{}}
\makebox[7mm]{\scshape\strut\small\partname}\\
\makebox[7mm] {\cellcolor{gray}\Huge\color{white}\bfseries\strut\thepart\rule[-4cm]{0pt}{4cm}}%
\end{tabular}%
}%
\kern6pt
\vbox to 0pt{%
\tabular[t]{@{}p{1cm}p{\dimexpr\hsize-2.55cm}@{}}\hline
& \Huge\itshape\rule{0pt}{1.5\ht\strutbox}#1\endtabular}%
}%
\cleardoublepage
}
\makeatother
\begin{document}
\tableofcontents
\cleardoublepage
\begin{myBox}{About Fairy tales}
Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us dragons can be beaten
\end{myBox}
\epigraphhead[450]{Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us dragons can be beaten.\par\hfill\textsc{C.K. Chesterton}}
\part{A Test Part Title}
\end{document}
答案1
这是因为声明\arrayrulecolor{…}
是全局的。只需替换代码的这一片段:
\newenvironment{myBox}[1]
{\par\medskip\noindent\arrayrulewidth=1.5pt\arrayrulecolor{myBlue}%
\hfill\tabularx{0.95\textwidth}{!{\color{myBlue}\vrule width 1.5pt} X @{}}
\multicolumn{1}{@{}l} {\tabular{@{}l}\kern\tabcolsep\textbf{#1}\\\hline\endtabular}\\}
{\endtabularx\par\medskip}
和
\newenvironment{myBox}[1]
{\par\medskip\noindent\arrayrulewidth=1.5pt\arrayrulecolor{myBlue}%
\hfill\tabularx{0.95\textwidth}{!{\color{myBlue}\vrule width 1.5pt} X @{}}
\multicolumn{1}{@{}l} {\tabular{@{}l}\kern\tabcolsep\textbf{#1}\\\hline\endtabular}\\}
{\endtabularx\par\medskip\arrayrulecolor{black}}