Should this combination of counters and \ifnum conditions work or does it need modification? Is there a better way?

I'm producing the final product of my thesis with LaTeX. I'm having trouble with the front matter of my thesis, specifically with getting LaTeX to recognize that if the front matter stops at a certain number of pages, then it is to execute the command \beginthesis.

I've tried to produce counters so that if a certain combination of counters produced a certain number, and it was greater than X, it would produce a new front matter page via \newpage, but if less than X, it would execute \beginthesis.

So, in simplified form, the whole process looks something like this, with abstract being the absolute last page that can be present:

\newcounter{frontmattercounter}
\newcounter{frontmattercheck}
\newcounter{frontmatterabstract}
\newcounter{frontmatterepigraph}

\newcommand{frontmattercheck}{%
}

\frontmattercheck
\setcounter{frontmattercounter}{\value{frontmattercheck}}

\newcommand{epigraph}
\setcounter{frontmatterepigraph}{1}
.
.
.
\ifnum\value{frontmattercounter} > 1
\@restonecolfalse\newpage
\else
\beginthesis\fi

\newcommand{abstract}
\setcounter{frontmatterabstract}{10}
.
.
.
\beginthesis


I have about 6 or 7 pages that I have set up this way, but for some reason, it seems that LaTeX is not recognizing the values properly. Is there a better way to do this, or is there a way I can modify my process to get the intended result? Thanks in advance.

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Martin Scharrer Oct 29 '11 at 18:12
It's not clear what you're going to achieve. Isn't issuing \beginthesis sufficient? –  egreg Oct 29 '11 at 20:51
Martin, thanks and thanks for for the tip! I'll file that away for future use. –  JohnDave Medina Oct 30 '11 at 1:13
egreg, the \beginthesis command does something different with page formatting and number so it can't be used in the front matter. What I'm looking to do is find a way to have LaTeX understand that if there isn't an abstract page, for instance, it will \beginthesis, but if there is an abstract page, then it will do a \newpage. –  JohnDave Medina Oct 30 '11 at 1:15
Where can we find the class you're using? A tip: if you precede the nickname of somebody with @ at the start of a comment, they will be notified. –  egreg Oct 30 '11 at 14:11

I'm going to take a somewhat blind shot at "is there a better way?" My university's thesis style requires some pages in the front matter, while other pages are optional. Pages in the front matter get one type of headers and footers, while pages in the main matter and back matter get another style. The following is the basic structure I use, where students are expected to provide their own abstract and other front matter content, and to comment out the pages they don't use:

\documentclass[oneside]{book}
\usepackage[english]{babel} \usepackage{blindtext} % For filler text
%%% Things that should go in a .sty file the student doesn't normally touch

% Use \somethingpage commands to define the layout of a frontmatter page,
% and include the content of the student's \thesissomething command.
\newcommand{\epigraphpage}{\cleardoublepage \thesisepigraph \cleardoublepage}
\newcommand{\abstractpage}{\cleardoublepage \thesisabstract \cleardoublepage}
% Provide default \thesissomething commands to prompt the student in case
% they forgot to enter their own content.
\newcommand{\thesisepigraph}{%
This is the default epigraph. You need to change it by editing the
thesisepigraph command in your own thesis.tex file
}
\newcommand{\thesisabstract}{%
This is the default abstract. You need to change it by editing the
thesisabstract command in your own thesis.tex file
}
%%%

%%% Things that should go in each student's .tex file
\renewcommand{\thesisepigraph}{%
This is my epigraph.
}

\renewcommand{\thesisabstract}{%
This is my abstract.
}
%%%

\begin{document}
\frontmatter \pagestyle{plain}

\tableofcontents
\listoffigures
\epigraphpage % Comment this out if there's no epigraph to include
\abstractpage % Don't comment this out, abstract is required

\mainmatter \beginthesis

\chapter{One}
\section{First}
\blindmathpaper
\begin{figure}
\centering
\fbox{Figure content goes here}
\caption{Some caption goes here}
\end{figure}

\backmatter

\chapter{Something Else}
Here goes the back matter.

\end{document}


There are some more sophisticated techniques available (e.g., patching the \mainmatter command to execute \beginthesis automatically), but maybe this is a starting point to figure out what's really required.

-
Mike, thanks for this approach. Let me mull over it for a day or two. –  JohnDave Medina Oct 31 '11 at 6:29
I ultimately took this path with some modification and it worked. Thanks very much! –  JohnDave Medina Jan 15 '12 at 22:11
When you get a chance, you can accept my answer and close out the question. –  Mike Renfro Jan 15 '12 at 22:35
Done. Thanks once again. –  JohnDave Medina Jan 16 '12 at 1:24