我想要上部右侧的下部。
为什么我没有获得下部的顶部对齐?
valign lower=top, % <------ Problem here!
没有效果。
附言:仅出于兴趣:“下部标题”有什么特殊之处吗?
\documentclass[12pt]{article}
\usepackage[showframe=false,
margin=2cm,
]{geometry}
\usepackage[most]{tcolorbox}
\newtcolorbox{mybox}[1][]{
enhanced, %
boxrule=0pt, frame hidden, % no Frame
%colframe=white,
colback=yellow!25,
arc=2pt, % "rounded corners"
% halign=flush center,
% Title =====================
colbacktitle=yellow!25,
coltitle=black, % Fontcolor Title
fonttitle=\bfseries\Large,
% Alignment =====================
valign lower=top, % <------ Problem here!
#1, % eventually further optional keys
}
\tcbset{
splitten/.style={
% "Lower Part" =================
lower separated=false,%
sidebyside, % Lower part to the right
},
}
\newcommand\TikzI{
\vbox{\begin{tikzpicture}[]
\draw[] (0,0) rectangle (4,5) node[midway, rotate=45]{TikZ I};
\end{tikzpicture} }
}
\begin{document}
\begin{mybox}[title=Title:, splitten]
\TikzI
\tcblower
\textbf{Lower Part Title:}
aaa
bbb
\end{mybox}
\end{document}
答案1
首先,用于在并排模式下sidebyside align=top
设置垂直对齐。tcolorbox
其次,使用tikz
选项baseline
(参见pgfmanual
v3.1.7a,第 12.2.1 节)设置 的基线tikzpicture
。此处将基线设置为比 的上边缘低一行(不跳过行)tikzpicture
。
\documentclass[12pt]{article}
\usepackage[showframe=false,
margin=2cm,
]{geometry}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\newtcolorbox{mybox}[1][]{
enhanced, %
boxrule=0pt, frame hidden, % no Frame
%colframe=white,
colback=yellow!25,
arc=2pt, % "rounded corners"
% halign=flush center,
% Title =====================
colbacktitle=yellow!25,
coltitle=black, % Fontcolor Title
fonttitle=\bfseries\Large,
% Alignment =====================
sidebyside align=top,
#1, % eventually further optional keys
}
\tcbset{
splitten/.style={
% "Lower Part" =================
lower separated=false,%
sidebyside, % Lower part to the right
},
}
\makeatletter
\newcommand\TikzI{%
\vbox{\begin{tikzpicture}[baseline={($ (current bounding box.north) + (0pt,-\f@size pt) $)}]
\draw[] (0,0) rectangle (4,5) node[midway, rotate=45]{TikZ I};
\end{tikzpicture}}%
}
\makeatother
\begin{document}
\begin{mybox}[title=Title:, splitten]
\TikzI
\tcblower
\textbf{Lower Part Title:}
aaa
bbb
\end{mybox}
\end{document}