在页脚中创建水平和垂直文本的混合

在页脚中创建水平和垂直文本的混合

我正在尝试在底部角落制作一个页脚,其中混合了水平页码、彩色背景以及一些包含固定文本(例如报告标题)和当前部分名称的垂直文本,如下图所示(示例页面的右下角)。我找不到任何地方如何做到这一点,非常感谢任何帮助!包括 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}

结果:

在此处输入图片描述

相关内容