I'm trying to add Question Type : Match the Pairs using EXAM Class use code mentioned below : [FYI: I'm converting HTML Table into Latex table. I'm using pdflatex to get pdf from tex file mentioned below.]
\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}
\newenvironment{Figure}
{\par\medskip\noindent\minipage{\linewidth}}
{\endminipage\medskip\par}
\marksnotpoints
\bracketedpoints
\pointsdroppedatright
\qformat{Q. \thequestion: \thequestiontitle\hfill\thepoints}
\renewcommand{\thesubsubpart}{\arabic{subsubpart}}
\renewcommand{\thechoice}{\arabic{choice}}
\runningheadrule
\pagestyle{headandfoot}
\runningheader{Competitive Examination}{}{}
\firstpagefooter{}{Page \thepage}{}
\runningfooter{}{Page \thepage}{}
\footrule
\renewcommand{\thepartno}{\Alph{partno}}
\begin{document}
\begin{center} {\centering \textbf{\Large{Dummy Value}}} \end{center}
\small{ABCD1234} \hspace*{\fill}
\small{TERMINAL EXAMINATION} \hspace*{\fill}
\small{Marks: 60}
\newline
\small{SSC-SET1} \hspace*{\fill}
\small{Science (Ch - 1,2,3)} \hspace*{\fill}
\small{2\textonehalf Hours}
\newline
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
\begin{center} {\centering \textbf{SECTION A}} \end{center}
\begin{questions}
\titledquestion{Match the Pairs}[10]
\begin{table}[ht] \begin{tabular}{l l l} \hline \hline
A &
B &
\\
\ 1) Why this text is dummy over here &
\ a) there is not dummy text &
\\
\ 2) THis is one word &
\ b) THis is not the correct word &
\\
\ 3) This is dummy value al dfadf adf adfasdf \ ddfakdfaasdf .\ &
\ c) values are here for all fasdf ad asdfasdkfad.\ &
\\
\ 4) asd fads adsfkaj dkladjsflkadsf asdfa skdlj, asdfasdasdfasdfa &
\ d) adjfklasd fasldfjasdlkfjasdlkfadsflkja sdflkjasd;lfkjasd;lfkja;sldkfjals;dk\ &
\\
\ 5) asdfasdfjas;dlfkjaslkdalkdsjf;alksdjfasdklfads &
\ e) adjfklasdjfa;lksdjf;alskdjf;alskdjf;alksdjf;laksdjf;alksdfj;alksdfja;lksdfja;lksdfja;lskdfj;alksdjfalksdfjasdklfjas;dlfja;sdlkfalkdjfa;lkdsjf;alksdfaldfja;lsdkfja;lsdkjf;alskdfj;aldkjf;alksdjfalksddddddfajsdlkfja;lsdkjf ;alsdjf ;asdjf; ajdf;l j;asdlfj ;alkdjsf;laksejriaeidkl ja;dlkfja;slkdfj a;ldskfja;sdikdfka dof asdf asdfk;lajsd;flkaj d;lkfajsd;lfk ja;dsfj ;alskdjf; lkadsjf;alksdjf; alsdfkja;lskdjf;alsdjf;alsdkjf;alskdjf\ &
\\
\hline \end{tabular} \label{table:nonlin} \end{table}
\end{questions}
\end{document}
Generated output is mentioned below
I'm facing two problems in this code :
- Match the pair table is coming above question title
- If there is
longer word or more text, it's going outside pagewidth
Can you please give me direction to solve these errors?
Best Answer
Here are some more to add on Phil and Werner's answer: first, for list structure, you should consider using
enumerate
environment; second, even withtabularx
LaTeX will still have some trouble handling extremely long word which had appeared in your example, in this case you can either use\hyphenation{...}
to manually set up hyphenation or use\seqsplit{...}
provided byseqsplit
package. Now here is a demonstration:Here I skip the preamble for it's too long
and its result:
Update
After thinking a while about your new request I came up a way to mimic the
enumerate
environment withtabularx
. First of all, we need to define two new counters:Then we need two new column types:
Now let's check out the code (again this is only the crucial part):
that will give us:
As you can see, what we got is quite similar to the implemented
enumerate
environment we previously have, and this time we also have nice vertical alignment. However, this method still has some imperfections, for instances:seqsplit
I don't quite understand.\topsep
is from thelist
environment. I tried to put it into column definition with\ifnum
but failed :P216.46775pt
is manually calculated0.5\linewidth-\columnsep
, I don't know how to makecalc
work inside a table so I didn't use it.et cetera et cetera.