文字沿着 tcolorbox 的四个边框

文字沿着 tcolorbox 的四个边框

以下是 MWE:

\documentclass[table]{standalone}
\usepackage{polyglossia, lipsum}
\usepackage[most]{tcolorbox}
\definecolor{mybrown}{HTML}{784421}
\newtcolorbox{mybox}[2][]{%
  enhanced,
  before upper=\setlength{\parskip}{\bigskipamount},
  colframe=mybrown,
  boxrule=2mm,
  colbacktitle=mybrown,
  fonttitle=\bfseries\centering,
  coltitle=yellow,
  colback=yellow!10!white,
  coltext=mybrown,
  watermark zoom=1,
  watermark color=black,
  watermark opacity=.05,
  clip watermark,
  watermark text={Watermark},
  title=#2,#1}

\newcommand{\xxbody}{
  \lipsum[2]
}

\newcommand{\xxheading}{
Top Heading \\ Second Line
}
  
\begin{document}

\begin{mybox}{\LARGE \xxheading{}}

  \xxbody{}

\end{mybox}

\end{document}

我想在所有四个边框中放置一些文本(棕色背景上的黄色文本)。因此,顶部框中会有“顶部标题”,右侧边框中会有“右侧标题”,左侧边框中会有“左侧标题”,底部边框中会有“底部标题”。

此外,顶部标题应该能够容纳多行,如 MWE 中所示。

可以这样做吗?如果可以使用 tcolorbox 完成此操作,还有其他实用程序可以提供此功能吗?

答案1

只是一个想法,忘记标题,声明一个宽度boxruleoverlay四边的文字。

\documentclass[table]{standalone}
\usepackage{polyglossia, lipsum}
\usepackage[most]{tcolorbox}
\definecolor{mybrown}{HTML}{784421}
\newtcolorbox{mybox}[2][]{%
  enhanced,
  before upper=\setlength{\parskip}{\bigskipamount},
  colframe=mybrown,
  boxrule=8mm,
  colbacktitle=mybrown,
  fonttitle=\bfseries\centering,
  coltitle=yellow,
  colback=yellow!10!white,
  coltext=mybrown,
  watermark zoom=1,
  watermark color=black,
  watermark opacity=.05,
  clip watermark,
  watermark text={Watermark},
  overlay={%
    \node[yellow, font=\LARGE\bfseries, anchor=north] at (frame.north) {Top Heading};
    \node[yellow, font=\LARGE\bfseries, anchor=south] at (frame.south) {Bottom Heading};
    \node[yellow, font=\LARGE\bfseries, anchor=north, rotate=90] at (frame.west) {Left Heading};
    \node[yellow, font=\LARGE\bfseries, anchor=south, rotate=90] at (frame.east) {Right Heading};},
%  title=#2,
%  bottomrule=5mm,
%  leftrule=5mm,
%  rightrule=5mm,
  #1}

\newcommand{\xxbody}{
  \lipsum[2]
}

\newcommand{\xxheading}{
Top Heading
}
  
\begin{document}

\begin{mybox}{}

  \xxbody{}

\end{mybox}

\end{document}

在此处输入图片描述

相关内容