tcolorbox 中的透明度选项

tcolorbox 中的透明度选项

大家好!这里我想要透明背景tcolorbox,当框进入框或页面颜色应用情况时。这里我使用了黄色背景框,所以我需要黄色背景,我无法将第二个框颜色变为透明。如果有任何选项可以使用更改背景颜色tcolorbox。请做必要的操作。

在此处输入图片描述

\documentclass[12pt]{article}

\RequirePackage[most]{tcolorbox}
\usetikzlibrary{patterns,shadows}

\newenvironment{Boxone}{\begin{tcolorbox}[colback=yellow!30,colbacklower=white,]
}{\end{tcolorbox}}

\newenvironment{Boxtwo}{\begin{tcolorbox}[colback=white,colbacklower=white]
}{\end{tcolorbox}}


\begin{document}

\begin{Boxone}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\begin{Boxtwo}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\end{Boxtwo}
\end{Boxone}

\end{document}

答案1

使用enhanced jigsawopacityback,您可以使其tcolorbox透明。顺便说一句,我不知道您为什么要colbacklower在这里使用...

\documentclass[12pt]{article}

\RequirePackage[most]{tcolorbox}
\usetikzlibrary{patterns,shadows}

\newenvironment{Boxone}{\begin{tcolorbox}[colback=yellow!30]
}{\end{tcolorbox}}

\newenvironment{Boxtwo}{\begin{tcolorbox}[opacityback=0,enhanced jigsaw]
}{\end{tcolorbox}}


\begin{document}

\begin{Boxone}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\begin{Boxtwo}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\end{Boxtwo}
\end{Boxone}

\begin{Boxtwo}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\end{Boxtwo}
\end{document}

黄色框内:

在此处输入图片描述

不包含任何东西:

在此处输入图片描述


但是,你不应该使用(或者至少我不建议你使用)\newenvironment来定义一个新的tcolorbox。该包有一个宏。

\documentclass[12pt]{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{patterns,shadows}
\newtcolorbox{Boxone}{colback=yellow!30}
\newtcolorbox{Boxtwo}{opacityback=0,enhanced jigsaw}
\begin{document}
\begin{Boxone}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\begin{Boxtwo}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\end{Boxtwo}
\end{Boxone}

\begin{Boxtwo}
A patient asks you how many medicines they need to swallow to take all their morning medicines. They have the following medicines to take:
\end{Boxtwo}
\end{document}

相关内容