3

I want to put a title at the bottom right of the frame and still have normal title on the top left.

My hack solution of using \tcbsubtitle[after={\vspace*{-34pt}}]{} seems to work but it messes up the valign=center for the box content:

enter image description here

So, what is the correct way to have both titles as well as having text vertically centered in the box.

Code:

\documentclass{article}
\usepackage[many]{tcolorbox}

\begin{document}
    \begin{tcolorbox}[
        title={Top Title},
        halign=center,
        valign=center,
        nobeforeafter,
        height=3cm,
    ]
        Some text%
        \tcbsubtitle[after={\vspace*{-34pt}}]{\hfill End-Title}% <-- Note: \vspace hack!
    \end{tcolorbox}%
\end{document}

3 Answers 3

3

It seems that using the lowerpart as a subtitle is the only solution. The subtitle is a new colorbox inside the colorbox. In the tcolorbox documentation at page 22 is written that "upperpart is mandatory" so it cannot be suppressed. I came up with a similar solution:

\documentclass{article}
\usepackage[many]{tcolorbox}
\begin{document}
    \begin{tcolorbox}[space to upper,
        skin=bicolor,
        colbacklower=black!75,
        collower=white,
        title={Top Title},
        halign=center,
        valign=center,
        nobeforeafter,
        halign lower=flush right,
        bottom=0mm,
        height=3cm
    ]
        Some text 3cm%

        \tcblower
        End-Title
    \end{tcolorbox}%

     \begin{tcolorbox}[space to upper,
        skin=bicolor,
        colbacklower=black!75,
        collower=white,
        title={Top Title},
        halign=center,
        valign=center,
        nobeforeafter,
        halign lower=flush right,
        bottom=0mm,
        height=6cm
        ]
        Some text 6cm%

        \tcblower
        End-Title
     \end{tcolorbox}%

\end{document}

enter image description here

3
  • With height=3cm this solution dows not work properly as it appplies he height to the lower box. Nov 20, 2017 at 17:23
  • The "space to upper" option was needed, as described in the package documentation. I think it is OK now.
    – mhtsort
    Nov 20, 2017 at 22:20
  • Yep, seems to work now. Nov 20, 2017 at 22:37
2

While someone finds a better solution and if your tcolorbox has no lower part, you can try to make the end title with the lower part in a bicolor box.

\documentclass{article}
\usepackage[many]{tcolorbox}

\begin{document}
    \begin{tcolorbox}[
          enhanced,
          bicolor,
        title={Top Title},
        halign=center,
        valign=center,
        nobeforeafter,
        height=3cm,
        colbacklower = black!75!white,
        halign lower = right,
        collower=white,
        space to upper,
        bottom = 0pt,
    ]
        Some text
        \tcblower
        End Title
    \end{tcolorbox}%

\end{document}

enter image description here

1

This other "hack" could be useful

enter image description here

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\makeatletter
\tcbset{
  experimental split/.code={
  \let\tcb@split@SL=\tcb@split@L},
}
\makeatother

\begin{document}

\begin{tcolorbox}[%
  experimental split,
  breakable,
  bicolor,
  collower=white,
  halign=center,
  valign lower=top,
  toptitle=1.5mm,
  bottomtitle=1.5mm,
  title={Top Title},
  colbacklower=black!75,
  ]%

  %\lipsum[1]
  Some text

  \tcblower
  \hfill End-Title
\end{tcolorbox}
\end{document}

I took the idea from Breaking tcolorbox between upper and lower part. Here is the customized tcolorbox with some text

enter image description here

1
  • With height=3cm this solution dows not work properly as it appplies he height to the lower box. Nov 20, 2017 at 17:24

You must log in to answer this question.

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