1

I am using the amsbook document class. I would like it to print the section number at the top of each page. How does one go about doing that? And, what options do I have for displaying it?

EDIT: Here is my preamble. I have typed about six sections, but there is nothing out of the ordinary about them.

\documentclass[12pt]{amsbook}

\usepackage{etex}

\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{epsfig}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot}
\usepackage{tikz}


\usepackage{amsmath,amsthm,amsfonts,amssymb,bm,tikz,pgfplots,subfig,float,sidecap,enumitem,varioref,thmtools}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{multicol}
\usepackage[nice]{nicefrac}
\usepackage{imakeidx}

\usepackage[hypertexnames=true]{hyperref}
\hypersetup{colorlinks,linkcolor=blue}

\pagestyle{plain}

\makeindex[name=index, title=Index of Terms, columns=2]
\makeindex[name=notation, title=Index of Notations, columns=2]

\onehalfspacing %also singlespacing and doublespacing
\setlength{\parindent}{18pt}
\setlength{\intextsep}{1cm}% plus 1pt minus 2pt}
\setlength{\textfloatsep}{1cm}% plus 1pt minus 2pt}
\setlength{\floatsep}{1cm}% plus 1pt minus 2pt}

\usepackage{enumitem}


\setcounter{secnumdepth}{2}
\numberwithin{section}{chapter}


\title{Book Title}
\author{Me}


\begin{document}


\maketitle
\pagebreak

\setcounter{secnumdepth}{-1}
\setcounter{page}{1}
\pagenumbering{roman}

\setcounter{tocdepth}{4}
\makeatletter
\def\l@subsection{\@tocline{2}{0pt}{2.5pc}{5pc}{}}
\makeatother


\tableofcontents
\pagebreak


\setcounter{secnumdepth}{2}
\pagenumbering{arabic}
\setcounter{page}{1}

\section{Book Begins}
A 
\newpage
B
\newpage
C

\end{document}
J126
  • 993
  • 1
    can you be a bit more specific, please. it would be helpful if you could emulate what you want in the running heads. the default for amsbook is the chapter number and title on the left, and the section number and title on the right. do you mean that you simply want the section information on both the left and the right, or do you want something entirely different? – barbara beeton Sep 19 '16 at 00:33
  • @barbarabeeton I want what you said is the default. But, it is not doing it. – J126 Sep 19 '16 at 20:22
  • can you please provide a small compilable example that shows what's going wrong. by default there will be no running head on the first page of a chapter. but succeeding pages should have running heads as i've described; all the multi-page tests i've performed do behave that way, so i need to see an example that doesn't. – barbara beeton Sep 19 '16 at 21:02
  • @barbarabeeton I have added the preamble along with some blank pages. – J126 Sep 20 '16 at 20:30
  • 1
    thanks for the updated example. you have suppressed the running heads by specifying \pagestyle{plain}. by definition, that page style marks pages only with a page number at the bottom. if you remove it, you will get running heads, but since you don't have any \chapters, the left-hand running head is never reset, so it will say "contents". if instead you want a section heading there, let me know, and i'll write out how to do it in an answer. (as it is, this is hardly worth a real answer.) – barbara beeton Sep 20 '16 at 20:46
  • Don't use epsfig. Don't load packages twice. – cfr Sep 20 '16 at 23:33
  • @barbarabeeton I have chapters in what I am typing. But, if you could write up an answer for how to get it to display the section on each page instead of alternating chapter and section, I'd appreciate it. – J126 Sep 21 '16 at 02:11

1 Answers1

1

here's an adaptation of your file that will set the running head to the section name on all pages after the first section appears. i've left the running head as the chapter title to take care of the case where there is no section in a chapter, or the first section doesn't appear until after the second page.

\documentclass[12pt]{amsbook}

\usepackage{xpatch}
\usepackage{etex}

\usepackage{amssymb,bm}

\usepackage[hypertexnames=true]{hyperref}
\hypersetup{colorlinks,linkcolor=blue}

\numberwithin{section}{chapter}
\setcounter{secnumdepth}{2}

\makeatletter
\patchcmd\ps@headings
  {\def\sectionmark{\@secmark\markright\sectionrunhead\sectionname}}%
  {\def\sectionmark{\@secmark\markboth\sectionrunhead\sectionname}}%
  {}{}
\pagestyle{headings}%
\makeatother

\title{Book Title}
\author{Me}

\begin{document}

\maketitle
\pagebreak

\setcounter{secnumdepth}{-1}
\setcounter{page}{1}
\pagenumbering{roman}

\setcounter{tocdepth}{4}
\makeatletter
\def\l@subsection{\@tocline{2}{0pt}{2.5pc}{5pc}{}}
\makeatother

\tableofcontents
\pagebreak

\setcounter{secnumdepth}{2}
\pagenumbering{arabic}
\setcounter{page}{1}

\chapter{Chapter title}
xx
\newpage
xx
\newpage
\section{Book Begins}
A 
\newpage
B
\newpage
C

\end{document}

the definitions for what appears in a running head are within the definition of \ps@headings.

the only change needed is for the section, so a patch is applied (using the xpatch package mechanism) rather than copying and replacing the whole (long!) definition. after that is done, it's necessary to reset the \pagestyle to use the new headings definition. that's usually done within code that first checks for the presence of a .cfg file, but since you want the change to be obligatory, and there are other side effects associated with that block of code, only the \pagestyle change is invoked.