2

I have been struggling to get text in the tcolorbox border. See the MWE:

\documentclass[table]{standalone}
\usepackage{polyglossia, lipsum}
\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[2][]{%
  enhanced,
  before upper=\setlength{\parskip}{\bigskipamount},
  boxrule=2mm,
  bottomrule=9mm,
  overlay={%
    \node[white, font=\small, anchor=south] at (frame.south) {Footer \\ With Two Lines};},
  title=#2,#1}

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

\newcommand{\xxheading}{
  Header \\ With Two Lines
}

\begin{document}

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

  \xxbody{}

\end{mybox}

\end{document}

I would like to have a multi-line footer like the multi-line heading. And if possible, set the height of bottom border automatically to accommodate the footer. Is there any way it can be done?

This is kind of sequel to this Earlier Question.

2 Answers 2

1

Another approach that uses bicolor skin and sets the style for lower part so it plays the role of footnote.

Pros: No need to set node options.

Cons: You have to manually insert \tcblower, otherwise there will be no lower part.

% !TeX TS-program = xelatex
\documentclass[table]{standalone}
\usepackage{polyglossia, lipsum}
\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[2][]{%
  skin=bicolor,
  % geometry
  boxrule=2mm,
  % color and font
  collower=white,
  colbacklower=tcbcolframe,
  fonttitle=\LARGE,
  % segmentation
  segmentation empty,
  % box content
  title=#2,
  before upper=\setlength{\parskip}{\bigskipamount},
  before lower={Footer \\ With Two Lines},
  halign lower=center,
  % more
  #1
}

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

\newcommand{\xxheading}{
  Header \\ With Two Lines
}

\begin{document}

\begin{mybox}{\xxheading}
  \xxbody{}
  \tcblower % this must be manually inserted
\end{mybox}

\end{document}

enter image description here

0

A bit more reading around and I have found a solution --- use minipage in node.

But the code can be simplified even further by incorporating suggestion by @Ignasi. Here is the MWE with his suggestion.

\documentclass[table]{standalone}
\usepackage{polyglossia, lipsum}
\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[2][]{%
  enhanced,
  before upper=\setlength{\parskip}{\bigskipamount},
  boxrule=2mm,
  bottomrule=9mm,
  overlay={%
    \node[white, font=\small, anchor=south, text width=\textwidth] at (frame.south) {%
    Footer \\ With Two Lines};},
  title=#2,#1}

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

\newcommand{\xxheading}{
  Header \\ With Two Lines
}

\begin{document}

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

  \xxbody{}

\end{mybox}

\end{document}
5
  • 2
    There's no need for minipage. This \node[..., text width= ..., ] {line1\\ line2}; should work. See manual-automatic-line-breaks-and-text-alignment-in-tikz-nodes
    – Ignasi
    Commented Apr 12, 2021 at 7:21
  • @Ignasi Thanks, indeed. I have modified the answer to reflect your suggestion. But there is a new problem. I am not able to get a watermark in the body with this node. How do I get that? I have modified the question to reflect this, too
    – deshmukh
    Commented Apr 15, 2021 at 14:58
  • But if we include: watermark zoom=1, watermark color=black, watermark opacity=1, clip watermark, watermark text={\rotatebox{65}{Watermark}}, in the tcolorbox definition, the watermark does not display. If we hide the node, watermark displays without any problem. How do we get both the things to show?
    – deshmukh
    Commented Apr 15, 2021 at 15:04
  • I don't see any modification into the question about watermarks. In any case, being a new question, I suggest to open a new one. It will have more visibility and more chances to get an answer.
    – Ignasi
    Commented Apr 15, 2021 at 15:06
  • @Ignasi in a minute :)
    – deshmukh
    Commented Apr 15, 2021 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .