1

I have the following box, but I want to change a bit the margins from all the sides. Is it possible to set custom margins (i.e., control where the text starts and ends)? Also I want to move the subtitles a bit to the left. Note that the text should start before the subtitles, as currently start of text and subtitles are aligned.

\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{tikz}

 \newtcolorbox{openningbox}[2]{
    colback = white,
    colframe = black,
    before upper = \tcbsubtitle{\tikz{\node[draw=black,fill=white,line width=1pt,rounded corners=3.5pt,font=\bfseries\color{black}]{\rule[-.3\baselineskip]{0pt}{\baselineskip}\normalsize\sffamily\bfseries\normalfont ~~\textbf{Experiment} #1~~};}},
    before lower = \tcbsubtitle{\tikz{\node[draw=black,fill=white,line width=1pt,rounded corners=3.5pt,font=\bfseries\color{black}]{\rule[-.3\baselineskip]{0pt}{\baselineskip}\normalsize\sffamily\bfseries\normalfont ~~\textbf{Experiment} #2~~};}},
    subtitle style = {
      enhanced,
      interior hidden,
      frame hidden,
      top=-0.8cm
    },
    boxrule=1pt,
    arc=2.5pt,
    sidebyside,
    sidebyside align = top,
    enhanced,
    segmentation style = {solid,line width=1pt}
  }



\begin{document}

\begin{openningbox}{Real}{Ideal}
  \lipsum*[1]
  \tcblower
  \lipsum*[2]
\end{openningbox}

\end{document}
4
  • You might want to have a look at section "2 Quick Reference" of the tcolorbox documentation. Commented May 31, 2023 at 10:25
  • @samcarter_is_at_topanswers.xyz Apparently setting just left also moves only the text on the left part of the box, and does not affect the right column that much.
    – pixel
    Commented May 31, 2023 at 11:53
  • @samcarter_is_at_topanswers.xyz Is it possible to set the distance to segmentation line from left and right somehow?
    – pixel
    Commented May 31, 2023 at 12:07
  • About segmentation. You have some examples in page 156 and 158. You can draw it with some shift from segmentation anchors
    – Ignasi
    Commented May 31, 2023 at 18:15

1 Answer 1

2

This is an alternative definition of OP's openningbox.

Main changes are:

  • Title and subtitle are replaced with an attach boxed title to top and a \node added through an overlay option. We could also use two overlay options to be sure that geometry of title is the same.
  • Text margins are adjusted with left and right parameters. Inner gap between side by side paragraphs is fixed with sidebyside gap.
  • sidebyside align=top works with the help of yshift* option in boxed title.
  • segmentation rule can be shortened with shorten options in its style.

The code is:

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

 \newtcolorbox{openningbox}[2]{
     enhanced,
    colback = white,
    colframe = black,
     title = {\textbf{Experiment}~#1~~},
     coltitle=black,
     boxed title style={colframe=black, colback=white},
     attach boxed title to top left={yshift*=-\tcboxedtitleheight/2, xshift=5mm},
     overlay={\node[rounded corners=2.5pt, line width=1pt, draw, anchor=west, fill=white, inner xsep=3mm, inner ysep=1.25mm] at ([xshift=5mm]segmentation.north) {\textbf{Experiment}~#2~~};},
    boxrule=1pt,
    boxsep=0pt,
    left=2mm,
    right=2mm,
    sidebyside gap=4mm,
    arc=2.5pt,
    sidebyside,
    sidebyside align = top,
    enhanced,
    segmentation style = {solid,line width=1pt, shorten >=1cm, shorten <=1cm}
  }



\begin{document}

\begin{openningbox}{Real}{Ideal}
  \lipsum*[1]
  \tcblower
  \lipsum*[2]
\end{openningbox}

\end{document}

enter image description here

You must log in to answer this question.

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