朋友们,
请看下面的代码。问题是环境在环境内部或直接在 下hlcard
时表现不同。我直接从网上选择了卡环境,但不太清楚那些长的可选参数在做什么。请帮忙。card
frame
内部的行为frame
是预期的行为
\documentclass[12pt]{beamer}
\usepackage[customcolors,shade]{hf-tikz}
\usetikzlibrary{arrows,shadows,petri,decorations.markings,shapes}
\RequirePackage[many]{tcolorbox}
\definecolor{dcol}{HTML}{3F51B5}
\definecolor{BGgrey03}{RGB}{190,190,190}
\definecolor{BGgrey04}{RGB}{230,230,230}
\usecolortheme[named=dcol]{structure}
\usepackage{biblatex}
\tcbset{%
colback=BGgrey04, colbacktitle=dcol, coltitle=white, coltext=dcol,%
enhanced, sharpish corners=all,%
fuzzy shadow={0mm}{0.9mm}{0.6mm}{0.2mm}{black!20!BGgrey03}, % top
fuzzy shadow={0mm}{-0.6mm}{-0.1mm}{0.2mm}{black!40!BGgrey03}, % bottomSmall
fuzzy shadow={0mm}{-0.2mm}{-0.2mm}{0.2mm}{black!20!BGgrey03}, % bottomBig
left=6mm, right=6mm, top=6mm, bottom=6mm, middle=4mm,%
title filled, boxrule=0mm, %
segmentation code={\path[draw=BGgrey01](segmentation.west) -- (segmentation.east);}%
}
\newenvironment{card}[1][pR23s2OTKY]{%
\ifthenelse{\equal{#1}{pR23s2OTKY}}{%
\begin{tcolorbox}%
}{%
\begin{tcolorbox}[colbacktitle=dcol, coltitle=white, title=#1, left=1mm, right=6mm, top=1mm,
bottom=1mm, middle=4mm, toptitle=1mm, bottomtitle=1mm, ]%
}%
}{%
\end{tcolorbox}%
}
\newenvironment{hlcard}[1][pR23s2OTKY]{%
\begin{tcolorbox}[noparskip, breakable, colback=dcol,%
coltitle=black,coltext=white, fonttitle={\bfseries \scshape}, left=1mm, right=6mm, top=1mm,
bottom=1mm, middle=4mm, toptitle=1mm, bottomtitle=1mm,]%
}{%
\end{tcolorbox}%
}
\begin{document}
\begin{frame}
\begin{card}[Problem]
\begin{hlcard}
Foo
\end{hlcard}
\end{card}
\begin{hlcard}
Bar
\end{hlcard}
\end{frame}
\end{document}
答案1
宏\tcbset
提供选项,即特定(或).style
的集合,否则任何未“包装”在中的选项都将全局使用,并对“层”产生副作用tcolorbox
tikz/pgfkeys
.style
tcolorbox
嵌套框reset
使用默认设置和来自的全局值tcbset
。
我建议使用一种outerlayer
样式和一种首先innerlayer
调用outerlayer
然后应用其自身设置的样式。
此外,应该用而不是将它们包装在宏中environments
来定义。\newtcolorbox
\newenvironment
\documentclass[12pt]{beamer}
\usepackage[customcolors,shade]{hf-tikz}
\usetikzlibrary{arrows,shadows,petri,decorations.markings,shapes}
\RequirePackage[many]{tcolorbox}
\definecolor{dcol}{HTML}{3F51B5}
\definecolor{BGgrey03}{RGB}{190,190,190}
\definecolor{BGgrey04}{RGB}{230,230,230}
\usecolortheme[named=dcol]{structure}
\usepackage{biblatex}
% Common options
\tcbset{%
left=6mm, right=6mm, top=6mm, bottom=6mm, middle=4mm,
}
\tcbset{
outerlayer/.style={
enhanced,
sharpish corners=all,
colbacktitle=dcol,
coltitle=white,
left=1mm,
right=6mm,
top=1mm,
bottom=1mm,
middle=4mm,
toptitle=1mm,
bottomtitle=1mm,
fuzzy shadow={0mm}{0.9mm}{0.6mm}{0.2mm}{black!20!BGgrey03}, % top
fuzzy shadow={0mm}{-0.6mm}{-0.1mm}{0.2mm}{black!40!BGgrey03}, % bottomSmall
fuzzy shadow={0mm}{-0.2mm}{-0.2mm}{0.2mm}{black!20!BGgrey03}, % bottomBig
title filled, boxrule=0mm, %
segmentation code={\path[draw=BGgrey01](segmentation.west) -- (segmentation.east);}
},
innerlayer/.style={outerlayer,
noparskip,
breakable,
colback=dcol,%
coltitle=black,
coltext=white,
fonttitle={\bfseries \scshape},
bottomtitle=1mm}
}
\newtcolorbox{card}[1][]{%
outerlayer,
title=#1,
}
\newtcolorbox{hlcard}[1][]{%
innerlayer,
#1
}
\begin{document}
\begin{frame}
\begin{card}[Problem]
\begin{hlcard}
Foo
\end{hlcard}
\end{card}
\begin{hlcard}
Bar
\end{hlcard}
\end{frame}
\end{document}