tcolorbox:框架邊框處的旋轉文本

tcolorbox:框架邊框處的旋轉文本

我試圖將文字放在框的左邊框處。現在我有這個:

\newtcolorbox{reminderbox}[1]{enhanced,
before skip=2mm,after skip=3mm,
boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
colback=white,
colframe=black,
sharp corners,
underlay={%
    \path[draw=none] (interior.south west) rectangle node[black,rotate=90]{\small #1} ([xshift=4mm]interior.north west);
}}

我這樣使用它:

\begin{reminderbox}{For reference:}
    This is a well known fact!
\end{reminderbox}

這使: 我的問題的輸出

如何使框根據文字縮放?

答案1

也許它需要一些額外的工作,但你可以從這樣的事情開始。

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

\newlength{\mywidth}

\newtcolorbox{reminderbox}[1]{enhanced,
before skip=2mm,after skip=3mm,
boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
colback=white,
colframe=black,
sharp corners,
underlay={%
    \path[draw=none] (interior.south west) rectangle node[black,rotate=90]{\small #1} ([xshift=4mm]interior.north west);
},
code={\settowidth{\mywidth}{#1}},
height=\mywidth,
}

\begin{document}
\begin{reminderbox}{For reference:}
    This is a well known fact!
\end{reminderbox}

\begin{reminderbox}{Another reference:}
    This is a well known fact!
\end{reminderbox}
\end{document}

在此輸入影像描述

相關內容