5

I want this type of output. enter image description here

I wrote the following code.

\usepackage[most]{tcolorbox}
\newtcbtheorem[auto counter]{project}{Project}{
lower separated=true,
colback=white!90!blue,
colframe=white,
colbacktitle=white!80!blue,
coltitle=black,
enhanced,
boxed title style={colframe=white!80!blue},
attach boxed title to top left={xshift=0.5cm,yshift=-3.5mm},
 }{def}
\begin{document}
\begin{project}{}
  Project
\end{project}
\end{document}

The output that I got is enter image description here

I am not getting a gap after the title. Please help me with this and also the boxed are not round enough.

2
  • \begin{project}{} \vskip 1cm Project \end{project} Sep 8 '19 at 12:14
  • Welcome to TeX.SX! Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem.
    – BambOo
    Sep 8 '19 at 12:19
6

With the help of the top option you can define the distance between the text and the frame:

enter image description here

\documentclass{article}

\usepackage[most]{tcolorbox}
\newtcbtheorem[auto counter]{project}{Project}{
lower separated=true,
colback=white!90!blue,
colframe=white,
colbacktitle=white!80!blue,
coltitle=black,
enhanced,
top=5mm, %<------------ Added
boxed title style={colframe=white!80!blue},
attach boxed title to top left={xshift=0.5cm,yshift=-3.5mm},
 }{def}


\begin{document}
\begin{project}{}{}
  with top=5mm
\end{project}
\end{document}

More information on the various spacing options can be found in section "4.7.4 Spacing" (page 39) of the tcolorbox manual.

For "rounder" edges, you can use the arc option as in the following exaggerated example:

enter image description here

\documentclass{article}

\usepackage[most]{tcolorbox}
\newtcbtheorem[auto counter]{project}{Project}{
lower separated=true,
colback=white!90!blue,
colframe=white!90!blue,
colbacktitle=white!80!blue,
coltitle=black,
enhanced,
top=5mm,
boxed title style={colframe=white!80!blue},
attach boxed title to top left={xshift=0.5cm,yshift=-3.5mm},
arc=5mm % <--------------------- Added
}{def}



\begin{document}

\begin{project}{}{}
  with top=5mm and arch=5 mm
\end{project}

\end{document}

More information on how to control the space of box corners can be found in section "4.7.3 Arcs" (page 36) of the tcolorbox manual.

6
  • What about the round boxes?
    – XYZABC
    Sep 8 '19 at 12:20
  • @XYZABC, if you need information regarding the tcolorbox options please have a look at the (very) comprehensive documentation
    – BambOo
    Sep 8 '19 at 12:23
  • @XYZABC: Sorry, but I don't understand what exactly your comment refers to. Could you please add a bit more explanation?
    – leandriis
    Sep 8 '19 at 12:32
  • I want the box would be in more round like corners should be more round.
    – XYZABC
    Sep 8 '19 at 12:39
  • @XYZABC: The shape of the corners can be changed with the arc option. I have edited my answer to also include an example on how to do that.
    – leandriis
    Sep 8 '19 at 12:53
4

When you use an attached title you should consider that the title box is independent of the contents box, therefore, if you want to place part of the title box below the border of the text box, the contents should be also moved.

In this case you can use yshift* option (page 160 in v4.20 documentation) which fixes the vertical title displacement but also a similar movement for the text into main box. The needed shift can be automatically computed using \tcboxedtitleheight macro.

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

\newtcbtheorem[auto counter]{project}{Project}{
lower separated=true,
colback=white!90!blue,
colframe=white,
colbacktitle=white!80!blue,
coltitle=black,
enhanced,
boxed title style={colframe=white!80!blue},
attach boxed title to top left={yshift*=-\tcboxedtitleheight/2, xshift=.5cm},
}{def}

\begin{document}
\begin{project}{Project's title}{Label}
\lipsum[1]
\end{project}

As can be seen in Projetc~\ref{def:Label} \dots
\end{document}

enter image description here

0
\documentclass{article}

\usepackage[most]{tcolorbox}
\newtcbtheorem[auto counter]{project}{Project}{
lower separated=true,
colback=white!90!blue,
colframe=white!90!blue,
colbacktitle=white!80!blue,
coltitle=black,
enhanced,
boxed title style={colframe=white!80!blue},
attach boxed title to top left={xshift=0.5cm,yshift=-3.5mm},
}{def}

\begin{documnt}

\begin{project}{}{}
  \vskip 1cm 
  Bla bla 
\end{project}

\end{document}

The above will give you proper space.enter image description here

9
  • Could you please make your example code compilable? When I try your suggestion, I recieve the following error message: Missing \endcsname inserted.
    – leandriis
    Sep 8 '19 at 12:20
  • 1
    Please do not add incomplete code. Also, if you run this code using the information provided by the OP, it actually misses one {} after the \begin{project}{} which swallows the first character after that (or worse)
    – BambOo
    Sep 8 '19 at 12:21
  • @leandriis Sorry, I updated my answer. Sep 8 '19 at 12:23
  • @leandriis Could you please let me know if you are getting the error message? Sep 8 '19 at 12:28
  • @SachchidanandPrasad: Now the error message is gone. However, there is a type on \begin{document}. Also, I get a different ouptu. The vertical space is a lot larger compared to your screenshot.
    – leandriis
    Sep 8 '19 at 12:34

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.