我怎样才能将一个框的标题(带有tcolorbox
)放在左侧(文本旋转 90°),就像这样?
_______________________________
| | |
| T | Lorem ipsum |
| I | blah blah |
| T | |
| L | |
| E | |
|___|___________________________|
TITLE 旋转了 90°,与 ASCII 图片不同。这只是我的感觉,还是手册中根本没有提到这一点?
答案1
您可以使用独立的标题并将其添加到扩大的边距:
\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}
或者如果您更喜欢标题和文本之间的分隔线:
\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}
答案2
我最后做的是这种方法:
\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}