I want prepare a question paper for my students. It is not very tedious. After taking the exam, I want to supply the students the answer of the question in a question answer style. There are 100 questions in the exam. I want to prepare a tex where all question and answer are stored but if I need only the paper, I don't want to delete or put percentage sign to each of the answer lines. The 2nd part is not solved by me.
\documentclass[12pt]{article}
\usepackage{graphicx}
\newif\iftechexplorer\techexplorerfalse
\setlength{\textheight}{9in}
\setlength{\textwidth}{7in}
\setlength{\topmargin}{-0.75in}
\setlength{\oddsidemargin}{-0.25in}
\setlength{\evensidemargin}{-0.25in}
\title{Math question paper}
\author{A B C}
\date{July 17, 2014}
\begin{document}
\pagestyle{headings}
\markright{Math 1P21/1P91\hrulefill Midterm $\alpha$, July 17, 2014\hrulefill page~}
\maketitle
\begin{center}
{\Large
\begin{tabular}{|r|c|}
\hline
Last Name & \hspace*{2.5in} \\ \hline
First Name & \hspace*{2.5in} \\ \hline
Student ID & \\ \hline
\end{tabular}
}
\vspace{0.2in}
{\large\bf Circle your course number above}
\end{center}
No examination aids other than those specified on this examination script are permitted
(FHB 5.1.2.A). Use or possession of unauthorized materials will automatically result
in the award of a zero grade for this examination.
\begin{center}
{\large\bf
This is a closed--book test, only calculators are allowed \\
Formulas not on the supplied formula sheet must be derived\\
~ \\
Attempt all questions}
\vspace{0.3in}
{\Large
\begin{tabular}{|c|c|c|}
\hline
Question & ~~Mark~~ & ~~Out of~~ \\
\hline \hline
1 &a~b~c~d~e & 1 \\ \hline
2 &a~b~c~d~e & 1 \\ \hline
3 &a~b~c~d~e & 1 \\ \hline
4 &a~b~c~d~e & 1 \\ \hline
5 &a~b~c~d~e & 1 \\ \hline
\hline
6 & & 5 \\ \hline
7 & & 5\\ \hline
8 & & 5\\ \hline
\hline
Total & & 20\\ \hline
\end{tabular}
} % end \Large
\vspace{0.2in}
\end{center}
\vspace{-0.7cm}
{\it For questions 1--5: circle the correct answer} {\bf on the front page}.
\begin{enumerate}
\item[~(Q)~{\bf 1}.] Prove that $f:R/\{0\}\to R$, $f(x)={1\over x}$ is differentiable at $x_0\not =0$.
{\bf Soln}.
%We only need to consider $f$ on $(x_0-\delta, x_0+\delta)$.
\begin{eqnarray*}
\lim_{x\to x_0} {f(x)-f(x_0)\over x-x_0}&=&\lim_{x\to x_0} {{1\over x}-{1\over x_0}\over x-x_0}\\
&=&\lim_{x\to x_0} {{x_0-x\over x_0x}\over x-x_0}\\
&=&\lim_{x\to x_0} -{1\over x_0x}=-{1\over x_0^2},
\end{eqnarray*}
in the last step we use that ${1\over x}$ is continuous at $x_0\not =0$.
\item[~(Q)~{\bf 2}.] Show that the function
$$f(x)=\left\{\begin{array}{ll}
x \sin(1/x),& \quad x\not =0\\
0, &\quad x=0 \end{array}\right.$$
is continuous everywhere but it is not differentiable at $x_0=0$.\\
{\bf Soln}.{\em
The function is continuous at $x\neq 0$ by an easy application of the algebra of continuity.
That $f(x)$ is continuous at
$x=0$ is discussed in Example \ref{example-3.8}.
If $x_0=0$, let $$g(x)={f(x)-f(0)\over x-0}=
\sin(1/x),\quad x\not =0\\.$$
Note that $g$ is defined on $R-\{0\}$.
We have previously proved that $\lim_{x\to 0}g(x)$ does not exist.
So $f$ is not differentiable at $0$.
(Take $x_n={1\over 2\pi n}\to 0$, $y_n={1\over 2\pi n+{\pi\over 2} }\to 0$.
Then $g(x_n)=0$, $g(y_n)=1$.)
}
\end{enumerate}
\end{document}
Don't have the time to privide a working example, but please have a look at package exsheets and/or the exam class. I think both provide what you are looking for.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Thanks for the suggestion. I got a tex file through web search. Now please help me to solve my problem. Here \documentclass[12pt,answers]{exam} has been used.
\documentclass[12pt,answers]{exam}
\usepackage{listings}
\usepackage{amsthm, amsmath, amssymb}
\usepackage{mathrsfs,latexsym}
\usepackage{graphicx,subfigure}
\usepackage{verbatim}
\firstpageheader{\bf\Large MATH}{\bf\Large Exam \#1 With \ifprintanswers Solutions \else \fi}{\ifprintanswers \else\bf\Large 2012-02-27 \fi}
\runningheader{MATH}{}{Exam \#1 The \ifprintanswers Solutions \else \fi}
\ifprintanswers \else
\firstpagefooter{}{}{Points earned: \fbox{\begin{minipage}{.25in}
\hspace{.1in}
\vspace{.25in}
\end{minipage}}\ {\Huge /}{\Large\pointsonpage{\thepage}}}
\runningfooter{}{Page \thepage\ }{Points earned: \fbox{\begin{minipage}{.25in}
\hspace{.1in}
\vspace{.25in}
\end{minipage}}\ {\Huge /}{\Large\pointsonpage{\thepage}}}
\fi
\addpoints
% THEOREMS -------------------------------------------------------
%
\newtheorem{claim}{Claim}
%
% MATH -----------------------------------------------------------
%
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\abs}[1]{\left\lvert#1\right\rvert}
\newcommand{\set}[1]{\left\lbrace#1\right\rbrace}
\newcommand{\setst}[2]{\left\lbrace#1\ \middle|\ #2\right\rbrace}
\newcommand{\sym}{\bigtriangleup}
%
\newcommand{\spa}{\operatorname{span}}
\newcommand{\nul}{\operatorname{null}}
\newcommand{\range}{\operatorname{range}}
%
\newcommand{\Real}{\ensuremath{\mathbb R}}
\newcommand{\Rational}{\ensuremath{\mathbb Q}}
\newcommand{\Complex}{\ensuremath{\mathbb C}}
\newcommand{\Natural}{\ensuremath{\mathbb N}}
%
\newcommand{\To}{\ensuremath{\longrightarrow}}
\newcommand{\dd}[2]{\ds\frac{d#1}{d#2}}
\newcommand{\ddx}[1]{\frac{d#1}{dx}}
\newcommand{\lh}{\stackrel{\text{\tiny LH}}{=}}
%
\newcommand{\eps}{\ensuremath{\varepsilon}}
\newcommand{\BX}{\ensuremath{\mathbf{B}(X)}}
\newcommand{\FL}{\ensuremath{\mathscr{L}}}
\newcommand{\A}{\ensuremath{\mathcal{A}}}
\newcommand{\F}{\ensuremath{\mathcal{F}}}
\newcommand{\PS}{\ensuremath{\mathscr{P}}}
%
\renewcommand{\qedsymbol}{$\blacksquare$}
\long\def\symbolfootnote[#1]#2{\begingroup%
\def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup}
%
% ABBREVIATED/RENAMED COMMANDS -----------------------------------
\newcommand{\ds}{\displaystyle}
\newcommand{\of}{\circ}
\newcommand{\contradiction}{\blitza}
\reversemarginpar
% ----------------------------------------------------------------
\begin{document}
\ifprintanswers \else
\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering \textsc{Guidelines:} You may use your textbook,....\\
There are \numquestions\ questions for a total of \numpoints\ points.
}}}
\end{center}
\fi
% setup standard options for the including code fragments
\lstset{language=Python,numbers=left}
\ifprintanswers \else
\vspace{0.1in}
\hbox to \textwidth{Name:\enspace\hrulefill}
\fi
% Questions start here:
\begin{questions}
\setcounter{question}{5}
\question Provide an argument or counter example to support the truth value of the following statements.
\begin{parts}
\part[3] $\exists x \in \Real, x^2-x=0$.
\begin{solution}[\stretch{1}]
True since the value $x=0$ or $x=1$ satisfy the equation.
\end{solution}
\part[3] $\forall x \in \Real, \sqrt{x^2}=x$.
\begin{solution}[\stretch{1}]
False, any $x<0$ is a counterexample.
\end{solution}
\part[3] $\exists x,y\in\Real, x+y+3=8$.
\begin{solution}[\stretch{1}]
True since $x=0, y=5$ satisfies the equation.
\end{solution}
\part[3] $\forall x,y\in\Real, x+y+3=8$
\begin{solution}[\stretch{1}]
False since $x=y=0\in\Real$ fails.
\end{solution}
\end{parts}
\ifprintanswers \else \newpage \fi
\question[8] Prove or give a counterexample to the following statement.
\begin{center}
$A\subseteq B$ if and only if $\PS(A)\subseteq\PS(B)$
\end{center}
\begin{solution}[\stretch{1}]
$(\implies)$: Assume $A\subseteq B$. Let $X\in\PS(A)$. This means that $X\subseteq A$. Since $X\subseteq A\subseteq B$, we know $X\subseteq B$. This means $X\in\PS(B)$.
$(\Longleftarrow)$: Assume $\PS(A)\subseteq \PS(B)$. Let $x\in A$. This means $\set{x}\subseteq A$ and so we have $\set{x}\in\PS(A)$. Since $\PS(A)\subseteq\PS(B)$, we have $\set{x}\in\PS(B)$. In other words, $\set{x}\subseteq B$. Now, $\set{x}\subseteq B$ implies $x\in B$.
\end{solution}
\ifprintanswers \else
\uplevel{
\fbox{\fbox{\parbox{6.35in}{\centering Once you have...'' and sign your name.
\vspace{.2in}
\hrulefill
\vskip .05 in
\hrulefill
\vskip .05 in
\hrulefill
\vskip .05 in
\hrulefill
\vskip .1 in
}}}}
\fi
\end{questions}
\end{document}