[Tugindia] Printing Answers seperately in exam document class

S.V. Sreejan svsreejan at gmail.com
Thu Sep 24 18:59:26 CEST 2015


Have a look at this code

\documentclass{exam}
\newwrite\myfile
\begin{document}

\immediate\openout\myfile=answers.tex
\immediate\write\myfile{\setlength{\parindent}{0pt}}
\newcommand{\ans}[1]{\immediate\write\myfile{\thequestion.\,\,#1}\immediate\write\myfile{\string\newline}}

\section*{Questions}

\begin{questions}
  \question Which is/are the neighbouring countries of India?
    \begin{choices}
      \choice Nepal
      \choice USA
      \choice Thailand
      \choice China
    \end{choices}
  \ans{(A, D) Hint: Thailand and USA are not neighbouing countries.}

  \question Who introduced mid-meal scheme in Tamil Nadu?\\
    \begin{choices}
      \choice Kamarajar
      \choice M.G.Ramachandran
      \choice C.N.Annadurai
      \choice Thandai Periyar
    \end{choices}
  \ans{(A) Hint: Kalvikan thiranda Kamarajar.}
\end{questions}

\immediate\closeout\myfile

\section*{Answers}

\input{answers}
\end{document}


=============================
SREEJAN S V
Principal & Mathematics Teacher,
Perambra Higher Secondary School,
Kozhikode, Kerala -673 525
Phone: Office 0496 2616220.
------------------------------------------------------
SREE, Eravattoor, Perambra,
Kozhikode, Kerala - 673 525
Ph: 0496 2614271(R)
Mob: 9447014271.
==============================

On Sat, Sep 19, 2015 at 7:41 PM, SIVAKUMAR R <skarg_ind at hotmail.com> wrote:

> I want to print answers separately after the end of the the questions in
> exam document class. Guide me.
>
> 1. Which is/are the neighbouring countries of India?
> A. Nepal B. USA C. Thailand D. China
>
> 2. Who introduced mid-meal scheme in Tamil Nadu?
> A. Kamarajar B. M.G.Ramachandran C. C.N.Annadurai D. Thandai Periyar
>
> Solution:
> 1. (A, D) Hint: Thailand and USA are not neighbouing countries
> 2. (A) Hint: Kalvikan thiranda Kamarajar.
>
>
> இரா.சிவக்குமார் (R.SIVAKUMAR)
> கணித விரிவுரையளர் (LECTURER IN MATHEMATICS),
> www.rasivakumar.blogspot.in
> _______________________________________________
> Home:        http://www.tug.org.in/
> TeX FAQ:     http://www.tex.ac.uk/faq
> unsubscribe: http://tug.org/mailman/listinfo/tugindia


More information about the tugindia mailing list