fancyhdr:如何在纸张的最左边开始页眉

fancyhdr:如何在纸张的最左边开始页眉

我正在尝试制作一个带有页眉的文档,该页眉由一侧圆角的矩形组成,该矩形从纸张宽度的最左侧开始。

我无法让矩形从文本宽度之外开始。我该如何在 fancyhdr-setup 中包含它?此外,但优先级较低的是,蓝色圆角矩形中的白色文本是否可以从 textwidth 开始,即不在最左边?(也就是说,在解决了第一个问题之后)。

这是我目前的代码:

\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[a4paper, width=150mm, top=25mm, bottom=25mm, includeheadfoot]{geometry}
\usepackage{lipsum}
\usepackage{xcolor}


\definecolor{myblue}{HTML}{004173}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning, shapes.misc}

%headers and footers

\usepackage{fancyhdr}
\pagestyle{fancy}



\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{1cm}


\fancyhead{}

\pagestyle{fancy}

\lhead{\begin{tikzpicture}[node distance = 2mm, every node/.style={rounded rectangle, minimum size = 6mm,draw=myblue,fill=myblue, text = white, font=\small}, very thick]
\node (author) [rounded rectangle west arc=none, align = left] {One author et al. \\
An here is an unnecessarily long title with many, many words};
\node (report) [rounded rectangle, align = left, right= of author] {Our Report \\ 1/2017};
\end{tikzpicture}
}


\fancyfoot{}
\rfoot{
\begin{tikzpicture}[pagina/.style={circle, minimum size = 6mm, draw= myblue, fill = myblue, text = white}]
\node (pagerino) [pagina] {\thepage};
\end{tikzpicture}}





\begin{document}

\lipsum

\end{document}

结果是:

在此处输入图片描述

答案1

左边距(带有oneside\oddsidemargin加一英寸;您可以将此尺寸传递给\fancyheadoffset

\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[a4paper, width=150mm, top=25mm, bottom=25mm, includeheadfoot]{geometry}
\usepackage{lipsum}
\usepackage{xcolor}


\definecolor{myblue}{HTML}{004173}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning, shapes.misc}

%headers and footers

\usepackage{fancyhdr}


\fancyhf{} % clear header and footer
\fancyhead[L]{%
  \begin{tikzpicture}[
    node distance = 2mm,
    every node/.style={
      rounded rectangle,
      minimum size = 6mm,
      draw=myblue,
      fill=myblue,
      text = white,
      font=\small,
    },
    very thick,
  ]
  \node (author) [rounded rectangle west arc=none, align = left] {%
    One author et al. \\
    An here is an unnecessarily long title with many, many words%
  };
  \node (report) [rounded rectangle, align = left, right= of author] {%
    Our Report \\ 1/2017%
  };
  \end{tikzpicture}%
}
\fancyfoot[R]{%
  \begin{tikzpicture}[
    pagina/.style={
      circle,
      minimum size = 6mm,
      draw= myblue,
      fill = myblue,
      text = white,
    },
  ]
  \node (pagerino) [pagina] {\thepage};
  \end{tikzpicture}%
}

\fancyheadoffset[L]{\dimexpr\oddsidemargin+1in\relax}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{34pt}% value suggested by fancyhdr
\pagestyle{fancy}

\begin{document}

\lipsum

\end{document}

在此处输入图片描述

相关内容