考虑以下代码:
% DOCUMENT TYPE
\documentclass[12pt,a4paper]{article}
% PACKAGES
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[margin=10pt,font=footnotesize,labelfont=bf]{caption}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{fancybox}
\usepackage{amsmath}
\usepackage{array}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{floatrow}
\usepackage{subfigure}
\usepackage{enumitem}
\usepackage{appendix}
\usepackage{listings}
\usepackage{multicol}
\usepackage{sistyle}
\usepackage{color}
\usepackage{tikz}
\usepackage{lmodern}
\usepackage{multicol}
\usepackage{seqsplit}
\usepackage[listings,skins,theorems]{tcolorbox}
\usepackage{libertine}
\usepackage[export]{adjustbox}
\usepackage[normalem]{ulem}
\usepackage[top=1.25in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\usepackage{calc}
\usetikzlibrary{calc}
\usepackage{hyperref}
% PRESENTATION
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancyfoot[CE,CO]{\thepage}
\hypersetup{colorlinks, citecolor=blue, filecolor=blue, linkcolor=blue, urlcolor=blue}
% DOCUMENT BEGINNING
\title{Title}
\author{Author}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\newpage
\section{First section}
\subsection{First subsection}
\lipsum
\lipsum
\subsection{Second subsection}
\lipsum
\lipsum
\section{Second section}
\subsection{First subsection}
\lipsum
\lipsum
\subsection{Second subsection}
\lipsum
\lipsum
\section{Third section}
\subsection{First subsection}
\lipsum
\lipsum
\subsection{Second subsection}
\lipsum
\lipsum
\end{document}
% DOCUMENT END
输出结果如下:
我的目标是使用可用的图像获得以下结果这里,可能使用 tikz 和/或 fancyhdr 来设计布局(但欢迎任何其他包):
和:
- 图像顶部导入为 2 厘米的标题,底部有 0.2 厘米的蓝线
- 当前章节在偶数页,文档标题在奇数页,以大号空白大写字母显示,左对齐
- 图像底部导入为 0.5 厘米页脚,顶部有 0.2 厘米蓝线
- 当前页码以空白字母显示,居中
- 除了第一个标题页
我对 tikz 一无所知,但我想学习如何做到这一点。
这样的事该怎么办呢?
答案1
以下是使用的建议scrlayer
定义新的页面样式。
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tikz}% loads also graphicx, xcolor
\usepackage{lmodern}
\usepackage[top=1.25in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\usepackage{scrlayer}[2015/02/07]
\newkomafont{myheadfoot}{\color{white}\bfseries\sffamily}
\newkomafont{myhead}{\Huge}
\newkomafont{mypagenumber}{\normalsize}
\newkomafont{mysepline}{\color{blue}}
\newcommand\headimageheight{2cm}
\newcommand\footimageheight{.5cm}
\newcommand\seplineheight{.2cm}
\newcommand\headtexthoffset{1cm}
\renewcommand\sectionmark[1]{\markright{#1}}
\newcommand\titleinhead{}
\newcommand\mytitle[1]{\title{#1}\renewcommand\titleinhead{#1}}
\newsavebox\headimage
\sbox\headimage{%
\tikz{
\clip(0,0)rectangle(\paperwidth,-\headimageheight);
\node[inner sep=0pt,outer sep=0pt,anchor=north west]{%
\includegraphics[width=\paperwidth]{image}};
}%
\llap{\usekomafont{mysepline}\rule[-\seplineheight]{\paperwidth}{\seplineheight}}%
}
\newsavebox\footimage
\sbox\footimage{%
\tikz{
\clip(0,0)rectangle(\paperwidth,\footimageheight);
\node[inner sep=0pt,outer sep=0pt,anchor=south west]{%
\includegraphics[width=\paperwidth]{image}};
}%
\llap{\usekomafont{mysepline}\rule[\footimageheight]{\paperwidth}{\seplineheight}}%
}
\DeclareNewLayer[
background,
area={0pt}{0pt}{\paperwidth}{\headimageheight},
contents={%
\parbox[c][\layerheight]{\layerwidth}{%
\vspace*{\stretch{2}}
\hspace*{\headtexthoffset}%
\usekomafont{myheadfoot}\usekomafont{myhead}\smash{\MakeUppercase{%
\ifodd\value{page}\titleinhead\else\rightmark\fi%
}}%
\vspace*{\stretch{1}}}%
%}%
}
]{headtext}
\DeclareNewLayer[
clone=headtext,
addheight=\seplineheight,
contents={\usebox\headimage}
]{headimage}
\DeclareNewLayer[
background,
align=b,
area={0pt}{\paperheight}{\paperwidth}{\footimageheight},
contents={%
\parbox[c][\layerheight][c]{\layerwidth}{\centering\usekomafont{myheadfoot}\usekomafont{mypagenumber}\thepage}%
}
]{foottext}
\DeclareNewLayer[
clone=foottext,
addheight=\seplineheight,
contents={\parbox{\layerwidth}{\usebox\footimage}}
]{footimage}
\DeclarePageStyleByLayers{headfootimage}{%
headimage,headtext,%
footimage,foottext%
}
\usepackage{lipsum}% dummy text
\begin{document}
\mytitle{Title}
\author{Author}
\maketitle
\tableofcontents
\clearpage
\pagestyle{headfootimage}
\section{First section}
\subsection{First subsection}
\lipsum
\lipsum
\subsection{Second subsection}
\lipsum
\lipsum
\section{Second section}
\subsection{First subsection}
\lipsum
\lipsum
\subsection{Second subsection}
\lipsum
\lipsum
\section{Third section}
\subsection{First subsection}
\lipsum
\lipsum
\subsection{Second subsection}
\lipsum
\lipsum
\end{document}