我正在使用mdframed
选项tikz
来定义我自己的环境。不幸的是,如果我使用带有命令的tabularx
环境,它会覆盖我的框的标题。xcolor
\cellcolor
这是一个最小的工作示例:
\documentclass[a4paper,10pt,DIV=1]{scrreprt}
\usepackage{multirow,tabularx}
\usepackage[table]{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{mystyle}{%
linecolor=black,
linewidth=0.5pt,
topline=true,
innerleftmargin=0pt,
innerrightmargin=0pt,
innertopmargin=0pt,
innerbottommargin=0pt,
frametitleaboveskip=1.2\dimexpr-\ht\strutbox\relax,
}
\makeatletter
\def\field{\cellcolor{gray!25}~}%
\makeatother
\newenvironment{ProtocolBox}[1][]{%
\mdfsetup{%
style = mystyle,
frametitlealignment={\hspace*{0.01\linewidth}\vspace{-1.63em}},
frametitle={%
\tikz{[
baseline=(current bounding box.east),
outer sep=0pt
]
\node[
draw = white,
line width = 1pt,
text = black,
anchor=east,rectangle,
fill=white,
]
{\strut #1};
}
}
}
\begin{mdframed}[userdefinedwidth=\linewidth]\relax%
}{\end{mdframed}}
\begin{document}
\begin{ProtocolBox}[Header]
\begin{tabularx}{\linewidth}{X}
\vspace{0.1em}\field The Background of the cell is overlaying the background of the box header
\end{tabularx}
\end{ProtocolBox}
\end{document}
你知道我该如何定义图层的“顺序”,以便标题背景始终位于前面吗?
谢谢