% examdoc.tex \documentstyle[12pt]{exam} %-------------------------------------------------------------------- %--------------------------------------------------------------------- \newenvironment{example}% {\bigskip\filbreak \subsubsection{Example:} }% {} \def\samplehead#1#2#3#4{% \begin{trivlist} \item[] \leavevmode \hbox to \textwidth{% \rlap{\parbox[b]{\textwidth}{\raggedright#1\strut}}% \hfil\parbox[b]{\textwidth}{\centering#2\strut}\hfil \llap{\parbox[b]{\textwidth}{\raggedleft#3\strut}}% }% hbox #4 \end{trivlist} } \def\samplefoot#1#2#3#4{% \begin{trivlist} \item[] \leavevmode #1 \vskip 3pt \hbox to \textwidth{% \rlap{\parbox[t]{\textwidth}{\raggedright#2}}% \hfil\parbox[t]{\textwidth}{\centering#3}\hfil \llap{\parbox[t]{\textwidth}{\raggedleft#4}}% }% hbox \end{trivlist} } \makeatletter \@ifundefined{AmS}{\def\AmS{{\protect\the\textfont\tw@ A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}} {} \makeatother %--------------------------------------------------------------------- %--------------------------------------------------------------------- %--------------------------------------------------------------------- %--------------------------------------------------------------------- \begin{document} \title{Using the exam document style} \author{Philip Hirschhorn\\ Department of Mathematics\\ Wellesley College\\ Wellesley, MA 02181\\ phirschhorn@wellesley.edu} \date{December 12, 1994} \maketitle \tableofcontents \section{Introduction} The file \verb"exam.sty" provides a document style that attempts to make it easier to prepare exams. Most of what's here can also be accomplished by using \verb"fancyheadings.sty", adjusting \LaTeX's page layout parameters (perhaps by using \verb"fullpage.sty") and making careful use of the \verb"list" environment, but \verb"exam.sty" tries to make all this as simple as possible. Specifically, \verb"exam.sty" sets the page layout so that there are one inch margins all around and provides commands that make it easy to format questions and create very flexible headers and footers. In particular: % \begin{itemize} \item The style will automatically format and number the questions, parts of questions, and subparts of questions, while making it easy to refer to specific questions by number in any special directions you need to print on the exam. \item You can include the point value of each question (or part, or subpart), with your choice of having the point values either at the beginning of the text of the question or in the left margin. \item You can specify the header in three parts: The left head, the center head, and the right head. The left head is left justified, the center head is centered, and the right head is right justified, and one or all of these can be omitted. \item The footer is also specified in three parts: Left justified, centered, and right justified. \item The header and footer for the first page can be different from the ones used on other pages. \item Both headers and footers can contain more than one line. To accommodate headers and footers with many lines, simple commands are provided to increase the parts of the page devoted to the header and/or the footer, and these commands can give one amount of space on the first page and a different amount of space on all other pages. \item You can have a horizontal rule at the base of the header and/or at the top of the footer. \item Macros are defined to allow you to state the total number of pages in the exam and to change the header and/or footer that appears on the {\em last\/} page of the exam. \end{itemize} %--------------------------------------------------------------------- \section{The documentstyle command} To use the \verb"exam" document style, you should specify \verb"exam" as your main document style. For example, if you want to use 12~point type, then your \verb"documentstyle" command should be % \begin{center} \verb"\documentstyle[12pt]{exam}" \end{center} % If you would also like to use some of the features of \AmS-\LaTeX, then you should use the command % \begin{center} \verb"\documentstyle[12pt,amstex]{exam}" \end{center} %--------------------------------------------------------------------- \section{Questions} To type the questions in the exam, you use the \verb"questions" environment. Each question is then begun with the command \verb"\question", and the questions will be numbered automatically. For example, if you type % \begin{verbatim} \begin{questions} \question Why is there air? \question How much wood would a woodchuck chuck if a woodchuck could chuck wood? \question Compute $\displaystyle\int_0^1 x^2 \, dx$. \end{questions} \end{verbatim} % then you'll get % \begin{questions} \question Why is there air? \question How much wood would a woodchuck chuck if a woodchuck could chuck wood? \question Compute $\displaystyle\int_0^1 x^2 \, dx$. \end{questions} \bigskip As the above example illustrates, you can leave blank lines between the \verb"\question" command and the actual beginning of the question, or before the first \verb"\question" command in the environment, and they will be ignored. %--------------------------------------------------------------------- \subsection{Questions with parts and subparts} If you want a question to have several parts, then you use the \verb"parts" environment. For example, if you type % \begin{verbatim} \begin{questions} \question Why is there air? \question What if there were no air? \begin{parts} \part Describe the effect on the balloon industry. \part Describe the effect on the aircraft industry. \end{parts} \question \begin{parts} \part Define the universe. Give three examples. \part If the universe were to end, how would you know? \end{parts} \end{questions} \end{verbatim} % then you'll get \begin{questions} \question Why is there air? \question What if there were no air? \begin{parts} \part Describe the effect on the balloon industry. \part Describe the effect on the aircraft industry. \end{parts} \question \begin{parts} \part Define the universe. Give three examples. \part If the universe were to end, how would you know? \end{parts} \end{questions} \bigskip The above example illustrates several things: % \begin{itemize} \item Parts of a question should be put into a \verb"parts" environment. \item If a question begins with a \verb"parts" environment, then the first part will appear on the same line with the question number. \item You can leave blank lines before and after the \verb"\part" command, and they will be ignored. \end{itemize} \bigskip There is also a \verb"subparts" environment, and it works just as you would expect. For example, if you type % \begin{verbatim} \begin{questions} \question This is the first question. \question This is the second question. \begin{parts} \part This is the first part. \part This is the second part. \begin{subparts} \subpart This is the first subpart. \subpart This is the second subpart. \subpart This is the third subpart. \end{subparts} \part This is the third part. \end{parts} \question \begin{parts} \part \begin{subparts} \subpart This is a subpart. \subpart This is another subpart. \end{subparts} \part This is another part. \end{parts} \end{questions} \end{verbatim} % then you'll get \begin{questions} \question This is the first question. \question This is the second question. \begin{parts} \part This is the first part. \part This is the second part. \begin{subparts} \subpart This is the first subpart. \subpart This is the second subpart. \subpart This is the third subpart. \end{subparts} \part This is the third part. \end{parts} \question \begin{parts} \part \begin{subparts} \subpart This is a subpart. \subpart This is another subpart. \end{subparts} \part This is another part. \end{parts} \end{questions} %--------------------------------------------------------------------- \subsection{Point values for the questions} \label{sec:points} Each of the commands \verb"\question", \verb"\part" and \verb"\subpart" take an optional argument, which is the number of points for that question, part, or subpart. The default is that the point value will be inserted at the beginning of the question (or part, or subpart) in parentheses, but if you give the command \verb"\pointsinmargin", then the point values will be set in the left margin. For example, if you type % \begin{verbatim} \begin{questions} \question[20] Why is there air? \question What if there were no air? \begin{parts} \part[10] Describe the effect on the balloon industry. \part[10] Describe the effect on the aircraft industry. \end{parts} \end{questions} \end{verbatim} % then, with the default setup, you'll get \nopointsinmargin \begin{questions} \question[20] Why is there air? \question What if there were no air? \begin{parts} \part[10] Describe the effect on the balloon industry. \part[10] Describe the effect on the aircraft industry. \end{parts} \end{questions} \bigskip If you give the command \verb"\pointsinmargin", then the above input will produce instead \pointsinmargin \begin{questions} \question[20] Why is there air? \question What if there were no air? \begin{parts} \part[10] Describe the effect on the balloon industry. \part[10] Describe the effect on the aircraft industry. \end{parts} \end{questions} If you want to switch back and forth between the two formats during the exam, you can do so by giving the commands \verb"\pointsinmargin" and \verb"\nopointsinmargin" whenever you want to switch. %--------------------------------------------------------------------- \subsubsection*{Using a substitute for the word ``points''} If you want the point value to be inserted at the beginning of the text of the question (i.e., using the default, \verb"\nopointsinmargin"), but you want to label it with some word other than ``points'', then you can change the word inserted by using the \verb"\pointname" command. If you give the command % \begin{center} \verb"\pointname{text}" \end{center} % then ``text'' will be inserted inside the parentheses immediately after the point value. For example, if you give the command % \begin{center} \verb"\pointname{\%}" \end{center} % and then type % \begin{verbatim} \question[25] Where, oh where, has my little dog gone? \end{verbatim} % then you'll get \pointname{\%} \nopointsinmargin % \begin{questions} \question[25] Where, oh where, has my little dog gone? \end{questions} % Using the default is equivalent to the command % \begin{center} \verb"\pointname{ points}" \end{center} % \pointname{ points} (Note that the space following the point value must be explicitly included.) %--------------------------------------------------------------------- \subsubsection*{Questions that begin with a parts environment} One thing to keep in mind is that {\em only one point value can appear on a line, and it will be the last one to be placed there}. This matters only if a question begins with a parts environment, or if a part begins with a subparts environment. In either of these cases, the question number and part number (or the part number and subpart number) will appear on the same line, and if both of these commands include an optional point value, {\em only the last one given will be used}. For example, if you type % \begin{verbatim} \begin{questions} \question[10] \begin{parts} \part[5] This is the first part. \part[5] This is the second part. \end{parts} \end{questions} \end{verbatim} % then you'll get % \begin{questions} \question[10] \begin{parts} \part[5] This is the first part. \part[5] This is the second part. \end{parts} \end{questions} % Notice that the 10~points for the entire question are never mentioned anywhere, since they would have appeared on the same line with the 5~points for the first part, and the 5~points for the part were placed later. This is true whether \verb"\pointsinmargin" or \verb"\nopointsinmargin" is in effect. %--------------------------------------------------------------------- \subsection{Including special instructions for a group of questions} \label{sec:uplevel} There are two commands provided for including special instructions for specific questions: \verb"\uplevel" and \verb"\fullwidth". These commands allow you to give instructions that will be set with the left indentation appropriate for the scope of the instructions. For example, if you are inside of a parts environment, and you want to give directions for the next few parts, then those directions should be indented to the level of the question of which they are parts, i.e., up one level. If you type % \begin{verbatim} \begin{questions} \question This is the first question. \question \begin{parts} \part This is the first part. \uplevel{The following two parts should be answered in classical Greek:} \part This is the second part. \part This is the third part. \end{parts} \end{questions} \end{verbatim} % then you'll get \begin{questions} \question This is the first question. \question \begin{parts} \part This is the first part. \uplevel{The following two parts should be answered in classical Greek:} \part This is the second part. \part This is the third part. \end{parts} \end{questions} \bigskip If you want to give instructions for a group of questions, then the indenting for those instructions should be to the outer left margin, i.e., up one level. For example, if you type % \begin{verbatim} \begin{questions} \question Approximate $\displaystyle \int_0^1 \sin x^2 \, dx$ within $.001$ of its true value. \uplevel{Questions \ref{exact-start} through~\ref{exact-end} should be evaluated completely, not just approximated.} \question \label{exact-start} $\displaystyle \int_0^1 \frac{x^2 \, dx}{\sqrt{1-x^2}}$ \question $\displaystyle \int_0^1 \frac{1}{1+x^2}\, dx$ \question \label{exact-end} $\displaystyle \int_0^{\frac{\pi}{2}} \sin^3 x \cos x \, dx$ \end{questions} \end{verbatim} % you'll get \begin{questions} \question Approximate $\displaystyle \int_0^1 \sin x^2 \, dx$ within $.001$ of its true value. \uplevel{Questions \ref{exact-start} through~\ref{exact-end} should be evaluated completely, not just approximated.} \question \label{exact-start} $\displaystyle \int_0^1 \frac{x^2 \, dx}{\sqrt{1-x^2}}$ \question $\displaystyle \int_0^1 \frac{1}{1+x^2}\, dx$ \question \label{exact-end} $\displaystyle \int_0^{\frac{\pi}{2}} \sin^3 x \cos x \, dx$ \end{questions} \bigskip If you want to give instructions that use the full width of the page (rather than just going up one level of indentation), then use the \verb"\fullwidth" command. For example, if you type % \begin{verbatim} \begin{questions} \question This is the first question. \question \begin{parts} \part This is the first part. \part This is the second part. \begin{subparts} \subpart This is a subpart. \fullwidth{When you finish this exam, you should go back and reexamine your work, both on the earlier part of this exam and in your life up until the day of this exam, for any errors that you may have made.} \subpart This is another subpart. \end{subparts} \end{parts} \end{questions} \end{verbatim} % then you'll get \begin{questions} \question This is the first question. \question \begin{parts} \part This is the first part. \part This is the second part. \begin{subparts} \subpart This is a subpart. \fullwidth{When you finish this exam, you should go back and reexamine your work, both on the earlier part of this exam and in your life up until the day of this exam, for any errors that you may have made.} \subpart This is another subpart. \end{subparts} \end{parts} \end{questions} %--------------------------------------------------------------------- \subsubsection*{Referring to specific questions by number} You can use the standard \LaTeX{} commands \verb"\label" and \verb"\ref" to refer to questions (or parts, or subparts) by number. For example, if you type % \begin{verbatim} The first question is question number~\ref{ques:first}, but it's question number~\ref{ques:second} that has both a good part (part~\ref{part:good}) and a bad part (part~\ref{part:bad}). \begin{questions} \question \label{ques:first} This is the first question. \question \label{ques:second} \begin{parts} \part \label{part:good} This is the good part. \part \lable{part:bad} This is the {\em bad\/} part. \end{parts} \question Is there a question? \end{questions} \end{verbatim} % then you'll get: \medskip The first question is question number~\ref{ques:first}, but it's question number~\ref{ques:second} that has both a good part (part~\ref{part:good}) and a bad part (part~\ref{part:bad}). \begin{questions} \question \label{ques:first} This is the first question. \question \label{ques:second} \begin{parts} \part \label{part:good} This is the good part. \part \label{part:bad} This is the {\em bad\/} part. \end{parts} \question Is there a question? \end{questions} \bigskip As with all other cross references in \LaTeX, you'll have to run your file through \LaTeX{} {\em twice\/} to be sure that all the cross references are correct. %--------------------------------------------------------------------- \subsection{Naming the parts of a long exam} There are two ways of naming the parts of a long exam. The first way uses the \verb"\uplevel" and \verb"\fullwidth" commands (see section~\ref{sec:uplevel}), and the other way uses the standard \verb"\part" and \verb"\section" commands. \subsubsection*{Using {\tt fullwidth} and {\tt uplevel}} To place a section name in the exam, just use a \verb"\fullwidth" command (see section~\ref{sec:uplevel}) and include whatever font changing commands that you want to use. For example, if you type % \begin{verbatim} \begin{questions} \question This is a question in the non-essay part of the exam. \fullwidth{\Large\bf Essay questions} \question Explain how the cooling of matter in the centuries following the big bang has influenced the British parliamentary system of government. \fullwidth{\Large\bf Laboratory questions} \question In the cabinet below your laboratory bench you will find a single edged razor blade, several C-clamps, and a bottle of whiskey. Remove your appendix. Do not suture until your work has been inspected. \end{questions} \end{verbatim} % then you'll get % \begin{questions} \question This is a question in the non-essay part of the exam. \fullwidth{\Large\bf Essay questions} \question Explain how the cooling of matter in the centuries following the big bang has influenced the British parliamentary system of government. \fullwidth{\Large\bf Laboratory questions} \question In the cabinet below your laboratory bench you will find a single edged razor blade, several C-clamps, and a bottle of whiskey. Remove your appendix. Do not suture until your work has been inspected. \end{questions} \subsubsection*{Using the standard sectioning commands} The exam document style is built upon the standard article document style, and so the sectioning commands used with the article document style can be used here as well. In particular, you can give the commands \verb"\part", \verb"\part*", \verb"\section", and \verb"\section*". The definitions made in \verb"exam.sty" ensure that if a \verb"\part" command appears {\em outside of a parts environment} it will be interpreted as a sectioning command, while if it appears {\em inside\/} of a parts environment, it will be interpreted as beginning a new part of a question. You can give these commands in the middle of a questions environment so as not to interrupt the numbering of the questions, or you can end a questions environment, give a sectioning command, and then start a new questions environment (which would reset the question counter to start again with number~1). If you give any of these commands while inside of a questions environment, then the section titles will be indented to the same extent that questions are indented, unless they are given as the argument of a \verb"\fullwidth" or \verb"\uplevel" command. These commands have the advantage, however, that the unstarred versions provide automatic numbering of the parts (or sections). %--------------------------------------------------------------------- \subsection{Leaving space for the answers} To leave a specific amount of blank space on the page for the answer to a question, you should use the \verb"\vspace*" command. For example, the command \verb"\vspace*{1in}" inserts one inch of vertical space after the line in which it appears. (If it appears in between paragraphs, then it inserts the space right there.) You can also use the \verb"\vspace" command, the difference being that any space inserted by \verb"\vspace" will be deleted if it occurs at the top of a new page, whereas space inserted by \verb"\vspace*" will never be deleted. If you want to equally distribute the blank space among the questions on the page, then just put \verb"\vspace*{\fill}" after each question on the page and use \verb"\newpage" to end the page. %-------------------------------------------------------------------- \subsection{Changing the page size} \label{sec:pagesize} The exam document style arranges things so that if you print onto standard American letter size paper (8.5~inches wide by 11~inches high) you'll get one inch margins at the top, bottom and sides. If you want to change the size of these margins (or if you're printing onto some other size paper), commands are provided to change the size of the printed area. To change the width of the printed area, you would use the \verb"\extrawidth" command. The \verb"\extrawidth" command takes one argument and enlarges the width of the printed area by the amount of the argument. It keeps the printed area centered as it changes its width. If the argument is negative, then the width of the printed area is decreased. For example, to enlarge the left and right margins by one half inch each, you would use the command \begin{center} \verb"\extrawidth{-1in}" \end{center} since the printed region must shrink by one inch to allow an additional one half inch on both sides. To decrease the left and right margins to three quarters of an inch each, you would use the command \begin{center} \verb"\extrawidth{.5in}" \end{center} since the printed region must grow by one half inch to decrease both margins by one quarter of an inch. To change the height of the printed area, you must choose whether the top or the bottom of the printed area (or possibly both) should move. The commands for this are principally intended to allow additional room for large headers and footers, and so they are called \verb"\extraheadheight" and \verb"\extrafootheight". For a full description of these commands, see section~\ref{sec:extra-room}. To move the top of the printed region (and any header that's present) downwards, you use the command \verb"\extraheadheight". This command takes one argument and moves the top of the text and the header down by this amount (keeping the distance between header and text constant). Thus, to increase the top margin by three quarters of an inch, you would give the command \begin{center} \verb"\extraheadheight{.75in}" \end{center} To decrease the top margin by one half inch, you would give the command \begin{center} \verb"\extraheadheight{-.5in}" \end{center} The \verb"\extraheadheight" command takes an optional argument to provide a top margin on the first page that's different from that on all other pages. For an explanation of this, see section~\ref{sec:extra-room}. To move the bottom of the printed region (and any footer that's present) upwards, you use the command \verb"\extrafootheight". This command takes one argument, and moves the bottom of the text and the footer up by this amount (keeping the distance between footer and text constant). Thus, to increase the bottom margin by three quarters of an inch, you would give the command \begin{center} \verb"\extrafootheight{.75in}" \end{center} To decrease the bottom margin by one half inch, you would give the command \begin{center} \verb"\extrafootheight{-.5in}" \end{center} The \verb"\extrafootheight" command takes an optional argument to provide a bottom margin on the first page that's different from that on all other pages. For an explanation of this, see section~\ref{sec:extra-room}. %-------------------------------------------------------------------- %--------------------------------------------------------------------- \section{Headers and footers} The following sections explain all of the technicalities of the commands that deal with headers and footers. There are a number of things to explain here, and so you may find it easier to skip this section and instead look at the examples in sections~\ref{sec:beginexamples} through~\ref{sec:endexamples} (on pages~\pageref{sec:beginexamples} through~\pageref{sec:endexamples}). You can then refer back to the technical sections for the full story on whatever isn't clear from the examples. %--------------------------------------------------------------------- \subsection{Page styles: Headers and/or footers} It's the \verb"\pagestyle" command that determines whether the exam will have headers, footers, both, or neither. The contents of the header and footer are specified using the commands described in sections~\ref{sec:header} through~\ref{sec:rules}, but it's the \verb"\pagestyle" command that determines whether the header and footer that you construct will actually be placed onto the page. The \verb"\pagestyle" command should be given after the \verb"\documentstyle" command, and before the \verb"\begin{document}". To have both a header and a footer, give the command % \begin{center} \verb"\pagestyle{headandfoot}" \end{center} % If you want every page to have a header but no footer, give the command % \begin{center} \verb"\pagestyle{head}" \end{center} % To give every page a foot but no head, give the command % \begin{center} \verb"\pagestyle{foot}" \end{center} % Finally, to omit both the header and the footer from the page, give the command % \begin{center} \verb"\pagestyle{empty}" \end{center} \bigskip As is true in all \LaTeX{} document styles, you can change the page style used on a single page by giving the command % \begin{center} \verb"\thispagestyle{somestyle}" \end{center} % somewhere on that page (where \verb"somestyle" is the style that you want to use on that page). This is most often needed if you use the \verb"\maketitle" command, since that command inserts a \verb"\thispagestyle{plain}" immediately following the title. If you use the \verb"\maketitle" command and you want the entire document to use \verb"\pagestyle{headandfoot}", then you'll need to put the command \verb"\thispagestyle{headandfoot}" immediately after the \verb"\maketitle" command to override the \verb"\thispagestyle{plain}" that is inserted by \verb"\maketitle". %--------------------------------------------------------------------- \subsection{The three parts of the header} \label{sec:header} The header is specified in three parts: % \begin{itemize} \item One part to be left justified. \item One part to be centered. \item One part to be right justified. \end{itemize} % There are two different ways in which you can specify the three parts of the header. The first uses the commands \verb"\lhead", \verb"\chead", and \verb"\rhead", each of which takes an optional argument to specify a different header for the first page (see section~\ref{sec:lhead}). The second uses the single command \verb"\header" to specify all three parts of the header, or the commands \verb"\firstpageheader" and \verb"\runningheader" to specify a different header for the first page (see section~\ref{sec:runningheader}). %-------------------------------------------------------------------- \subsubsection{Using lhead, chead and rhead} \label{sec:lhead} The command \verb"\lhead{Text}" puts ``Text'' into the left justified part of the header on every page. The command \verb"\lhead[Text 1]{Text 2}" puts ``Text~1'' into the left justified header on the first page and ``Text~2'' into the left justified header on all other pages. The commands \verb"\chead" and \verb"\rhead" have similar effects on the centered and right justified parts of the header. For example, to put the header \samplehead{Math 115}{Second Exam}{July 4, 1776}{} on every page of the exam, you would give the commands % \begin{verbatim} \lhead{Math 115} \chead{Second Exam} \rhead{July 4, 1776} \end{verbatim} If you want any of the three parts to have a special version to be used only on the first page, then you just include that special version as an optional argument (enclosed in square brackets) to the command. For example, if you want the above header for the first page, but on all pages after the first you want to have the header \samplehead{Math 115}{Second Exam (Continued)}{July 4, 1776}{} then you would give the commands % \begin{verbatim} \lhead{Math 115} \chead[Second Exam]{Second Exam (Continued)} \rhead{July 4, 1776} \end{verbatim} You can leave one or more of the three parts empty. To have the header \samplehead{Math 115}{Second Exam}{July 4, 1776}{} on the first page, with the header \samplehead{Math 115}{}{Second Exam (Continued)}{} on all other pages, you would give the commands % \begin{verbatim} \pagestyle{headandfoot} \lhead{Math 115} \chead[Second Exam]{} \rhead[July 4, 1776]{Second Exam Continued)} \end{verbatim} % Any of the three parts of the header can have multiple lines. To specify where the line breaks should go, you just type \verb"\\". Thus, to have the header \samplehead{\bf\large Math 115\\Professor Hilbert}{} {\bf\large First Exam\\July 4, 1776}{} appear on every page, you would give the commands % \begin{verbatim} \lhead{\bf\large Math 115\\Professor Hilbert} \chead{} \rhead{\bf\large First Exam\\July 4, 1776} \end{verbatim} %-------------------------------------------------------------------- \subsubsection{Using header, firstpageheader and runningheader} \label{sec:runningheader} The command \verb"\header{Text 1}{Text 2}{Text 3}" puts ``Text~1'' into the left justified header, ``Text~2'' into the centered header and ``Text~3'' into the right justified header on every page. If you want the header on the first page to be different from that on the other pages, then you should use the commands \verb"\firstpageheader" and \verb"\runningheader", which also take three arguments and affect either the first page or all pages except the first. For example, to put the header \samplehead{Math 115}{Second Exam}{July 4, 1776}{} on every page of the exam, you would give the command % \begin{verbatim} \header{Math 115}{Second Exam}{July 4, 1776} \end{verbatim} If you want to have different header on the first page from the header on all other pages, you would use the commands \verb"\firstpageheader" and \verb"\runningheader" instead of \verb"\header". For example, if you want the above header for the first page, but on all pages after the first you want to have the header \samplehead{Math 115}{Second Exam (Continued)}{July 4, 1776}{} then you would give the commands % \begin{verbatim} \firstpageheader{Math 115}{Second Exam}{July 4, 1776} \runningheader{Math 115}{Second Exam (Continued)}{July 4, 1776} \end{verbatim} You can leave one or more of the three parts empty. To have the header \samplehead{Math 115}{Second Exam}{July 4, 1776}{} on the first page, with the header \samplehead{Math 115}{}{Second Exam (Continued)}{} on all other pages, you would give the commands % \begin{verbatim} \firstpageheader{Math 115}{Second Exam}{July 4, 1776} \runningheader{Math 115}{}{Second Exam (Continued)} \end{verbatim} % Any of the three parts of the header can have multiple lines. To specify where the line breaks should go, you just type \verb"\\". Thus, to have the header \samplehead{\bf\large Math 115\\Professor Hilbert}{} {\bf\large First Exam\\July 4, 1776}{} appear on every page, you would give the command % \begin{verbatim} \header{\bf\large Math 115\\Professor Hilbert}% {}% {\bf\large First Exam\\July 4, 1776} \end{verbatim} %--------------------------------------------------------------------- \subsubsection*{Leaving extra room for multiple line headers} See section~\ref{sec:extra-room} for a description of the \verb"\extraheadheight" command. %--------------------------------------------------------------------- \subsection{The three parts of the footer} \label{sec:footer} The footer is composed of three parts, the whole setup being similar to that for the header (see section~\ref{sec:header}). There are two different ways in which you can specify the three parts of the footer. The first uses the commands \verb"\lfoot", \verb"\cfoot", and \verb"\rfoot", each of which takes an optional argument to specify a different footer for the first page (see section~\ref{sec:lfoot}). The second uses the single command \verb"\footer" to specify all three parts of the footer, or the commands \verb"\firstpagefooter" and \verb"\runningfooter" to specify a different footer for the first page (see section~\ref{sec:runningfooter}). %-------------------------------------------------------------------- \subsubsection{Using lfoot, cfoot and rfoot} \label{sec:lfoot} The command \verb"\lfoot{Text}" puts ``Text'' into the left justified part of the footer on every page. The command \verb"\lfoot[Text 1]{Text 2}" puts ``Text~1'' into the left justified footer on the first page and ``Text~2'' into the left justified footer on all other pages. The commands \verb"\cfoot" and \verb"\rfoot" have similar effects on the centered and right justified parts of the footer. For example, to have an empty footer on the first page and the footer \samplefoot{}{}{Page 3 of 5}{} on all pages after the first, you would give the commands % \begin{verbatim} \lfoot{} \cfoot{} \rfoot[]{Page \thepage\ of \numpages} \end{verbatim} % (For an explanation of the \verb"\numpages" command, see section~\ref{sec:numpages}.) %-------------------------------------------------------------------- \subsubsection{Using footer, firstpagefooter and runningfooter} \label{sec:runningfooter} The command \verb"\footer{Text 1}{Text 2}{Text 3}" puts ``Text~1'' into the left justified footer, ``Text~2'' into the centered footer and ``Text~3'' into the right justified footer on every page. If you want the footer on the first page to be different from that on the other pages, then you should use the commands \verb"\firstpagefooter" and \verb"\runningfooter", which also take three arguments and affect either the first page or all pages except the first. For example, to have an empty footer on the first page and the footer \samplefoot{}{}{Page 3 of 5}{} on all pages after the first, you would give the commands % \begin{verbatim} \firstpagefooter{}{}{} \runningfooter{}{Page \thepage\ of \numpages}{} \end{verbatim} % (For an explanation of the \verb"\numpages" command, see section~\ref{sec:numpages}.) %--------------------------------------------------------------------- \subsubsection*{Leaving extra room for multiple line footers} See section~\ref{sec:extra-room} for a description of the \verb"\extrafootheight" command. %--------------------------------------------------------------------- \subsection{Leaving extra room for multiple line headers and footers} \label{sec:extra-room} \subsubsection*{Headers} If you specify more than one or two lines for any part of the header, then you may want to move the header down slightly so that it doesn't run off of the top of the paper. The command for this is \verb"\extraheadheight". You can also use the \verb"\extraheadheight" command to adjust the size of the text area. The \verb"\extraheadheight" command never changes the distance between the header and the text. For example, to move the header and the text a half inch down from the top of the page, you would give the command % \begin{center} \verb"\extraheadheight{.5in}" \end{center} % You can also specify a negative distance to \verb"extraheadheight" to move the header up closer to the top of the paper. For example, the command % \begin{center} \verb"\extraheadheight{-.25in}" \end{center} % moves the header one quarter inch closer to the top of the paper. If you want to have a different value for \verb"\extraheadheight" on the first page from that on the pages after the first, then use the same syntax as in the \verb"\lhead", \verb"\chead", and \verb"\rhead" commands: Include an optional argument giving the extra head height for the first page, and the required argument will apply only to those pages after the first. For example, the command % \begin{center} \verb"\extraheadheight[.5in]{.25in}" \end{center} % gives a half inch of extra head height on the first page and a quarter inch of extra head height on all pages after the first. If you say % \begin{center} \verb"\extraheadheight[.5in]{}" \end{center} % then this will be interpreted as if it was % \begin{center} \verb"\extraheadheight[.5in]{0in}" \end{center} % Note that the braces {\em must\/} appear. If you give an \verb"\extraheadheight" command, it should be after the \verb"\documentstyle" command but before the \verb"\begin{document}" command. The \verb"\extraheadheight" command can also be used to change the size of the text region (see section~\ref{sec:pagesize}). \subsubsection*{Footers} To leave extra room for multiple line footers, you use the command \verb"\extrafootheight". Thus, to move the footer one half inch higher up on the paper, you would give the command % \begin{center} \verb"\extrafootheight{.5in}" \end{center} % If you wanted to move the footer an eighth of an inch lower down on the paper, you would give the command % \begin{center} \verb"\extrafootheight{-.125in}" \end{center} If you want to have a different value for \verb"\extrafootheight" on the first page from that on the pages after the first, then use the same syntax as in the \verb"\lfoot", \verb"\cfoot", and \verb"\rfoot" commands: Include an optional argument giving the extra foot height for the first page, and the required argument will apply only to those pages after the first. For example, the command % \begin{center} \verb"\extrafootheight[.5in]{.25in}" \end{center} % gives a half inch of extra foot height on the first page and a quarter inch of extra foot height on all pages after the first. If you say % \begin{center} \verb"\extrafootheight[.5in]{}" \end{center} % then this will be interpreted as if it was % \begin{center} \verb"\extrafootheight[.5in]{0in}" \end{center} % Note that the braces {\em must\/} appear. If you give an \verb"\extrafootheight" command, it should be after the \verb"\documentstyle" command but before the \verb"\begin{document}" command. The \verb"\extrafootheight" command can also be used to change the size of the text region (see section~\ref{sec:pagesize}). %--------------------------------------------------------------------- \subsection{Horizontal rules} \label{sec:rules} The \verb"exam" document style make it easy to put a horizontal rule under the header and one above the footer. It is also easy to do this for the pages after the first page without affecting the first page. \begin{itemize} \item The command \verb"\runningheadrule" puts a horizontal rule below the header on all pages after the first. \item The command \verb"\firstpageheadrule" puts a rule under the header of only the first page. \item The command \verb"\headrule" is equivalent to the two commands \verb"\firstpageheadrule" and \verb"\runningheadrule". \item The command \verb"\runningfootrule" puts a horizontal rule above the footer on all pages after the first. \item The command \verb"\firstpagefootrule" puts a rule above the footer of only the first page. \item The command \verb"\footrule" is equivalent to the two commands \verb"\firstpagefootrule" and \verb"\runningfootrule". \end{itemize} % For example, to have the header \samplehead{Math 115}{First Exam}{July 4, 1776}{} on the first page, with the header \samplehead{Math 115}{First Exam}{July 4, 1776}{\hrule} on all pages after the first, give the commands % \begin{verbatim} \runningheadrule \lhead{Math 115} \chead{First Exam} \rhead{July 4, 1776} \end{verbatim} \bigskip To have no footer on the first page, and the footer \samplefoot{\hrule}{}{Page 3 of 5}{} on all pages after the first, you would give the commands % \begin{verbatim} \runningfootrule \lfoot{} \cfoot[]{Page \thepage\ of \numpages} \rfoot{} \end{verbatim} %--------------------------------------------------------------------- \subsection{Listing the number of pages in the exam} \label{sec:numpages} The \verb"exam" document style defines the command \verb"\numpages" so that it will expand to the number of pages in the exam. Thus, to have the footer \samplefoot{}{}{Page \thepage\ of \numpages}{} you should give the commands % \begin{verbatim} \lfoot{} \cfoot{Page \thepage\ of \numpages} \rfoot{} \end{verbatim} % For a description of the commands \verb"\lfoot", \verb"\cfoot", and \verb"\rfoot", see section~\ref{sec:footer}. As with all other cross referencing commands in \LaTeX, you'll have to run the file through \LaTeX{} {\em twice\/} to be sure that \verb"\numpages" is correct. %--------------------------------------------------------------------- \subsection{Testing for the last page} \label{sec:lastpage} If you want to vary the text that appears in the header or footer on the last page of the exam, you should use the command \verb"\iflastpage". The command % \begin{center} \verb"\iflastpage{Text 1}{Text 2}" \end{center} % expands to `Text~1' on the last page, and to `Text~2' on all pages before the last. Thus, to have the footer \samplefoot{}{}{Please go on to the next page\ldots}{} on all pages before the last page, and the footer \samplefoot{}{}{End of exam}{} on the last page, you would give the commands % \begin{verbatim} \lfoot{} \cfoot{\iflastpage{End of exam}{Please go on to the next page\ldots}} \rfoot{} \end{verbatim} % For a description of the commands \verb"\lfoot", \verb"\cfoot", and \verb"\rfoot", see section~\ref{sec:footer}. As with all other cross referencing commands in \LaTeX, you'll have to run the file through \LaTeX{} {\em twice\/} to be sure that \verb"\iflastpage" correctly detects the last page. %-------------------------------------------------------------------- \subsection{Treating odd and even numbered pages differently} If you'd like odd and even numbered pages to be treated differently (perhaps because you'll be printing onto both sides of the paper), you should use the \verb"\oddeven" command. The \verb"\oddeven" command takes two arguments. If the current page number is odd it expands to the first argument; otherwise, it expands to the second argument. For example, to have the page number printed in the right head on odd numbered pages and in the left head on even numbered pages, you would use the commands \begin{center} \begin{verbatim} \rhead{\oddeven{\thepage}{}} \lhead{\oddeven{}{\thepage}} \chead{} \end{verbatim} \end{center} If you wanted the footer of the even numbered pages to be empty and the footer of the odd numbered pages to contain the message ``Please continue\dots'', except that the last page of the exam should have an empty footer whether its page number is even or odd, then you would use the commands \begin{center} \begin{verbatim} \lfoot{} \rfoot{} \cfoot{\oddeven{\iflastpage{}{Please continue\dots}}{}} \end{verbatim} \end{center} (see section~\ref{sec:lastpage} for an explanation of \verb"\iflastpage"). Although the \verb"\oddeven" command can be used anywhere in the document (i.e., not just in headers and footers), it is reliable only in headers and footers. This is because \LaTeX{} generally processes more text than can fit on the current page before it outputs a page. When the \verb"\oddeven" command is encountered it will act as though it will appear on the current page whether it appears on that page or on the following page. %-------------------------------------------------------------------- \subsection{Examples} \begin{example} \label{sec:beginexamples} To have the header \samplehead{Math 115}{First Exam}{July 4, 1776}{} on the first page, the header \samplehead{Math 115}{First Exam, Page 2 of 5}{July 4, 1776}{\hrule} on all pages after the first, and no footer on any page, give the commands % \begin{verbatim} \pagestyle{head} \runningheadrule \lhead{Math 115} \chead[First Exam]{First Exam, Page \thepage\ of \numpages} \rhead{July 4, 1776} \end{verbatim} % Alternatively, you could give the commands % \begin{verbatim} \pagestyle{head} \runningheadrule \firstpageheader{Math 115}{First Exam}{July 4, 1776} \runningheader{Math 115}% {First Exam, Page \thepage\ of \numpages}% {July 4, 1776} \end{verbatim} % \end{example} \begin{example} To have the header \samplehead{\large\bf Mathematics 115\\ First Exam, July 4, 1776}% {}{\large\bf Name:\enspace\hbox to 2in{\hrulefill}}{} on the first page, the header \samplehead{\large\bf Mathematics 115\\ First Exam, July 4, 1776}% {}{}{} on all pages after the first, an empty foot on the first page, and the footer \samplefoot{}{}{Page 2}{} on all pages after the first, give the commands % \begin{verbatim} \pagestyle{headandfoot} \lhead{\large\bf Mathematics 115\\ First Exam, July 4, 1776} \chead{} \rhead[\large\bf Name:\enspace\hbox to 2in{\hrulefill}]{} \lfoot{} \cfoot[]{Page \thepage} \rfoot{} \end{verbatim} % Alternatively, you could give the commands \begin{verbatim} \pagestyle{headandfoot} \firstpageheader{\large\bf Mathematics 115\\ First Exam, July 4, 1776}% {}{\large\bf Name:\enspace\hbox to 2in{\hrulefill}} \runningheader{\large\bf Mathematics 115\\ First Exam, July 4, 1776}{}{} \firstpagefooter{}{}{} \runningfooter{}{Page \thepage}{} \end{verbatim} \end{example} \begin{example} To have the header \samplehead{}{Wellesley College\\ Second Semester Final Examination, Spring 1993\\ Mathematics 115}{}{} on the first page, the header \samplehead{}{Wellesley College\\ Second Semester Final Examination, Spring 1993\\ Mathematics 115 (Continued)}{}{} on all pages after the first, the footer \samplefoot{}{}{Page 3 of 10}{Please go on to the next page\ldots} on all pages {\em except the last\/} page, and the footer \samplefoot{}{}{Page 10 of 10}{End of exam.} on the last page, give the commands % \begin{verbatim} \pagestyle{headandfoot} \extraheadheight{.25in} \lhead{} \chead[Wellesley College\\ Second Semester Final Examination, Spring 1993\\ Mathematics 115] {Wellesley College\\ Second Semester Final Examination, Spring 1993\\ Mathematics 115 (Continued)} \rhead{} \lfoot{} \cfoot{Page \thepage\ of \numpages} \rfoot{\iflastpage{End of exam.}{Please go on to the next page\ldots}} \end{verbatim} % Alternatively, you could give the commands \begin{verbatim} \pagestyle{headandfoot} \extraheadheight{.25in} \firstpageheader{}{Wellesley College\\ Second Semester Final Examination, Spring 1993\\ Mathematics 115}{} \runningheader{}{Wellesley College\\ Second Semester Final Examination, Spring 1993\\ Mathematics 115 (Continued)}{} \footer{}{Page \thepage\ of \numpages}% {\iflastpage{End of exam.}{Please go on to the next page\ldots}} \end{verbatim} \end{example} \begin{example} \label{sec:endexamples} To have the header \samplehead{Math 115}{First Exam}{July 4, 1776}{} on the first page, no header on the pages after the first, no footer on the first page, and the footer \samplefoot{\hrule}{Math 115}{First Exam}{Page 2 of 5} on all pages after the first, give the commands % \begin{verbatim} \pagestyle{headandfoot} \runningfootrule \lhead[Math 115]{} \chead[First Exam]{} \rhead[July 4, 1776]{} \lfoot[]{Math 115} \cfoot[]{First Exam} \rfoot[]{Page \thepage\ of \numpages} \end{verbatim} % Alternatively, you could give the commands \begin{verbatim} \pagestyle{headandfoot} \runningfootrule \firstpageheader{Math 115}{First Exam}{July 4, 1776} \runningheader{}{}{} \firstpagefooter{}{}{} \runningfooter{Math 115}{First Exam}{Page \thepage\ of \numpages} \end{verbatim} % \end{example} %-------------------------------------------------------------------- \end{document}