5

In the second box I tried to imitate the layout of the first box but with the title down. Obviously, the result is not correct. In fact, the result that I foresee is in the third box; but I do not know how to implement it using the tcolorbox features.

\documentclass{beamer}
\usepackage{lmodern}

\usepackage{tikz}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.pathmorphing}

\tcbset{%
    myboxmainstyle/.style={%
        enhanced,
        segmentation style={solid,line width=1pt,decorate,decoration={zigzag}},
        center title,
        halign=flush center,
        boxrule=1pt,
        arc is angular, arc=3pt,
    }
}

\newtcolorbox{mybox}[2][]{%
    adjusted title={#2},
    myboxmainstyle,
    #1,
}

\usepackage{environ}

\newcommand\myrotateboxgrap[1]{\reflectbox{\rotatebox[origin=c]{180}{#1}}}
\newcommand\myrotateboxtikz[1]{\tikz[baseline=(box.north)]\node[yscale=-1,inner sep=0,outer sep=0](box){#1};}

\NewEnviron{myboxflipped}[2][]{%
    %\myrotateboxgrap{\begin{mybox}[#1]{\myrotateboxgrap{#2}}\myrotateboxgrap{\BODY}\end{mybox}}
    \myrotateboxtikz{\begin{mybox}[#1]{\myrotateboxtikz{#2}}\myrotateboxtikz{\BODY}\end{mybox}}
}

\begin{document}

\begin{frame}
    \begin{mybox}[]{Test}
        bla bla
    \end{mybox}
    \begin{mybox}[attach boxed title to bottom center={yshift=0.25mm+\tcboxedtitleheight/2,yshifttext=-2mm+\tcboxedtitleheight/2}]{Test}
        bla bla
    \end{mybox}
    \begin{myboxflipped}[colback=pink]{Test}
        bla bla
    \end{myboxflipped}
\end{frame}

\end{document}

enter image description here

  • Are those \NewEnviron stuff commands really necessary? – user31729 Dec 7 '15 at 16:46
  • I want to flip the box frame, but not its contents. – cacamailg Dec 7 '15 at 16:53
  • Well, you want to reverse the position of the box and the title, with other words – user31729 Dec 7 '15 at 16:57
6

The tcolorbox manual has an example flipbox which does precisely this flipping of the box and title (See page 161 as of version 4.15).

The crucial point is minipage boxed title* which expands the boxed title the width of outer tcolorbox.

\documentclass{beamer}
\usepackage{lmodern}

\usepackage{tikz}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.pathmorphing}

\tcbset{%
    myboxmainstyle/.style={%
      enhanced,
      segmentation style={solid,line width=1pt,decorate,decoration={zigzag}},
      center title,
      halign=flush center,
      boxrule=1pt,
      arc is angular, arc=3pt,
    }
}


\newtcolorbox{mybox}[2][]{
  enhanced,
  sharp corners=south,
  myboxmainstyle,
  attach boxed title to bottom center={yshift=0.5mm},
  minipage boxed title*,
  boxed title style={enhanced,
    size=normal,
    top=0pt,
    bottom=0pt,
    %interior hidden,
    sharp corners=north,
    boxrule=1pt,
    colback=red,
    arc is angular, arc=3pt},
  title={#2},#1
}



\begin{document}

\begin{frame}
    \begin{mybox}[]{Test}
        bla bla
    \end{mybox}
    \begin{mybox}[colback={yellow},coltitle=black,colbacktitle=red]{Another Test}
        bla bla
    \end{mybox}

\end{frame}

\end{document}

Edit

\documentclass{beamer}
\usepackage{lmodern}

\usepackage{tikz}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.pathmorphing}

\tcbset{%
    myboxmainstyle/.style={%
      enhanced,
      segmentation style={solid,line width=1pt,decorate,decoration={zigzag}},
      center title,
      halign=flush center,
      boxrule=1pt,
      arc is angular, arc=3pt,
    }
}


\newtcolorbox{mybox}[2][]{
  enhanced,
  sharp corners=south,
  myboxmainstyle,
  attach boxed title to bottom center={yshift=0.5mm},
  minipage boxed title*,
  boxed title style={enhanced,
    size=normal,
    top=0pt,
    bottom=0pt,
    center title,
    sharp corners=north,
    boxrule=1pt,
    arc is angular, arc=3pt},
  title={{\centering #2}},#1
}



\begin{document}

\begin{frame}
    \begin{mybox}[]{Test}
        bla bla
    \end{mybox}
    \begin{mybox}[colback={yellow},coltitle=black,colbacktitle=red]{Another Test}
        bla bla
    \end{mybox}

\end{frame}

\end{document}

enter image description here

  • Can you point me the page? I am using TexLive 2015. – cacamailg Dec 7 '15 at 17:13
  • @cacamailg: Page 144 of the current version 3.80, at the lower part of that page – user31729 Dec 7 '15 at 17:15
  • For me it seems centered :-). – cacamailg Dec 7 '15 at 17:23
  • @cacamailg: Yes, I've updated. -- \centering #2 helps. – user31729 Dec 7 '15 at 17:24
  • 1
    @cacamailg: How many shadows did your box have initially? None! That's not in the original question – user31729 Dec 8 '15 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.