添加自定义页眉时出现小缩进

添加自定义页眉时出现小缩进

当我将 \pagestyle{myheader} 添加到 MWE 时,段落的第一行会出现一个小的缩进。我不想让它出现在那里。感谢 Gonzalo Medina 的回答我做了Section格式描述的部分。

梅威瑟:

\documentclass[11pt,oneside,article]{memoir}
\usepackage{lipsum}

% Begin Section format 
\newcommand{\marginbox}[1]{%
  \parbox[t][0pt]{10em}{%
  \upshape\sffamily\raggedright\mbox{}#1}%
}
\newcommand{\marginhead}[1]{%
  \bfseries\smash{\raisebox{\baselineskip}{\llap{\marginbox{#1}\kern3em}}}%
}

\setsecindent{0em}
\setsecheadstyle{\marginhead}
\setbeforesecskip{1em}
\setaftersecskip{0em}
\setsechook{%
  \setsecnumformat{\csname   the##1\endcsname\enspace\par\nobreak}%
}
% End Section format

\copypagestyle{myheader}{ruled}
\makeevenhead{myheader}{}{}{My-Name}
\makeoddhead{myheader}{}{}{Other-Name}
\pagestyle{myheader}

\begin{document}

% Layout
\settrims{0pt}{0pt}
\settypeblocksize{562pt}{300pt}{*}
\setulmargins{114pt}{*}{*}
\setheadfoot{28pt}{24pt}
\setheaderspaces{*}{*}{*}
\setmarginnotes{1pt}{1pt}{1pt}
\setlrmargins{210pt}{*}{*}
\checkandfixthelayout

\section{Introduction}
\lipsum[4] 

\end{document}

答案1

问题在于,在 的定义中不知何故出现了一个空格\sectionmark

\documentclass[11pt,oneside,article]{memoir}
\usepackage{lipsum}

% Begin Section format 
\newcommand{\marginbox}[1]{%
  \parbox[t][0pt]{10em}{%
  \upshape\sffamily\raggedright\mbox{}#1}%
}
\newcommand{\marginhead}[1]{%
  \bfseries\smash{\raisebox{\baselineskip}{\llap{\marginbox{#1}\kern3em}}}%
}

\setsecindent{0em}
\setsecheadstyle{\marginhead}
\setbeforesecskip{1em}
\setaftersecskip{0em}
\setsechook{%
  \setsecnumformat{\csname   the##1\endcsname\enspace\par\nobreak}%
}
% End Section format

\copypagestyle{myheader}{ruled}
\makeevenhead{myheader}{}{}{My-Name}
\makeoddhead{myheader}{}{}{Other-Name}
\pagestyle{myheader}

%%% Fix \sectionmark
\makeatletter
\renewcommand\sectionmark[1]{%
  \@setclcnt{section}{@memmarkcntra}%<------ Missing!
  \advance\c@@memmarkcntra\m@ne
  \markright{%
    \memUChead{%
      \ifnum\c@secnumdepth>\c@@memmarkcntra 
        \if@mainmatter
          \@nameuse{sectionmarksn}{\@nameuse{thesection}. \space}%
        \fi
      \fi #1%
    }%
  }%
}
\makeatother

% Layout (should go before \begin{document})
\settrims{0pt}{0pt}
\settypeblocksize{562pt}{300pt}{*}
\setulmargins{114pt}{*}{*}
\setheadfoot{28pt}{24pt}
\setheaderspaces{*}{*}{*}
\setmarginnotes{1pt}{1pt}{1pt}
\setlrmargins{210pt}{*}{*}
\checkandfixthelayout

\begin{document}


\section{Introduction}
\lipsum[4] 

\end{document}

在此处输入图片描述

这是 中的一个错误memoir。第 1968 行(版本 2013/05/30 v3.7b)是

1968       \@setclcnt{#1}{@memmarkcntra}

但应该

1968       \@setclcnt{#1}{@memmarkcntra}%

相关内容