我怎样才能消除头部规则的偏移?

我怎样才能消除头部规则的偏移?

我的主要规则在我的论文中被抵消了。它看起来像这样:

在此处输入图片描述

我发现一个表现出相同行为的 MWE:

\documentclass{article}
\usepackage{titleps}% http://ctan.org/pkg/titleps


\expandafter\def\expandafter\normalsize\expandafter{%

    \setlength\abovedisplayskip{20pt}
    \setlength\belowdisplayskip{20pt}
    \setlength\abovedisplayshortskip{5pt}
    \setlength\belowdisplayshortskip{20pt}
}


\newpagestyle{main}{
\setheadrule{.4pt}% Header rule
\sethead{\thesubsection\ \subsectiontitle}% left
        {}%                                 center
        {\thesection\ \sectiontitle}%       right
}

\pagestyle{main}

\begin{document}

This is the introduction. This is the introduction. This is the introduction. This is the introduction. This is the introduction. This is the introduction. This is the introduction. This is the introduction. 
\section{A section}

This is the introduction. This is the introduction. This is the introduction. This is the introduction. This is the introduction. This is the introduction. 

\subsection{A subsection}
dsd
\subsubsection{A subsubsection}
\end{document}

我意识到问题是由命令 \expandafter\def\expandafter\normalsize\expandafter 引起的。如果我删除它,问题就会消失。但是我无法删除它,因为我需要它来计算间距方程。

我应该怎么办?

谢谢

答案1

我认为您丢失了一些正在复制的代码:

\documentclass{article}
\usepackage{titleps}

\expandafter\def\expandafter\normalsize\expandafter{%
  \normalsize
  \setlength\abovedisplayskip{20pt}%
  \setlength\belowdisplayskip{20pt}%
  \setlength\abovedisplayshortskip{5pt}%
  \setlength\belowdisplayshortskip{20pt}%
}

\newpagestyle{main}{%
  \setheadrule{.4pt}% Header rule
  \sethead{\thesubsection\ \subsectiontitle}% left
          {}%                                 center
          {\thesection\ \sectiontitle}%       right
}

\pagestyle{main}

\begin{document}

This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 

\section{A section}

This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 

\subsection{A subsection}
dsd
\subsubsection{A subsubsection}

\end{document}

\normalsize缺少一个(在重新定义时扩展的)(并且还有一些%)。

在此处输入图片描述

一个更简单的策略是

\documentclass{article}
\usepackage{titleps}
\usepackage{etoolbox}

\appto\normalsize{%
  \setlength\abovedisplayskip{20pt}%
  \setlength\belowdisplayskip{20pt}%
  \setlength\abovedisplayshortskip{5pt}%
  \setlength\belowdisplayshortskip{20pt}%
}

其余都一样。

答案2

我建议你更换

\expandafter\def\expandafter\normalsize\expandafter{%

\AtBeginDcoument{%

完整的 MWE (最小工作示例):

\documentclass{article}
\usepackage{titleps}

\AtBeginDocument{%
    \setlength\abovedisplayskip{20pt}
    \setlength\belowdisplayskip{20pt}
    \setlength\abovedisplayshortskip{5pt}
    \setlength\belowdisplayshortskip{20pt}
}

\newpagestyle{main}{%
\setheadrule{.4pt}% Header rule
\sethead{\thesubsection\ \subsectiontitle}% left
        {}%                                 center
        {\thesection\ \sectiontitle}%       right
}
\pagestyle{main}

\begin{document}
\noindent
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction.

\section{A section}
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction. 
This is the introduction. This is the introduction.

\subsection{A subsection}
dsd

\subsubsection{A subsubsection}
\end{document}

相关内容