에서 첫 번째 줄만 들여쓰는 방법은 무엇입니까 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}
답변1
\parindent
을 로 설정했지만 17pt
실제로는 번호가 매겨진 제목 상자를 위한 공간만 확보하기를 원합니다. 따라서 \parindent=0pt
첫 번째 단락에서 수동으로 들여쓰기가 필요합니다 .
다음을 사용하여 이를 달성할 수 있습니다.
before upper={\setlength{\parindent}{0pt}\hspace*{17pt}}
전체 예는 다음과 같습니다.
\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}