我想要的是:
我已经拥有的:
有人能帮我重新创建这种章节标题(第一张图片)吗?欢迎大家提供帮助!
第二张图片的代码:
\documentclass[
11pt,a4paper,twoside,openright]{book}
%nummering
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{fancyhdr}
\pagestyle{fancy}
\pagestyle{plain}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\usepackage[dutch]{babel}
\usepackage[babel=true]{csquotes}
\usepackage[T1]{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\usepackage{charter}
\definecolor{mybluei}{RGB}{5, 0, 100}
\definecolor{myblueii}{RGB}{0, 0, 100}
\usepackage{titlesec}
\newcommand\ChapterFont{\rmfamily\selectfont\huge}
\newcommand\SectionFont{\bfseries\rmfamily\selectfont\Large}
\titleformat{\chapter}[display]
{\normalfont\ChapterFont\huge\color{myblueii}}
{}
{0pt}
{\parbox[b]{0pt}{\mbox{}}%
\parbox[b]{70 pt}{\colorbox{mybluei}{%
\parbox[b][60pt][t]{60pt}{\centering%
\color{white}%
{\itshape\rmfamily\small\chaptertitlename}%
\vfill{\fontsize{70}{70}\selectfont\thechapter}%
}%
}%
}\hspace{15pt}%
\parbox[b]{\dimexpr\textwidth}{%
\raggedright\bfseries#1\vskip18pt%
}%
}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\selectfont\huge\color{myblueii}}
{}
{0pt}
{\parbox[b]{70pt}{\mbox{}}%
\hspace{15pt}%
\parbox[b]{\dimexpr\textwidth-15pt}{%
\raggedright\bfseries#1\vskip6pt%
}%
}
\titleformat{\section}
{\normalfont\small\sffamily\SectionFont\color{myblueii}}
{\colorbox{mybluei}{%
\parbox[c][16pt][c]{40pt}{%
\centering\textcolor{white}{\SectionFont\Large\rmfamily\thesection}%
}%
}%
}
{1em}
{#1}
[\vspace{-0.755\baselineskip}%
\color{myblueii}\hspace*{\dimexpr40pt+2\fboxsep\relax}%
\rule{\dimexpr\textwidth-40pt-2\fboxsep\relax}{1pt}%
]
\usepackage{amsmath, amsthm, amssymb, amsfonts, enumerate, dlfltxbcodetips}
\renewcommand{\qedsymbol}{$\blacksquare$}
答案1
一个选项(提供编号和未编号章节的设置);根据需要调整设置:
\documentclass[openany]{book}
\usepackage[dutch]{babel}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{lmodern}% to have a large font size for the chapter numbers
\usepackage{lipsum}% just to generate text for the example
\definecolor{chapnumberbg}{RGB}{26,40,105}
\definecolor{chapname}{RGB}{100,117,158}
\titleformat{\chapter}[display]
{\normalfont}
{}
{0pt}
{%
\begin{tikzpicture}
\node[
draw=chapname,
rounded corners,
outer sep=0pt,
inner sep=6pt,
rotate=90,
line width=1pt,
font=\Large\color{chapnumberbg}\bfseries
]
(chapname)
{\chaptertitlename};
\node[
fill=chapnumberbg,
minimum width=2cm,
minimum height=2.3cm,
rounded corners,
anchor=west,
font=\color{white}\fontsize{40}{48}\selectfont\bfseries
]
at ([xshift=6pt]chapname.south)
(chapnumber)
{\thechapter};
\node[
anchor=west,
text width=\textwidth-4cm,
font=\bfseries\LARGE
]
at ([xshift=10pt]chapnumber.east)
{#1};
\fill[
overlay,
draw=none,
line width=0pt,
rounded corners=1pt,
left color=chapnumberbg,
right color=chapnumberbg!10
]
([yshift=-3pt]chapname.north west) rectangle ++(\textwidth,-3pt);
\end{tikzpicture}%
}
\titleformat{name=\chapter,numberless}[display]
{\normalfont}
{}
{0pt}
{%
\begin{tikzpicture}
\node[
anchor=west,
inner sep=0pt,
outer sep=0pt,
text width=\textwidth,
font=\bfseries\LARGE
]
(chaptitle)
{#1};
\fill[
overlay,
draw=none,
line width=0pt,
rounded corners=1pt,
left color=chapnumberbg,
right color=chapnumberbg!10
]
([yshift=-3pt]chaptitle.south west) rectangle ++(\textwidth,-3pt);
\end{tikzpicture}%
}
\begin{document}
\chapter{Test numbered chapter}
\lipsum[1-2]
\chapter{Test unnumbered chapter}
\lipsum[1-2]
\end{document}
生成的文档的图像:
编号章节的放大图像:
未编号章节的放大图:
要控制标题的垂直定位,你可以使用类似
\titlespacing*{\chapter}
{0pt}{20pt}{40pt}
第三个强制参数(在我的示例中为20pt
)控制标题前的距离,第四个参数(在我的示例中为40pt
)控制标题后的距离。将这些长度更改为所需值。
答案2
使用包的解决方案tcolorbox
(我仅涉及编号章节格式)。顺便说一句,您的 chapterstyle 应该是block
,而不是display
:
\documentclass[
11pt,a4paper,twoside,openright]{book}
%nummering
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{fancyhdr}
\pagestyle{fancy}
\pagestyle{plain}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\usepackage[dutch]{babel}
\usepackage[babel=true]{csquotes}
\usepackage[T1]{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\usepackage{charter}
\definecolor{mybluei}{RGB}{5, 0, 100}
\definecolor{myblueii}{RGB}{0, 0, 100}
\usepackage{rotating, graphicx}
\usepackage{titlesec}
\usepackage{tcolorbox}
\newcommand\ChapterFont{\rmfamily\selectfont\huge}
\newcommand\SectionFont{\bfseries\rmfamily\selectfont\Large}
\titleformat{\chapter}[block]
{\normalfont\ChapterFont\huge\color{myblueii}}%\raisebox{-0.6\height}
{\tcbset{colframe=mybluei, boxrule=0.8pt, left=0pt, right=0pt, top=0pt, bottom=0pt}\raisebox{-0.48\height}{\rotatebox{90}{\tcbox[boxsep=4pt, colback= white ]{\color{mybluei}\Large\chaptertitlename}}}\hskip 0.25em\mbox{\tcbox[ boxsep=12pt, colback=mybluei, tcbox raise = -35pt]{\color{white}\bfseries\fontsize{70}{70}\selectfont\thechapter}}}
{0.5em}
{#1\vskip0.6ex\endgraf\titlerule[1ex]}[]
\titleformat{name=\chapter,numberless}[block]
{\normalfont\selectfont\huge\color{myblueii}}
{}
{0pt}
{\parbox[b]{70pt}{\mbox{}}%
\hspace{15pt}%
\parbox[b]{\dimexpr\textwidth-15pt}{%
\raggedright\bfseries#1\vskip6pt%
}%
}
\titleformat{\section}
{\normalfont\small\sffamily\SectionFont\color{myblueii}}
{\colorbox{mybluei}{%
\parbox[c][16pt][c]{40pt}{%
\centering\textcolor{white}{\SectionFont\Large\rmfamily\thesection}%
}%
}%
}
{1em}
{#1}
[\vspace{-0.755\baselineskip}%
\color{myblueii}\hspace*{\dimexpr40pt+2\fboxsep\relax}%
\rule{\dimexpr\textwidth-40pt-2\fboxsep\relax}{1pt}%
]
\usepackage{amsmath, amsthm, amssymb, amsfonts, enumerate}%, dlfltxbcodetips
\renewcommand{\qedsymbol}{$\blacksquare$}
\usepackage{lipsum}
\begin{document}
\chapter{Vectorruimtem}
\lipsum[1]
\end{document}