2

I'm using EveryShipout to redisplay section headings on subsequent pages, using an approach based off the answer to this question. I've modified it slightly to work better with Memoir. It works pretty well:

\makepagestyle{headings} {} % Disable default Memoir repeated headings, we'll make our own

\EveryShipout{%
  \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \f@rhdr% Reprint/-insert sectional heading
  \fi%
}

Repeating page headings

Next what I want to change is to have it so that it's the same size as the main headings. (I plan on making it grey later)

I tried both

\makepagestyle{headings} {} % Disable default Memoir repeated headings, we'll make our own

\EveryShipout{%
  \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \chaptitlefont\f@rhdr% Reprint/-insert sectional heading
  \fi%
}

and

\makepagestyle{headings} {} % Disable default Memoir repeated headings, we'll make our own

\EveryShipout{%
  \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \Huge\f@rhdr% Reprint/-insert sectional heading
  \fi%
}

and even

\makepagestyle{headings} {} % Disable default Memoir repeated headings, we'll make our own

\EveryShipout{%
  \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \printchaptertitle{\f@rhdr}% Reprint/-insert sectional heading
  \fi%
}

but both of them gave the same result:

Weird number appears

Why isn't the font bigger, and where did this weird number (20.7425) come from?

EDIT: Complete example:

\documentclass[twoside]{memoir}
\usepackage[papersize={8.5in,11in}, vmargin=0.5in, outer=1in, inner=0.5in, includehead, includefoot]{geometry}
%\usepackage{color}
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{newunicodechar}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{everyshi}% http://ctan.org/pkg/everyshi
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage[none]{hyphenat}

\setmainfont{OpenSans}

\makeatletter

% Repeating headings (based on https://tex.stackexchange.com/questions/47646/re-displaying-section-headings-after-page-breaks)

\makepagestyle{headings} {} % Disable default Memoir repeated headings, we'll make our own

\EveryShipout{%
  \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \printchaptertitle{\f@rhdr}% Reprint/-insert sectional heading
  \fi%
}

\makeatother

\raggedright

\setlength{\parindent}{0pt}%
\nonzeroparskip

\begin{document}
\chapter{My chapter heading}
\section{Section 1}\lipsum[7-14]
\section{Section 2}\lipsum[1-6]
\end{document}
  • Show a complete example, this will make it much easier to test your issue. – Ulrike Fischer Oct 8 '16 at 10:23
  • @UlrikeFischer Added – Joshua Walsh Oct 8 '16 at 11:04
2

During an output routine, \protect is set to \noexpand, so commands such as \normalfont and \fontsize do nothing, because they expand to

\protect\normalfont<space>
\protect\fontsize<space>

(the space is part of the macro name), and \noexpand makes them behave as \relax.

Temporarily switch \protect to the meaning it has during normal typesetting:

\EveryShipout{%
  \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \begingroup\let\protect\@typeset@protect
      \printchaptertitle{\f@rhdr}% Reprint/-insert sectional heading
    \endgroup
  \fi
}

enter image description here

Where does 20.7425 come from? Let's see: \printchaptertitle{foo} does \chaptertitlefont foo; \chaptertitlefont expands to \normalfont\Huge\bfseries; \normalfont does nothing as explained before. Now \Huge becomes \@setfontsize\Huge\@xxpt{25} and, to keep it short, \@setfontsize calls \fontsize{\@xxpt}{25}. Since \fontsize eventually becomes \relax, the two values are printed and no font change happens (for \bfseries the discussion is similar).

  • There's so much to learn about LaTeX. Thanks for your explanation, I understood most of it and it's given me some things to research so that I will be able to understand all of it. – Joshua Walsh Oct 8 '16 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.