好吧,我正在使用下面这样的代码,基本上我想为本章的编号添加装饰...有什么想法或例子吗?非常感谢
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
%\ifnum \c@secnumdepth >\m@ne
% \huge\bfseries \@chapapp\space \thechapter
% \par\nobreak
% \vskip 20\p@
%\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
% Datei fancyheaders.tex
% Kopf- und Fu�zeile mit Paket fancyhdr
% Paket muss extra installiert werden
\usepackage{fancyhdr} % Paket laden
\pagestyle{fancy} % bereitgestelltes Layout 'fancy' laden
% Am Anfang jeder neuen \section wird deren Name in die linke Kopfzeile geschrieben, dazu neuen command definieren
%\renewcommand{\sectionmark}[1]{\markboth{\thesection\ #1}{}}
% Am Anfang jeder neuen \subsection wird deren Name in die rechte Kopfzeile geschrieben, dazu neuen command definieren
%\renewcommand{\subsectionmark}[1]{\markright{\thesubsection\ #1}}
% Die so erzeugten Inhalte stehen jetzt mit den Befehlen
% \leftmark und \rightmark zur Verf�gung und k�nnen wie im folgenden eingesetzt werden:
% \lhead[\rightmark]{\rightmark}
%\renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\textsl{\thesection\ #1}}}
%%\renewcommand\chaptermark[1]{\markboth{\textsl{\chaptername\ \thechapter\ : #1}}{}}
%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
%\ifnum \c@secnumdepth >\m@ne
% \huge\bfseries \@chapapp\space \thechapter
% \par\nobreak
% \vskip 20\p@
%\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{blindtext}
\newcommand{\chapnumfont}{% % define font for chapter number
\usefont{T1}{pnc}{b}{n}% % choose New Chancery, bold, normal shape
\fontsize{100}{100}% % font size 100pt, baselineskip 100pt
\selectfont% % activate font
}
\colorlet{chapnumcol}{gray!100} % color for chapter number
\titleformat{\chapter}[display]
{\filleft\bfseries}
{\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
{-24pt}
{\Huge}
\fancyhead{}
%\fancyhead[L]{\leftmark}
\fancyhead[L]{}
\fancyhead[R]{}%{\rightmark}
\fancyfoot{}
\fancyfoot[L]{}
\fancyfoot[C]{}%{\leftmark}
\fancyfoot[R]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% Style "plain" berschreiben, das bei
%\chapter{...} mit aktiviert wird
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.4pt}}
答案1
下面我介绍了几个借助titlesec
包裹。
两个简单的替代方案。第一个只是在数字周围画一个框架;第二个使用带有阴影的彩色背景(需要 TikZ):
\documentclass{book}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}
\usepackage{tikz}
\begin{document}
\let\cleardoublepage\relax % just for the example
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\fbox{\makebox[3cm][r]{\fontsize{100}{130}\color{gray}\selectfont\thechapter}}}
{20pt}
{\Huge}
\chapter{Test chapter}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\tikz\node[inner xsep=0pt,top color=gray!10,bottom color=gray!70,text width=3.5cm,align=right]
{{\fontsize{100}{130}\color{gray}\selectfont\thechapter}};%
}
{20pt}
{\Huge}
\chapter{Test chapter}
\end{document}
再来一条,在右边添加一个简单的规则:
\documentclass{book}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}
\usepackage{tikz}
\begin{document}
\let\cleardoublepage\relax % just for the example
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{{\fontsize{100}{130}\color{gray}\selectfont\thechapter\rlap{\vrule width 2pt height 100pt}}}
{20pt}
{\Huge}
\chapter{Test chapter}
\end{document}
一些更精致的装饰使用pgfornament
:
\documentclass{book}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{pgfornament}
\usetikzlibrary{calc}
\begin{document}
\let\cleardoublepage\relax % just for the example
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\begin{tikzpicture}
\node[text width=3cm,align=center] (chapnum)
{\fontsize{100}{130}\color{gray}\selectfont\thechapter};%
\node[shift={(-1cm,1cm)},anchor=north west](CNW)
at (chapnum.north west) {\pgfornament[width=1.75cm]{61}};
\node[shift={(1cm,1cm)},anchor=north east](CNE)
at (chapnum.north east) {\pgfornament[width=1.75cm,symmetry=v]{61}};
\node[shift={(-1cm,-1cm)},anchor=south west](CSW)
at (chapnum.south west) {\pgfornament[width=1.75cm,symmetry=h]{61}};
\node[shift={(1cm,-1cm)},anchor=south east](CSE)
at (chapnum.south east) {\pgfornament[width=1.75cm,symmetry=c]{61}};
\end{tikzpicture}
}
{20pt}
{\Huge}
\chapter{Test chapter}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\begin{tikzpicture}
\node[text width=3cm,align=center] (chapnum)
{\fontsize{100}{130}\color{gray}\selectfont\thechapter};%
\node[shift={(-1cm,10pt)},anchor=north west](CNW)
at (chapnum.north west) {\pgfornament[width=1cm]{7}};
\node[shift={(1cm,10pt)},anchor=north east](CNE)
at (chapnum.north east) {\pgfornament[width=1cm,symmetry=v]{7}};
\end{tikzpicture}
}
{20pt}
{\Huge}
\chapter{Test chapter}
\end{document}
还有两个示例,这次使用 Web-O-Mints 字体:
\documentclass{book}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*\wb[2]{%
\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\begin{document}
\let\cleardoublepage\relax % just for the example
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\begin{tikzpicture}
\node[text width=3cm,align=center] (chapnum)
{\fontsize{100}{130}\color{gray}\selectfont\thechapter};%
\node[shift={(-1cm,1cm)},anchor=north west](CNW)
at (chapnum.north west) {\wb{20}{24}I};
\node[shift={(1cm,1cm)},anchor=north east](CNE)
at (chapnum.north east) {\wb{20}{24}J};
\end{tikzpicture}
}
{20pt}
{\Huge}
\chapter{Test chapter}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\begin{tikzpicture}
\node[text width=3cm,align=center] (chapnum)
{\fontsize{100}{130}\color{gray}\selectfont\thechapter};%
\node[shift={(-1cm,1cm)},anchor=north west](CNW)
at (chapnum.north west) {\wb{40}{48}A};
\node[shift={(1cm,1cm)},anchor=north east](CNE)
at (chapnum.north east) {\wb{40}{48}B};
\end{tikzpicture}
}
{20pt}
{\Huge}
\chapter{Test chapter}
\end{document}