我使用pgfornament
包装将装饰品放在角落里,如下面的 MWE 所示:
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage{pgfornament}
\usepackage{eso-pic}
\newcommand\AtPageUpperRight[1]{\AtPageUpperLeft{%
\put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
}}%
\newcommand\AtPageLowerRight[1]{\AtPageLowerLeft{%
\put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
}}%
\AddToShipoutPictureBG{%
\AtPageUpperLeft{\put(0,-25){\pgfornament[width=1.75cm]{61}}}
\AtPageUpperRight{\put(-50,-25){\pgfornament[width=1.75cm,symmetry=v]{61}}}
\AtPageLowerLeft{\put(0,25){\pgfornament[width=1.75cm,symmetry=h]{61}}}
\AtPageLowerRight{\put(-50,25){\pgfornament[width=1.75cm,symmetry=c]{61}}}
}
\begin{document}
\title{Magnificent title}
\maketitle
\frontmatter
\tableofcontents
\mainmatter
\chapter{New chapter}
\lipsum[5]
\chapter{Another chapter}
\lipsum[4]
\end{document}
但我想只从特定页面开始放置这些装饰,比如摘自第 1 章. 我该如何修改上面的代码,最好不添加有新包裹吗?
答案1
只需将代码放在后面\mainmatter
(或您想要的任何位置)
.
.
\mainmatter
\AddToShipoutPictureBG{%
\AtPageUpperLeft{\put(0,-25){\pgfornament[width=1.75cm]{61}}}
\AtPageUpperRight{\put(-50,-25){\pgfornament[width=1.75cm,symmetry=v]{61}}}
\AtPageLowerLeft{\put(0,25){\pgfornament[width=1.75cm,symmetry=h]{61}}}
\AtPageLowerRight{\put(-50,25){\pgfornament[width=1.75cm,symmetry=c]{61}}}
}
\chapter{New chapter}
.
.
您还可以定义宏来为多个页面添加装饰:
\newcommand{\beautify}{%
\AddToShipoutPictureBG{%
\AtPageUpperLeft{\put(0,-25){\pgfornament[width=1.75cm]{61}}}
\AtPageUpperRight{\put(-50,-25){\pgfornament[width=1.75cm,symmetry=v]{61}}}
\AtPageLowerLeft{\put(0,25){\pgfornament[width=1.75cm,symmetry=h]{61}}}
\AtPageLowerRight{\put(-50,25){\pgfornament[width=1.75cm,symmetry=c]{61}}}
}
}
\newcommand{\simplify}{%
\cleardoublepage\ClearShipoutPictureBG
}
并像使用它一样
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
%\usepackage{fontspec}
\usepackage{lipsum}
\usepackage{pgfornament}
\usepackage{eso-pic}
\newcommand\AtPageUpperRight[1]{\AtPageUpperLeft{%
\put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
}}%
\newcommand\AtPageLowerRight[1]{\AtPageLowerLeft{%
\put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
}}%
\newcommand{\beautify}{%
\AddToShipoutPictureBG{%
\AtPageUpperLeft{\put(0,-25){\pgfornament[width=1.75cm]{61}}}
\AtPageUpperRight{\put(-50,-25){\pgfornament[width=1.75cm,symmetry=v]{61}}}
\AtPageLowerLeft{\put(0,25){\pgfornament[width=1.75cm,symmetry=h]{61}}}
\AtPageLowerRight{\put(-50,25){\pgfornament[width=1.75cm,symmetry=c]{61}}}
}
}
\newcommand{\simplify}{%
\cleardoublepage\ClearShipoutPictureBG
}
\begin{document}
\title{Magnificent title}
\maketitle
\frontmatter
\tableofcontents
\mainmatter
\beautify
\chapter{New chapter}
\lipsum[5]
\simplify
\chapter{Another chapter}
\lipsum[4]
\end{document}