4

How can I put the title of a box (with tcolorbox) on the left side (text rotated by 90°), like this?

 _______________________________
|   |                           |
| T | Lorem ipsum               |
| I | blah blah                 |
| T |                           |
| L |                           |
| E |                           |
|___|___________________________|

TITLE is rotated by 90°, not like in the ASCII pic. It's just me or this is not specified at all in the manual?

3

2 Answers 2

8

You could use a detached title and add it to an enlarged margin:

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\tcbset{%
    enhanced,
    coltitle=black, 
    detach title,
    left=10mm,
    overlay={
        \node[rotate=90, minimum width=1cm, anchor=south,yshift=-0.8cm] at (frame.west) {\tcbtitle};
    }
}

\begin{document}

\begin{tcolorbox}[title=test]
\lipsum[1]
\end{tcolorbox}

\end{document}

enter image description here

Or if you prefer a separation line between the title and the text:

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\newtcolorbox{mybox}[2][]{
    enhanced,
    coltitle=black, 
    title={#2},
    sidebyside,
    detach title,
    attach title to upper={\tcblower},
    lefthand width=0.3cm,
    #1
}

\makeatletter
\renewcommand\tcbtitle{\ifx\tcbtitletext\@empty\else%
  \leavevmode{\rotatebox{90}{\color{tcbcol@title}\kvtcb@fonttitle\kvtcb@haligntitle\kvtcb@before@title\tcbtitletext\kvtcb@after@title}}\fi}
\makeatother

\begin{document}

\begin{mybox}{Title}
\lipsum[2]
\end{mybox}

\end{document}

enter image description here

10

What I did in the end, following this approach:

\usepackage{lipsum}
\usepackage{xcolor}
\definecolor{lbrown}{HTML}{EB811B}
\usepackage[most]{tcolorbox}
\newtcolorbox{mybox}[2][]{%
  enhanced,
  boxsep=3pt,
  arc=1.25ex,
  colback=white,
  colframe=lbrown,
  boxrule=3pt,
  leftrule=18pt,
  overlay unbroken and first ={%
    \node[rotate=90,
          minimum width=1cm,
          anchor=south,
          font=\Large\sffamily\bfseries,
          yshift=-18pt,
          white]
    at (frame.west) {#2};
  }
}
\begin{document}
\begin{mybox}{LOREM IPSUM}
    \lipsum[2]
\end{mybox}
\end{document}

result

You must log in to answer this question.

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