具有特殊格式的页眉和页脚

具有特殊格式的页眉和页脚
\documentclass[a4paper]{article}

\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{xcolor}

\usepackage{lipsum}
\setlength\headheight{26pt} %% just to make warning go away. Adjust the value after looking into the warning.
% \rhead{{\color{blue}\rule{1cm}{1cm}}}

\rhead{\includegraphics[width=5cm]{1}}
\lhead{\includegraphics[width=4cm]{2}}

% \rhead{\begin{picture}(3,3) \put(3,3){\includegraphics[width=1cm]{example-image-a}} \end{picture}}

\begin{document}

\lipsum

\end{document}

我怎样才能在右侧添加像这样的编号页脚?:

数字

我如何才能退出在页眉下创建的规则?并在页脚上添加规则?

谢谢

答案1

这看起来像是 的工作tikz。您可能需要稍微调整一些设置。

可以使用 禁用头部规则\renewcommand{\headrulewidth}{0pt}。我还插入了彩色脚规则,如图片所示。

结果(底部和右侧的黑色和灰色框架来自我的 PDF 查看器):

在此处输入图片描述

代码:

\documentclass[a4paper]{article}

\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{xcolor}

\usepackage{tikz}

\usepackage{lipsum}
\setlength\headheight{26pt} %% just to make warning go away. Adjust the value after looking into the warning.
% \rhead{{\color{blue}\rule{1cm}{1cm}}}

\rhead{\includegraphics[width=5cm,height=22pt]{example-image-a}}
\lhead{\includegraphics[width=4cm,height=22pt]{example-image-b}}

% \rhead{\begin{picture}(3,3) \put(3,3){\includegraphics[width=1cm]{example-image-a}} \end{picture}}

% remove rule in head
\renewcommand{\headrulewidth}{0pt}

% colored foot rule
\let\origfootrule\footrule
\renewcommand{\footrule}{{\color{blue!80!black}\origfootrule}}
\renewcommand{\footrulewidth}{0.4pt}


\cfoot{} % clear centeer foot
\rfoot{%
    \begin{tikzpicture}[remember picture,overlay]
    \fill[violet!75]
        (current page.south east) --
        ++(-5,0) -- node[white,below right,node font=\sffamily,scale=4] {\thepage}
        ++(5,5) -- cycle;
    \end{tikzpicture}
}

\begin{document}

\lipsum

\end{document}

答案2

这里还有另一个建议,即使用包。scrlayer-scrpage然后fancyhdr,您可以为页码声明一个新层,并将该层添加到层 pagestyle 中scrheadings

\documentclass[a4paper]{article}
\usepackage{lipsum}% only for dummy text
\usepackage{tikz}% loads also graphicx, xcolor, ...

\colorlet{footsepline}{blue!80!black}
\colorlet{pagenumberbg}{violet}
\colorlet{pagenumberfg}{white}

\usepackage[footsepline]{scrlayer-scrpage}% sets pagestyle scrheadings
\setlength\headheight{26pt} %% just to make warning go away. Adjust the value after looking into the warning.
\clearpairofpagestyles
\ihead{\includegraphics[width=5cm,height=22pt]{example-image-a}}
\ohead{\includegraphics[width=4cm,height=22pt]{example-image-b}}

\newlength\pagenumberbgsize
\setlength\pagenumberbgsize{5cm}% sets the size of the colored triangle
\newsavebox\pagenumberbgbox
\savebox\pagenumberbgbox{\tikz\fill[pagenumberbg]
  (0,0)--++(\pagenumberbgsize,0)--+(0,\pagenumberbgsize)--cycle;}
\DeclareNewLayer[
  foreground,
  align=br,
  area={\paperwidth}{\paperheight}{\pagenumberbgsize}{\pagenumberbgsize},
  mode=picture,
  contents={%
    \putLL{\usebox\pagenumberbgbox}%
    \put(\LenToUnit{.66\layerwidth},\LenToUnit{.33\layerheight}){\makebox(0,0){\pagemark}}%
  }
]{pagenumber}
\AddLayersToPageStyle{scrheadings}{pagenumber}

\addtokomafont{footsepline}{\color{footsepline}}
\addtokomafont{pagenumber}{\Huge\bfseries\sffamily\color{pagenumberfg}}

\begin{document}
\lipsum
\clearpage
\setcounter{page}{100}% test a page number with 3 digits
\lipsum
\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容