This is a follow-on to the question: Adding different kinds of entities to table of contents
As I build a huge document, things don't work as in the MWE from the previous problem. I stripped out the entire document and have just the commands and a couple of sample pages to demonstrate what I want, and what the problems are.
The table of contents crashes. The error message states there is an extra close brace } but I don't see it.
The labs are supposed to be separate, standalone units like appendices. But every page starts with a header "Chapter 1. Title ... " because the book style thinks that everything must be inside chapters. How do I suppress that header?
\documentclass[12pt]{book} % Book class in 12 points
\parindent0pt \parskip10pt % make block paragraphs
\raggedright % do not right justify
\usepackage{mathptmx} % times roman, including math (where possible)
\usepackage{mathpazo} % palatino, including math (where possible)
\usepackage{helvet} % helvetica
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[usenames,dvipsnames]{color}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{comment}
\usepackage{listings}
\usepackage{grffile}
\usepackage{listing}
\usepackage{changepage}
\usepackage{multirow}
\usepackage{outlines}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{subfigure}
\usepackage{hyperref}
\usepackage{textcomp}
\usepackage[top=1in, bottom=1.5in, left=1in, right=1in]{geometry}
%usepackage{fullpage} would fix the margins problem
\cfoot{\sffamily\textcopyright 2005-2014 copyright notice }
\rfoot{\thepage}
\graphicspath{ {C:/LaTeX/img/} }
\pagestyle{fancy}
\title{\bf Grandiose Title Here \\ %\includegraphics[scale=.5]{ Logo.jpg}\\
Organization Name Here} % Supply information
\author{Primary Author} % for the title page.
\date{\today} % Use current date.
\definecolor{lgray}{rgb}{0.9,0.9,0.9}
%\definecolor{graycolor}{rgb}{0.9,0.9,0.9}
\definecolor{white}{rgb}{1,1,1}
\definecolor{dkgreen}{rgb}{0,.5,0.1}
\definecolor{wrongcolor}{rgb}{.9,.5,.4}
\definecolor{purple}{rgb}{0.6,0,0.6}
%\input state.tex
\newcommand{\underscore}{ %UNDERLINE COMMAND
\underline{ \hspace{3 cm}}
}
\makeatletter
\newcounter{lab}% also defines \thelab
% roughly equivalent to \chapter
\newcommand{\lab}[1]{% #1 is lab heading
\refstepcounter{lab}%
\if@openright\cleardoublepage\else\clearpage\fi%
\addtocontents{toc}{\string\contentsline {chapter}%
{\hbox to .65in{Lab}\protect\numberline{\thelab}#1}{\thepage}}%
\global\@topnum\z@% page number to bottom?
\noindent%
\@lab{#1}% fixed first character separation
}
% roughly equivalent to \@chapter
\def\@lab#1{% #1 is lab heading
\if@twocolumn%
\@topnewpage[{\huge\bfseries Lab \thelab: #1\par}]%
\else{\huge\bfseries Lab \thelab: #1\par}%
\@afterheading% no idea
\fi}
% copied from mwe
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
% copied from book.cls and modified
\def\@chapter[#1]#2{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addtocontents{toc}{\string\contentsline {chapter}%
{\hbox to .65in{Chapter}\protect\numberline{\thechapter}#1}{\thepage}}%
\else
\addtocontents{toc}{\string\contentsline {chapter}%
{\hbox to .65in{Chapter}\protect\numberline{\thechapter}#1}{\thepage}}%
\fi
\else
\addtocontents{toc}{\string\contentsline {chapter}%
{\hbox to .65in{Chapter}\protect\numberline{\thechapter}#1}{\thepage}}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\makeatother
% Note that book class by default is formatted to be printed back-to-back.
\begin{document} % End of preamble, start of text.
\setenumerate[1]{label=\arabic*.}
\setenumerate[2]{label=\Alph*.}
\setenumerate[3]{label=\roman*.}
\setenumerate[4]{label=\alph*.}
\frontmatter % only in book class (roman page #s)
\maketitle % Print title page.
\pagebreak
{\Large Acknowledgements }
Acknowledgements ... Thanks Stack Overflow experts!
{\Large Authors}
Main author \\
author2 \\
author3
{\Large Editors} \\
editor-in-chief
{\Large Layout and LaTeX Programming} \\
interns who laid out the document
{\Large Contributors} \\
contributor 1 \\
contributor 2
{\Large Example Programs in Java} \\
Code contributors
{\Large Example Programs in C++}
{\Large Online Quiz Development and Testing}
{\Large Lab Photos and Testing}
\pagebreak
\tableofcontents % Print table of contents
\mainmatter % only in book class (arabic page #s)
\chapter{How to Use this Document} % Print a "chapter" heading
This is where we describe how it all works
Now, here come the individual short self-paced lessons,
called labs for now for want of a better term.
\lab{ Let There be Light}
To embed a live link ...
%\url{http://www.AdAstraEducation.org}
\lab{C++ Code and BadCode Styles}
Write some code, yadayada
\end{document}
hyperrefand the re-deifinition of what's in the .toc file: if uou don't load hyperref, it compiles fine. – Bernard Jul 20 '14 at 16:47\chaptercommand as well? – Jul 20 '14 at 17:47