2

I want the lower part right of the upper part.

Why don't I get top alignment for the lower part?
valign lower=top, % <------ Problem here!
has no effect.

enter image description here

PS: Just for interessts: is there something special for a "lower part title"?

\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 Answer 1

3

Firstly, use sidebyside align=top to set vertical alignment of a tcolorbox in side-by-side mode.

Second, use tikz option baseline (see pgfmanual v3.1.7a, sec 12.2.1) to set the baseline of tikzpicture. Here the baseline is set to one line (without line skip) lower than the upper edge of 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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .