Como recuar apenas a primeira linha tcolorbox
?
\documentclass[12pt,a4paper]{book}
\usepackage[listings,many]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{lipsum}
\tcbuselibrary{listingsutf8,breakable,skins}
\tcbset{listing engine=listings}
\tcbset{mystyle/.style={
breakable,
enhanced,
rightrule=0pt,
toprule=0pt,
outer arc=0pt,
before upper={\parindent17pt},
parbox = true,
arc=0pt,
colback=white,
attach boxed title to top left,
fonttitle=\sffamily
}
}
\newtcolorbox[auto counter]{mybox}[1][]{
mystyle,colframe=black,boxed title style={
colback=black,
outer arc=0pt,
arc=0pt,
top=0pt,
bottom=0pt,
left=1pt,
right=1pt
},
left=0pt,right=0pt,top=-18pt,bottom=0pt,
title=\thetcbcounter,
overlay unbroken and first={
\path
let
\p1=(title.north west),
\p2=(frame.north west)
in
node[anchor=west,font=\sffamily,text width=\x2-\x1]
at (title.west) {#1};
}
}
\begin{document}
\begin{mybox}
\lipsum[1-8]
\end{mybox}
\end{document}
Responder1
Você definiu \parindent
como 17pt
, mas realmente deseja que isso abra espaço para a caixa de título numerada. Então você realmente precisa \parindent=0pt
de um recuo manual no primeiro parágrafo.
Você pode conseguir isso usando:
before upper={\setlength{\parindent}{0pt}\hspace*{17pt}}
Aqui está um exemplo completo:
\documentclass[12pt,a4paper]{book}
\usepackage[listings,many]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{lipsum}
\tcbuselibrary{listingsutf8,breakable,skins}
\tcbset{listing engine=listings}
\tcbset{mystyle/.style={
breakable,
enhanced,
rightrule=0pt,
toprule=0pt,
outer arc=0pt,
before upper={\setlength{\parindent}{0pt}\hspace*{17pt}},
parbox = true,
arc=0pt,
colback=white,
attach boxed title to top left,
fonttitle=\sffamily
}
}
\newtcolorbox[auto counter]{mybox}[1][]{
mystyle,colframe=black,boxed title style={
colback=black,
outer arc=0pt,
arc=0pt,
top=0pt,
bottom=0pt,
left=1pt,
right=1pt
},
left=0pt,right=0pt,top=-18pt,bottom=0pt,
title=\thetcbcounter,
overlay unbroken and first={
\path
let
\p1=(title.north west),
\p2=(frame.north west)
in
node[anchor=west,font=\sffamily,text width=\x2-\x1]
at (title.west) {#1};
}
}
\begin{document}
\begin{mybox}
\lipsum[1-2]
\end{mybox}
\end{document}