答案1
tcolorbox
从文档中复制:
\documentclass{article}
\usepackage{lipsum}
\usepackage[skins]{tcolorbox}
\usepackage{hyperref}
\newtcbox{\mylib}{enhanced,nobeforeafter,tcbox raise base,boxrule=0.4pt,top=0mm,bottom=0mm,
right=0mm,left=4mm,arc=1pt,boxsep=2pt,before upper={\vphantom{dlg}},
colframe=green!50!black,coltext=green!25!black,colback=green!10!white,
overlay={\begin{tcbclipinterior}\fill[green!75!blue!50!white] (frame.south west)
rectangle node[text=white,font=\sffamily\bfseries\tiny,rotate=90] {LIB} ([xshift=4mm]frame.north west);\end{tcbclipinterior}}}
\MakeRobust\mylib
\ifdefined\pdfstringdefDisableCommands
\pdfstringdefDisableCommands{\def\mylib#1{'#1'}}
\fi
\begin{document}
Library \mylib{lipsum}:
\lipsum[1]
\end{document}
该行使\MakeRobust\mylib
其强大,因此您可以在命令(如或 )\mylib
的参数中使用它。该行(仅在加载时使用)使其在 中使用时产生合理的 PDF 大纲条目。如果您随后执行此操作,它不会中断(因为),并且 PDF 大纲将显示。\section
\caption
\pdfstringdefDisableCommands
hyperref
\mylib
\section
\section{Library \mylib{lipsum}}
\MakeRobust
Library 'lipsum'