Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to implement a macro that begins a chapter. I don't want to use latex or fancyhdr but only plain tex (for pedagogical reasons). The code is the following

\headline={\hfil{\tenrm\folio}\hfil}
\nopagenumbers
% Counters and macros for handling chapters
\newcount\fChapterNumber
\global\fChapterNumber=0
\def\fBeginChapter#1{
  % Initialization
  \advance\fChapterNumber by 1
  % Formatting
  \vfill\eject
  \hrule height0.7mm
  \vskip 5mm
  \centerline{\tenrm \noindent Chapter \the\fChapterNumber}
  \vskip 18mm
  {\tenbf \noindent #1}
  \vskip 35mm
}

% DOCUMENT %
\fBeginChapter{Analisis I}
blah, blah, blah, blah,...
\vfill\eject
blah, blah, blah, blah,...
\bye

As you can see the header will be printed in both pages, but I want it not to be printed in the first page of the chapter. I've been thinking and looking in the web unsuccessfully. What is the best way to do this?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Use a conditional:

% Counters and macros for handling chapters
\newif\iffChapter
\newcount\fChapterNumber
\fChapterNumber=0
\def\fBeginChapter#1{
  % Initialization
  \global\advance\fChapterNumber by 1
  % Formatting
  \vfill\eject
  \global\fChaptertrue
  \hrule height0.7mm
  \vskip 5mm
  \centerline{\tenrm \noindent Chapter \the\fChapterNumber}
  \vskip 18mm
  {\tenbf \noindent #1}
  \vskip 35mm
}

\headline={\iffChapter\global\fChapterfalse\else\hfil{\tenrm\folio}\hfil\fi}
\nopagenumbers


% DOCUMENT %
\fBeginChapter{Analisis I}
blah, blah, blah, blah,...
\vfill\eject
blah, blah, blah, blah,...
\bye

The begin chapter command sets the conditional to true; when this is the case, the code in the header just switches the conditional to false, otherwise it prints the page number.

Notice that your \global\fChapterNumber=0 is useless, while a \global should be in front of \advance\fChapterNumber.

If you want to set the page number at the bottom in the chapter starting pages, you can use the same idea:

\headline={\iffChapter\else\hfil{\tenrm\folio}\hfil\fi}
\footline={\iffChapter\hfil{\tenrm\folio}\hfil\global\fChapterfalse\fi}

and no \nopagenumbers; setting \iffChapter to false must be done by the footline code, as it is executed after the one in the headline.

share|improve this answer
    
Thank you @egreg, that is a very nice solution. –  Felipe Apr 26 '12 at 15:29

A simplistic way is to check for odd numbers.

\headline={\hfil{\tenrm\folio}\hfil}
\nopagenumbers
% Counters and macros for handling chapters
\newcount\fChapterNumber
\global\fChapterNumber=0
\def\fBeginChapter#1{
  % Initialization
  \advance\fChapterNumber by 1
  % Formatting
  \ifodd\the\fChapterNumber\vfill\eject
  \hrule height0.7mm
  \vskip 5mm
  \centerline{\tenrm \noindent Chapter \the\fChapterNumber}
  \vskip 18mm
  {\tenbf \noindent #1}
  \vskip 35mm
 \fi
}

% DOCUMENT %
\fBeginChapter{Analisis I}
blah, blah, blah, blah,...
\vfill\eject
blah, blah, blah, blah,...
\bye

However, to be correct you need to call your routines through the output routine.

share|improve this answer
    
I'm afraid this doesn't answer the question. However, a \null before \vfill\eject is needed. –  egreg Apr 26 '12 at 9:02
    
@egreg It is always best to add headers and footers in the OR i.e, \output={ \shipout\box255 \advancepageno \global\output={ \shipout\vbox{ \box255 \bigskip \centerline{\folio}} \advancepageno} } –  Yiannis Lazarides Apr 26 '12 at 9:50
    
The standard OR uses \headline and \footline for that purpose. The question was about suppressing the header in the chapter starting page. –  egreg Apr 26 '12 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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