![在页脚中创建水平和垂直文本的混合](https://linux22.com/image/345447/%E5%9C%A8%E9%A1%B5%E8%84%9A%E4%B8%AD%E5%88%9B%E5%BB%BA%E6%B0%B4%E5%B9%B3%E5%92%8C%E5%9E%82%E7%9B%B4%E6%96%87%E6%9C%AC%E7%9A%84%E6%B7%B7%E5%90%88.png)
我正在尝试在底部角落制作一个页脚,其中混合了水平页码、彩色背景以及一些包含固定文本(例如报告标题)和当前部分名称的垂直文本,如下图所示(示例页面的右下角)。我找不到任何地方如何做到这一点,非常感谢任何帮助!包括 MWE。
\documentclass[letterpaper,12pt,twoside]{book}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{fancyhdr}
\usepackage{graphicx,tikz}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usetikzlibrary{calc}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[O]{
\normalfont\sffamily\small\bfseries\scshape
\begin{tikzpicture}[overlay, remember picture]%
\fill[blue] ($(current page.south east)+(-1.5in,0in)$) rectangle ($(current page.south east)+(-.5in,.75in)$);
\node[anchor=center, text=white] at ($(current page.south east)+(-1in,.5in)$) {\thepage};
\end{tikzpicture}
}
\fancyfoot[E]{
\normalfont\sffamily\small\bfseries\scshape
\begin{tikzpicture}[overlay, remember picture]%
\fill[blue] ($(current page.south west)+(1.5in,0in)$) rectangle ($(current page.south west)+(0.5in,.75in)$);
\node[anchor=center, text=white] at ($(current page.south west)+(1in,.5in)$) {\thepage};
\end{tikzpicture}
}
\begin{document}
\pagestyle{fancy}
% Title e.g., `Report Template'
\section{Overview}
\lipsum[1]
\end{document}
答案1
scrlayer
以下是使用包的建议fancyhdr
:
\documentclass[letterpaper,12pt,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage[automark]{scrlayer}[2016/10/03]
\renewcommand\chaptermarkformat{}
\renewcommand\sectionmarkformat{}
\newkomafont{outertext}{\normalfont\normalcolor\sffamily\small\bfseries}
\addtokomafont{pagenumber}{\color{white}\sffamily\bfseries}
\DeclareNewLayer[
oddpage,
background,
align=br,
hoffset=\paperwidth-.5in,
voffset=\paperheight,
width=1in,
height=1in,
mode=picture,
contents={%
\putLL{\textcolor{blue}{\rule{\layerwidth}{\layerheight}}}%
\put(\LenToUnit{.5\layerwidth},\LenToUnit{.75\layerheight})
{\raisebox{-\height}{\makebox[0pt]{\pagemark}}}%
}
]{pagenumber.odd}
\DeclareNewLayer[
clone=pagenumber.odd,
evenpage,
align=lb,
hoffset=.5in
]{pagenumber.even}
\makeatletter
\DeclareNewLayer[
clone=pagenumber.odd,
contents=\putUR{\makebox[0pt][r]{%
\rotatebox[origin=tr]{-90}{\usekomafont{outertext}%
\MakeUppercase{\@title}%
\ifstr{\rightmark}{}
{\ifstr{\rightbotmark}{}{}{\ \textbar\ \rightbotmark}}
{\ \textbar{}\ \rightmark}%
}\enskip}}
]{text.odd}
\DeclareNewLayer[
clone=pagenumber.even,
contents=\putUL{\makebox[0pt][l]{\enskip
\rotatebox[origin=tl]{90}{\usekomafont{outertext}%
\MakeUppercase{\@title}%
\ifstr{\leftmark}{}{}{\ \textbar\ \leftmark}%
}}}
]{text.even}
\makeatother
\DeclareNewPageStyleByLayers{mystyle}{%
pagenumber.odd,pagenumber.even,%
text.odd,text.even%
}
\DeclarePageStyleAlias{plain}{mystyle}
\pagestyle{mystyle}
\usepackage{blindtext}% dummy text
\begin{document}
\title{Report Title}
\blinddocument
\end{document}
结果: