# Text along all the four borders of a tcolorbox

Here is the 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]
}

}

\begin{document}

\xxbody{}

\end{mybox}

\end{document}


I would like to put some text in all the four borders (yellow text on brown background). So, there would be 'Top Heading' in the top box, 'Right Side Heading' in the border on the right, 'Left Side Heading' in the border on the left and 'Bottom Heading' in the border at the bottom.

Also, the top heading should be able to accommodate multiple lines as shown in the MWE.

Can this be done? If this can be done with a tcolorbox, is there any other utility that provides this functionality?

Just an idea, forget the title, declare a wide boxrule and overlay the text on four sides.

\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]
}

}

\begin{document}

\begin{mybox}{}

\xxbody{}

\end{mybox}

\end{document}


• almost perfect except that I am not able to get a multi-line top heading (I am adding this bit to the question). I tried Top Heading \\ Second Line as well as Top Heading \newline Second Line. But if we keep heading is in MWE, it is possible. Any workarond for this? – deshmukh Feb 5 at 9:30
• @deshmukh This \node[yellow, font=\LARGE\bfseries, anchor=north, align=center] at (frame.north) {Top Heading\\ Second line}; works for me. Only the align option was added. – Ignasi Feb 5 at 9:57
• Thanks. That did add the second line. But it spills out of the brown box onto the off-white background. I could increase the boxrule to 16mm. But that created a new problem - all the other three borders are unnecessarily large! – deshmukh Feb 5 at 10:03
• Take a look at tcolorbox documentation, instead of a uniform boxrule you can decide the width of every side. In this case, it's also possible to use a title again which will provide an automatic height and just decide the width of left, right and bottom border. – Ignasi Feb 5 at 10:11