svmono.cls:如何在标题下方添加行?

svmono.cls:如何在标题下方添加行?

如何使用类在普通页面(即非章节页面或目录等)的标题下添加一行svmono?下面是我想要实现的示例:我希望第 2 页和第 3 页的标题下方有一行,横跨整个页面宽度,如第二张图所示。可以找到 svmono.cls 的副本这里。定义标题的代码似乎如下,我如何在此代码中插入页面范围的规则?:

svmono.cls 代码片段(第 1917-1927 行):

\def\ps@headings{\let\@mkboth\markboth
   \let\@oddfoot\@empty\let\@evenfoot\@empty
   \def\@evenhead{\runheadsize\runheadstyle\rlap{\thepage}\hfil
                  \leftmark}
   \def\@oddhead{\runheadsize\runheadstyle\rightmark\hfil
                  \llap{\thepage}}
   \def\chaptermark##1{\markboth{{\if@chapnum
      \thechapter\thechapterend\hskip\betweenumberspace\fi ##1}}{{\if@chapnum
      \thechapter\thechapterend\hskip\betweenumberspace\fi ##1}}}
   \def\sectionmark##1{\markright{{\ifnum\c@secnumdepth>\z@
      \thesection\seccounterend\hskip\betweenumberspace\fi ##1}}}}

笔记:

1)可以进行修改svmono.cls(这不打算发送给出版商)

2)我尝试使用fancyhdr,但它完全弄乱了标题的样式。

例子:

\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm]{geometry}
\usepackage{mathptmx}
\usepackage{lipsum}
\begin{document}
\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]
\end{document}

实际输出(不期望的):

在此处输入图片描述

期望输出:

在此处输入图片描述

更新的示例(titleps几乎解决了它,但是参考书目中断了!):

\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm]{geometry}
\usepackage{mathptmx}
\usepackage{lipsum}


\usepackage{titleps}
\newpagestyle{withheadrule}{%
 \headrule
\sethead[\footnotesize\thepage][][\footnotesize\thechapter~\chaptertitle]{\footnotesize\thesection~\sectiontitle}{}{\footnotesize\thepage}
\setfoot{}{}{}
}
\pagestyle{withheadrule}


\begin{document}
\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]
\cite{dummy1,dummy2,dummy3,dummy4}

\backmatter
\bibliographystyle{plain}
\bibliography{./sample}

\end{document}

sample.bib的内容:

@misc{dummy1,author="Dummy 1",title={\lipsum[1-4]}}
@misc{dummy2,author="Dummy 2",title={\lipsum[1-4]}}
@misc{dummy3,author="Dummy 3",title={\lipsum[1-4]}}
@misc{dummy4,author="Dummy 4",title={\lipsum[1-4]}}

更新的示例输出(最后几页;请注意在页眉和页脚中添加的虚假“参考”文本):

在此处输入图片描述

使用 fancyhdr 的解决方案:如何仅在文档的一部分上定义它?

\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm,heightrounded]{geometry}
\usepackage{newtxtext,newtxmath} % <--- not mathptmx
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{\runheadsize\runheadstyle\leftmark}
\fancyhead[LO]{\runheadsize\runheadstyle\rightmark}
\fancyhead[LE,RO]{\runheadsize\runheadstyle\thepage}
\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
  \fancyfoot[RE,LO]{\runheadsize\runheadstyle\thepage}%
}
\makeatletter
\renewcommand\chaptermark[1]{%
  \markboth{%
    \if@chapnum\thechapter\thechapterend\hskip\betweenumberspace\fi #1%
  }{%
    \if@chapnum\thechapter\thechapterend\hskip\betweenumberspace\fi #1%
  }%
}
\renewcommand{\sectionmark}[1]{%
  \markright{%
    \ifnum\c@secnumdepth>\z@ \thesection\seccounterend\hskip\betweenumberspace\fi #1%
  }%
}
\makeatother

% How to define a "normal" page style? or invoke the default style (i.e. non-fancy)?
\fancypagestyle{test}{%
}

\usepackage{lipsum}

\begin{document}
\pagestyle{test}
\tableofcontents

\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]
\cite{dummy1,dummy2,dummy3,dummy4}

\pagestyle{test}

\backmatter
\bibliographystyle{plain}
\bibliography{./sample}

\end{document}

在此处输入图片描述

答案1

您可以使用,但也可以应用和fancyhdr的定义。\chaptermark\sectionmark

\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[
  paperheight=220mm,
  paperwidth=140mm,
  top=1.5cm,
  bottom=1.5cm,
  inner=1cm,
  outer=1cm,
  heightrounded, % <--- don't forget
]{geometry}
\usepackage{newtxtext,newtxmath} % <--- not mathptmx
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{\runheadsize\runheadstyle\leftmark}
\fancyhead[LO]{\runheadsize\runheadstyle\rightmark}
\fancyhead[LE,RO]{\runheadsize\runheadstyle\thepage}
\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
  \fancyfoot[RE,LO]{\runheadsize\runheadstyle\thepage}%
}
\makeatletter
\renewcommand\chaptermark[1]{%
  \markboth{%
    \if@chapnum\thechapter\thechapterend\hskip\betweenumberspace\fi #1%
  }{%
    \if@chapnum\thechapter\thechapterend\hskip\betweenumberspace\fi #1%
  }%
}
\renewcommand{\sectionmark}[1]{%
  \markright{%
    \ifnum\c@secnumdepth>\z@ \thesection\seccounterend\hskip\betweenumberspace\fi #1%
  }%
}
\makeatother

\usepackage{lipsum}

\begin{document}

\tableofcontents

\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]

\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}

\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}
\chapter{A}\section{AA}\section{AB}\section{AC}

\end{document}

我添加了大量虚假章节以填充目录并查看其中的标题是否正确。

在此处输入图片描述

在此处输入图片描述

不要使用mathptmx,这是 20 年前可以做到的事情的黑客攻击。如果你想要 Times 文本和数学,组合newtxtextnewtxmath远的更好的。

答案2

看起来titleps,的同伴包titlesec可以与类和平共处svmono

\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm]{geometry}
\usepackage{mathptmx}
\usepackage{lipsum}
\usepackage{titleps}
\newpagestyle{withheadrule}{%
 \headrule
\sethead[\footnotesize\thepage][][\footnotesize\thechapter~\chaptertitle]{\footnotesize\thesection~\sectiontitle}{}{\footnotesize\thepage}
\setfoot{}{}{}
}
\pagestyle{withheadrule}

\begin{document}

\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]

\end{document} 

在此处输入图片描述 在此处输入图片描述

相关内容