如何对齐页眉/页脚

如何对齐页眉/页脚

我想获取标题的左边框(请参见下文)到部分标题的尖端以及文本末尾的右边框。我使用fancyhdr包,代码如下:

\documentclass[10pt]{article}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{caption}

\makeatletter
\newlength{\bibhang}
\setlength{\bibhang}{1em}
\newlength{\bibsep}
 {\@listi \global\bibsep\itemsep \global\advance\bibsep by\parsep}
\newenvironment{bibsection}%
        {\vspace{-\baselineskip}\begin{list}{}{%
       \setlength{\leftmargin}{\bibhang}%
       \setlength{\itemindent}{-\leftmargin}%
       \setlength{\itemsep}{\bibsep}%
       \setlength{\parsep}{\z@}%
        \setlength{\partopsep}{0pt}%
        \setlength{\topsep}{0pt}}}
        {\end{list}\vspace{-.6\baselineskip}}
\makeatother

\reversemarginpar

\usepackage[paper=a4paper,
            %includefoot, % Uncomment to put page number above margin
            marginparwidth=25mm,    % Length of section titles
            marginparsep=1.5mm,       % Space between titles and text
            margin=25mm,              % 25mm margins
            includemp]{geometry}

\usepackage{paralist}
\setlength{\parindent}{0in}



\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyfootoffset{.2\textwidth}%\marginparsep+\marginparwidth
\fancyheadoffset{20pt}
\lhead{The Curiculum Vitae of Vahid Ebrahimzade}
\rhead{\thepage}
\chead{}
\fancyfoot{}

\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
            linkcolor=blue,urlcolor=blue,
            anchorcolor=blue,citecolor=kblue}

\renewcommand{\section}[2]%
        {\pagebreak[2]\vspace{1.3\baselineskip}%
         \phantomsection\addcontentsline{toc}{section}{#1}%
         \hspace{0in}%
         \marginpar{
         \raggedright \scshape #1}#2}


\newenvironment{innerlist}[1][\enskip\textbullet]%
        {\begin{compactitem}[#1]}{\end{compactitem}}

\newcommand{\blankline}{\quad\pagebreak[2]}

\begin{document}

\section{Forschungs-\newline t\"atigkeit}
%\vspace{.5cm}
\begin{bibsection}
\item Modellreduktion Methoden
\item Surrogate Modellierung; Polynomfunktion Methoden, Radiale Basisfunktion Methoden
\end{bibsection}

\vspace{2cm}        

\end{document}      

这导致: 在此处输入图片描述

谁能帮我?

答案1

您的页眉需要向左偏移,其宽度等于为边注保留的空间 ( \marginparwidth) 加上边注与正文之间的间隔 ( \marginparsep),如下所示

\fancyheadoffset[L]{\dimexpr\marginparsep+\marginparwidth}

完整示例:

\documentclass[10pt]{article}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{caption}

\makeatletter
\newlength{\bibhang}
\setlength{\bibhang}{1em}
\newlength{\bibsep}
 {\@listi \global\bibsep\itemsep \global\advance\bibsep by\parsep}
\newenvironment{bibsection}%
        {\vspace{-\baselineskip}\begin{list}{}{%
       \setlength{\leftmargin}{\bibhang}%
       \setlength{\itemindent}{-\leftmargin}%
       \setlength{\itemsep}{\bibsep}%
       \setlength{\parsep}{\z@}%
        \setlength{\partopsep}{0pt}%
        \setlength{\topsep}{0pt}}}
        {\end{list}\vspace{-.6\baselineskip}}
\makeatother

\reversemarginpar

\usepackage[paper=a4paper,
            %includefoot, % Uncomment to put page number above margin
            marginparwidth=25mm,    % Length of section titles
            marginparsep=1.5mm,       % Space between titles and text
            margin=25mm,              % 25mm margins
            includemp]{geometry}

\usepackage{paralist}
\setlength{\parindent}{0in}



\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyheadoffset[L]{\dimexpr\marginparsep+\marginparwidth}
\fancyfootoffset{.2\textwidth}%\marginparsep+\marginparwidth
\lhead{The Curiculum Vitae of Vahid Ebrahimzade}
\rhead{\thepage}
\chead{}
\fancyfoot{}

\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
            linkcolor=blue,urlcolor=blue,
            anchorcolor=blue,citecolor=kblue}

\renewcommand{\section}[2]%
        {\pagebreak[2]\vspace{1.3\baselineskip}%
         \phantomsection\addcontentsline{toc}{section}{#1}%
         \hspace{0in}%
         \marginpar{
         \raggedright \scshape #1}#2}

\newenvironment{innerlist}[1][\enskip\textbullet]%
        {\begin{compactitem}[#1]}{\end{compactitem}}

\newcommand{\blankline}{\quad\pagebreak[2]}

\begin{document}

\section{Forschungs-\newline t\"atigkeit}
%\vspace{.5cm}
\begin{bibsection}
\item Modellreduktion Methoden
\item Surrogate Modellierung; Polynomfunktion Methoden, Radiale Basisfunktion Methoden
\end{bibsection}

\vspace{2cm}        

\end{document}

在此处输入图片描述

顺便提一下,\newline参数中的命令\section会给您带来问题(使用书签,最终是 ToC 条目)。如果您使用\section允许可选参数的重新定义,这个问题就可以轻松解决。

相关内容