4

This question already has an answer here:

I use the code below for some texts, but the starting spacing is missing from every paragraph. I would like to have the starting spacing at the red arrows like as it be at the blue.enter image description here

\documentclass{article}

\usepackage[most]{tcolorbox}

\usepackage{lipsum}
\usepackage{varwidth}
\newtcolorbox{mybox}[2][]{enhanced,
    before skip=2mm,after skip=2mm, colback=black!5,colframe=black!50,boxrule=0.2mm,
    attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
    boxed title style={frame code={
            \path[fill=tcbcolback!30!black]
            ([yshift=-1mm,xshift=-1mm]frame.north west)
            arc[start angle=0,end angle=180,radius=1mm]
            ([yshift=-1mm,xshift=1mm]frame.north east)
            arc[start angle=180,end angle=0,radius=1mm];
            \path[left color=tcbcolback!60!black,right color=tcbcolback!60!black,
            middle color=tcbcolback!80!black]
            ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
            [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
            -- (frame.south east) -- (frame.south west)
            -- ([xshift=-1mm,yshift=-1mm]frame.north west)
            [sharp corners]-- cycle;
        },interior engine=empty,
    },
    fonttitle=\bfseries,
    title={#2},#1}

\begin{document}

    \begin{mybox}[colbacktitle=green]{My title}
        \lipsum[1-2]
    \end{mybox}

\end{document}

Thanks in advance!!!

marked as duplicate by koleygr, Ignasi, Tiuri, Stefan Pinnow, Cragfelt Nov 8 at 12:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I don't think the first indentation should be used, for the same reason as the first paragraph after a section title is not indented – Bernard Nov 8 at 9:50
1

Try this way:

(add ,before upper={\parindent15pt}, in the definition of the colorbox)

\documentclass{article}

\usepackage[most]{tcolorbox}
\definecolor{tcbcolback}{RGB}{100,100,100}
\usepackage{lipsum}
\usepackage{varwidth}
\newtcolorbox{mybox}[2][]{enhanced,
    before skip=2mm,after skip=2mm, colback=black!5,colframe=black!50,boxrule=0.2mm,
    attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
    boxed title style={frame code={
            \path[fill=tcbcolback!30!black]
            ([yshift=-1mm,xshift=-1mm]frame.north west)
            arc[start angle=0,end angle=180,radius=1mm]
            ([yshift=-1mm,xshift=1mm]frame.north east)
            arc[start angle=180,end angle=0,radius=1mm];
            \path[left color=tcbcolback!60!black,right color=tcbcolback!60!black,
            middle color=tcbcolback!80!black]
            ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
            [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
            -- (frame.south east) -- (frame.south west)
            -- ([xshift=-1mm,yshift=-1mm]frame.north west)
            [sharp corners]-- cycle;
        },interior engine=empty,
    },before upper={\parindent15pt},
    fonttitle=\bfseries,
    title={#2},#1}

\begin{document}

    \begin{mybox}[colbacktitle=green]{My title}
        \lipsum[1-2]
    \end{mybox}

\end{document}

PS: If this works for you you may mark your post as a duplicate of this question/answer

  • Thanks a lot! Problem solved! I don't know how to mark my question as duplicate... – Kώστας Κούδας Nov 8 at 9:50
  • 1
    It is ok ... I did that for you ... You can do it through "flag" button under your post (for future usage). – koleygr Nov 8 at 9:58

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