Is it possible to customize chapter style like below picture by using tcolorbox package? if not, can you show me which package could generate that such style? Thanks
Asked
Active
Viewed 4,554 times
11
Đăng Khoa Nguyễn Vũ
- 301
- 2
- 7
-
we can ignore the background picture on the left handsite. – Đăng Khoa Nguyễn Vũ Jul 08 '15 at 14:18
-
What have you got so far in terms of code? Note that without a minimal example document, any solution is likely to not work for your document because we just don't know anything about it. So the answer to you first question is 'Yes'. The bonus answer is: 'and show us what you've tried if you get stuck implementing it'. – cfr Jul 08 '15 at 14:45
1 Answers
25
Here's one possibility using tcolorbox and titlesec. An image for an unnumbered chapter:

An image for a numbered chapter:

The code:
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage[many]{tcolorbox}
\usepackage{lmodern}
\usepackage{lipsum}
\definecolor{titlebgdark}{RGB}{0,163,243}
\definecolor{titlebglight}{RGB}{191,233,251}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{%
\begin{tcolorbox}[
enhanced,
colback=titlebgdark,
boxrule=0.25cm,
colframe=titlebglight,
arc=0pt,
outer arc=0pt,
leftrule=0pt,
rightrule=0pt,
fontupper=\color{white}\sffamily\bfseries\huge,
enlarge left by=-1in-\hoffset-\oddsidemargin,
enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
width=\paperwidth,
left=1in+\hoffset+\oddsidemargin,
right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
top=0.6cm,
bottom=0.6cm,
overlay={
\node[
fill=titlebgdark,
draw=titlebglight,
line width=0.15cm,
inner sep=0pt,
text width=1.7cm,
minimum height=1.7cm,
align=center,
font=\color{white}\sffamily\bfseries\fontsize{30}{36}\selectfont
]
(chapname)
at ([xshift=-4cm]frame.north east)
{\thechapter};
\node[font=\small,anchor=south,inner sep=2pt] at (chapname.north)
{\MakeUppercase\chaptertitlename}; % if using amsbook, this should be \chaptername
}
]
#1
\end{tcolorbox}%
}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{%
\begin{tcolorbox}[
enhanced,
colback=titlebgdark,
boxrule=0.25cm,
colframe=titlebglight,
arc=0pt,
outer arc=0pt,
remember as=title,
leftrule=0pt,
rightrule=0pt,
fontupper=\color{white}\sffamily\bfseries\huge,
enlarge left by=-1in-\hoffset-\oddsidemargin,
enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
width=\paperwidth,
left=1in+\hoffset+\oddsidemargin,
right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
top=0.6cm,
bottom=0.6cm,
]
#1
\end{tcolorbox}%
}
\titlespacing*{\chapter}
{0pt}{0pt}{40pt}
\makeatother
\begin{document}
\chapter*{A test unnumbered chapter}
\lipsum[4]
\chapter{A test chapter with a long title that will span more than one line}
\lipsum[4]
\end{document}
Martin Argerami
- 315
Gonzalo Medina
- 505,128
-
Thanks Gonzalo. Is it possible to put the "chapter" on the top of small box (i.e. "1") – Đăng Khoa Nguyễn Vũ Jul 08 '15 at 14:52
-
@ĐăngKhoaNguyễnVũ You're welcome. Please see my updated answer. – Gonzalo Medina Jul 08 '15 at 14:57
-
Dear Gonzala, Can you tell me which code can adjust the the size of the small box (square rectangular) on the right top? and I also want to move the box to the right a little bit. How can adjust it. Pls forgive me, coz i am newbie of Tex. – Đăng Khoa Nguyễn Vũ Jul 22 '15 at 06:51
-
Dear Gonzalo, you can refer to my question with the pic at http://imgur.com/9zBzJAV . If the chapter title too long so that it will close very much with the rectangular box. I would like to move it to the right a litter bit and make the number in box occupied all most the box. Many thanks for your instruction! – Đăng Khoa Nguyễn Vũ Jul 22 '15 at 07:23
-
1@ĐăngKhoaNguyễnVũ I can't reproduce the problem you mentioned. Move the number to the right changing the
-4cmin(chapname) at ([xshift=-4cm]frame.north east) {\thechapter};to a smaller value (-3cmor whatever value suits your needs). For the other resuirement, change the values infont=\color{white}\sffamily\bfseries\fontsize{30}{36}\selectfontto a bigger font size, for examplefont=\color{white}\sffamily\bfseries\fontsize{50}{60}\selectfont. – Gonzalo Medina Jul 22 '15 at 15:56 -
For anyone trying to use this with amsbook, there is a small change needed to make it work right in the appendices:
\chaptertitlenameshould be\chaptername. I added a comment in the code for this. – Martin Argerami Jun 05 '20 at 17:39