3

Referring to question at Create a box using tcolorbox package?, I would like to attach a small square box at top right of the main box rather than attach it on the left along with full height of the main box. Can you tell me which code of (Create a box using tcolorbox package?) I can change to meet the requirement?

Thanks

  • 2
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jul 24 '15 at 7:08
  • Especially, what should this top-right box show? – user31729 Jul 24 '15 at 7:08
5

The skin library of tcolorbox has the feature of attached box titles, which can be styled on their own, as well as being shifted with xshift and yshift options.

To attach the box title top right, just say attach box title to top right={...}, with some options, see the manual (version 3.70, as of now, page 131 for more options and possibilities)

\documentclass{article}

\usepackage[most]{tcolorbox}


\newtcbtheorem{Summary}{\bfseries Summary}{enhanced,drop shadow={black!50!white},
  coltitle=black,
  top=0.3in,
  attach boxed title to top right=
  {xshift=0em,yshift=-\tcboxedtitleheight/2},
  boxed title style={size=small,colback=pink}
}{summary}


\newtcolorbox[auto counter]{summary}[1][]{title={\bfseries Summary~\thetcbcounter},enhanced,drop shadow={black!50!white},
  coltitle=black,
  top=0.3in,
  attach boxed title to top right=
  {xshift=0pt},
  boxed title style={size=small,colback=pink},#1}



\begin{document}

\begin{Summary}{}{firstsummary}
Brontosaurs are thin at one end, thick in the middle and thin again on the other end
\end{Summary}

\begin{summary}[boxed title style={colback=yellow},colback=green]
Brontosaurs are thin at one end, thick in the middle and thin again on the other end

See excavations of Brontosaurs skeletons
\end{summary}



\end{document}

enter image description here

Here, two versions are shown, own with an overlay of the box title and own with almost no boundary space between bottom of the title box and the top of the regular tcolorbox frame. In my point of view, the first version does provide the better look.

  • in case I would like to attach the box to right of the main box: just replace "attach boxed title to top right" by "attach boxed title right=", isn't it? Many Thanks – Chau Nhu Jul 24 '15 at 8:01
  • @Chau: You wrote top right ... – user31729 Jul 24 '15 at 8:36
1

by changing in value of 0em in xshift and value in yshift, you can move small box to the right or left; up or down [{xshift=0em,yshift=-\tcboxedtitleheight/2}]

0

the code is \newtcbtheorem{Summary}{\bfseries Summary}{enhanced,drop shadow={black!50!white}, coltitle=black,top=0.3in, attach boxed title to top right= {xshift=7em,yshift=-2em}, boxed title style={size=small,colback=pink, outer arc=0pt,arc=0pt} }{summary}

and here is the result: enter image description here

  • 1
    Why do you just steal from my solution and why 2 solutions? ;-) – user31729 Jul 24 '15 at 15:25
  • @ChristianHupfer: the code is yours. I just re-used it to demonstrate for Chau Nhu know how to shift the small box surrounding top-right. Don't be strict like that. – Đăng Khoa Nguyễn Vũ Jul 25 '15 at 3:08

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.