See the fourth question: the choices are showing twice one is along horizontal and another is along vertical, but I need only one like the above three. The commands I have used is given below.
\documentclass{exam}
\usepackage{ifthen}
\usepackage{calc}
\renewcommand{\baselinestretch}{1.2}
\oddsidemargin 0in \evensidemargin 0in \topmargin 0in \textheight
9.2in \textwidth 6.5in
%\hoffset -1in
%\voffset -1in
%\evensidemargin 14pt
\usepackage{amsmath,amsthm,amsfonts,amssymb,dsfont}
\pagestyle{headandfoot} \extraheadheight{.5in} \lhead[]{}
\chead[ \vskip .1in MATHEMATICS\\
STANDARD X(CBSE)\\
%\hrule
\textbf{PAIR OF LINEAR EQUATIONS IN TWO VARIABLES} \linebreak
\textbf{Time: 1 Hour} \hskip 1.3in \textsf{ }
\hfill{\textbf{Max. Marks:30}}\vskip.05in \vskip -.5in]{}
\rhead[]{} \lfoot{David 7502878908} \cfoot{HOME TUITIONS}
\rfoot{\iflastpage{$\maltese\maltese\maltese \maltese
\maltese$}{Continued...\ldots}} \pointsinrightmargin
\newcommand{\ntt}{\normalfont\ttfamily}
% command name
\newcommand{\cn}[1]{{\protect\ntt\bslash#1}}
\hfuzz1pc % Don't bother to report overfull boxes if overage is < 1pc
\newcommand{\thmref}[1]{Theorem~\ref{#1}}
\newcommand{\secref}[1]{\S\ref{#1}}
\newcommand{\lemref}[1]{Lemma~\ref{#1}}
%\newcommand{\bysame}{\mbox{\rule{3em}{.4pt}}\,}
\newcommand{\sqt}[1]{\sqrt{\smash[b] {#1}}}
% \interval is used to provide better spacing after a [ that
% is used as a closing delimiter.
\newcommand{\interval}[1]{\mathinner{#1}}
% Notation for an expression evaluated at a particular condition. The
% optional argument can be used to override automatic sizing of the
% right vert bar, e.g. \eval[\biggr]{...}_{...}
\newcommand{\eval}[2][\right]{\relax
\ifx#1\right\relax \left.\fi#2#1\rvert}
% Enclose the argument in vert-bar delimiters:
\newcommand{\envert}[1]{\left\lvert#1\right\rvert}
\let\abs=\envert
% Enclose the argument in double-vert-bar delimiters:
\newcommand{\enVert}[1]{\left\lVert#1\right\rVert}
\let\norm=\enVert
\newcommand{\pad}[2]{\frac{\der #1}{\der #2}}
\newcommand{\IC}{{\mathbb C}}
\newcommand{\IN}{{\mathbb N}}
\newcommand{\IR}{{\mathbb R}}
\newcommand{\gol}{\mbox{$\,${\rm Log}$\,$}}
\newcommand{\Log}{\ln}
\newcommand{\ov}[1]{\overline{\smash[b] {#1}}}
\newcommand{\Ndash}{\nobreakdash--}
\newcommand{\IE}{{\mathds{R}^n}}
\newcommand{\IF}{{\mathds{R}^m}}
\setlength\parindent{0pt}
%usage \choice{ }{ }{ }{ }
%(A)(B)(C)(D)
\newcommand{\fourch}[4]{
\par
\begin{tabular}{*{4}{@{}p{0.23\textwidth}}}
(a)~#1 & (b)~#2 & (c)~#3 & (d)~#4
\end{tabular}
}
%(A)(B)
%(C)(D)
\newcommand{\twoch}[4]{
\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(A)~#1 & (B)~#2
\end{tabular}
\par
\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}
(C)~#3 & (D)~#4
\end{tabular}
}
%(A)
%(B)
%(C)
%(D)
\newcommand{\onech}[4]{
\par
(A)~#1 \par (B)~#2 \par (C)~#3 \par (D)~#4
}
\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth
\setlength\tabmaxwidth{0.96\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}
\newcommand{\choice}[4]{
\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}
\settowidth\widthchb{BM.#2}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\settowidth\widthchb{CM.#3}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\settowidth\widthchb{DM.#4}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\ifthenelse{\widthch<\fourthtabwidth}{\fourch{#1}{#2}{#3}{#4}}
{\ifthenelse{\widthch<\halftabwidth\and\widthch>\fourthtabwidth}{\twoch{#1}{#2}{#3}{#4}}
{\onech{#1}{#2}{#3}{#4}}}
}
\begin{document}
\hrule
\begin{questions}
\question What is your favourite color?
\onech{cjfije}{nkwjfl}{vvkji}{ n ejok}
\question nci jifj
\twoch{nknfi}{nvsjijp}{msj8j}{n vuhjkd}
\question kkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
\fourch{qqqqqqqqq}{qqqqqqqqqq}{qqqqqqqqq}{rrrrrrrrrrrr}
\question what is your favourite fruit?
\choice{apple}{banana}{orang}{pear}
\end{questions}
\end{document}
I think there is a wrong in the following redefinition..
\newcommand{\choice}[4]{
\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}
\settowidth\widthchb{BM.#2}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\settowidth\widthchb{CM.#3}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\settowidth\widthchb{DM.#4}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\ifthenelse{\widthch<\fourthtabwidth}{\fourch{#1}{#2}{#3}{#4}}
{\ifthenelse{\widthch<\halftabwidth\and\widthch>\fourthtabwidth}{\twoch{#1}{#2}{#3}{#4}}
{\onech{#1}{#2}{#3}{#4}}}
}
Kindly correct it and tell me how to identify the correct choice and to print in a separate sheet.
Best Answer
In order to perform a length test using
ifthen
you need to explicitly state it:where
?
is one of<
,=
or>
. I've adopted a more old-school way of testing dimensions using\ifdim
: