1

I created Database of questions in LaTeX using datatool (named nayi17n-ii) as shown below

\DTLnewdb{CS2}
\long\def\newproblem#1#2#3#4#5#6#7#8#9{%
  \DTLnewrow{CS2}%
  \DTLnewdbentry{CS2}{seq}{#1}%
  \DTLnewdbentry{CS2}{yr}{#2}%
  \DTLnewdbentry{CS2}{sub}{#3}%
  \DTLnewdbentry{CS2}{top}{#4}%
 \DTLnewdbentry{CS2}{mar}{#5}%
\DTLnewdbentry{CS2}{qus}{#6}%
\DTLnewdbentry{CS2}{url}{#7}%
\DTLnewdbentry{CS2}{exp}{#8}%
\DTLnewdbentry{CS2}{ans}{#9}%
}

\newproblem{1}{2017-ii}{DE}{number}{1}{{The representation of the value of a 16-bit unsigned integer $X$ in hexadecimal number system is BCA9. The representation of the value of $X$ in octal number system is}\\
(A)571244\\
(B)736251\\
(C)571247\\
(D)136251\\
\hspace*{\fill} GATE 2017-II,1 MARK\\}{\url{http://gatefreaks.com/index.php?qa=9446&qa_1=de-gate-2017-2-1}}{$( BCA9)_{16}=(1011 \ 1100 \ 1010 \ 1001)_2$\\
   =$(001 \ 011 \ 110 \ 010 \ 101 \ 001)_2 = (136251)_8$.}{Ans:d}


\newproblem{2}{2017-ii}{C}{fun}{1}{{Match the following:}\\
\begin{tabular}{|p{0.05in}|p{0.85in}|p{0.05in}|p{1.5in}|p{0.15in}|p{1.0in}|p{1.0in}}
  \hline
P.& static char var;    &i.& Sequence of memory locations to store addresses\\ \hline
Q.& m=malloc(10); m=NULL;&  ii.& A variable located in data section of memory\\ \hline
R.& char *ptr[10];  &iii.& Request to allocate a CPU register to store data\\ \hline
S.& register int varl;  &iv.& A lost memory which cannot be freed\\
  \hline
\end{tabular}\\
(A)P-ii; Q-iv; R-i; S-iii\\
(B)P-ii; Q-i; R-iv; S-iii\\
(C)P-ii; Q-iv; R-iii; S-i\\
(D)P-iii; Q-iv; R-i; S-ii\\
\hspace*{\fill} GATE 2017-II,1 MARK\\}{\url{http://gatefreaks.com/index.php?qa=9447&qa_1=c-gate-2017-2-2}}{static char var = A: variable located in data section of memory.\\
m= malloc(10); m= null : A lost memory which cannot be freed because memory location m is not being freed.\\
Char *Ptr[10]: Sequence of  memory locations to store addresses, it can store 10 addresses.\\
register int var1 :register storage class is used so request to alloacte a CPU register to store data\\
Option a is correct.\\
}{Ans:a}

I was compiling this database from another file having content as:

\documentclass[10pt,twocolumn]{book}
\usepackage{layouts}
\usepackage{longdata}
\usepackage{url}
\usepackage{bm}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{scalerel}
\usepackage{stackengine}
\input{nayi17n-ii.tex}
\begin{document}

\begin{enumerate}
\DTLforeach[\DTLisclosedbetween{\seq}{1}{100}]%
           {CS2}%
           {\seq=seq,\yr=yr,\sub=sub, \top=top, \mar=mar,\qus=qus, \ans=ans}%
          {\DTLifstringeq{\yr}{2017-ii} { \item \qus }{}}
\end{enumerate}\end{document}

It was working fine but I reinstalled protext and tried to compile these files again but now it is not working properly and showing error. Any file related to datatool is not working and showing the same error.

......
"C:\Program Files\MiKTeX 2.9\tex\latex\ltxmisc\varwidth.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\url\url.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\tools\bm.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\fancyvrb\fancyvrb.sty"
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
<2008/02/07> (tvz))
("C:\Program Files\MiKTeX 2.9\tex\latex\fancyhdr\fancyhdr.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\tools\multicol.sty"

Package multicol Warning: May not work with the twocolumn option on input line 
134.
) ("C:\Program Files\MiKTeX 2.9\tex\latex\draftwatermark\draftwatermark.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\everypage\everypage.sty")) (ocgx.sty
(ocg-p.sty ("C:\Program Files\MiKTeX 2.9\tex\latex\eso-pic\eso-pic.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\atbegshi.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty")))))
("C:\Program Files\MiKTeX 2.9\tex\latex\titlesec\titlesec.sty") (scalerel.sty)
(stackengine.sty (listofitems.sty (listofitems.tex))) (nayi17n-ii.tex
! Undefined control sequence.
<argument> ...l@datatype }\fi \toks@gput@right@cx 
                                                  {dtlkeys@CS2}{\noexpand \d...
l.40 }{Ans:a}

? 

1 Answer 1

3

What should your used package longdata do?

After loading package datatool and combining both given codes to one MWE I can compile without errors ...

See the MWE

\documentclass[10pt,twocolumn]{book}
\usepackage{layouts}
%\usepackage{longdata}
\usepackage{datatool} % <===============================================
\usepackage{url}
\usepackage{bm}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{scalerel}
\usepackage{stackengine}

\DTLnewdb{CS2}
\long\def\newproblem#1#2#3#4#5#6#7#8#9{%
  \DTLnewrow{CS2}%
  \DTLnewdbentry{CS2}{seq}{#1}%
  \DTLnewdbentry{CS2}{yr}{#2}%
  \DTLnewdbentry{CS2}{sub}{#3}%
  \DTLnewdbentry{CS2}{top}{#4}%
 \DTLnewdbentry{CS2}{mar}{#5}%
\DTLnewdbentry{CS2}{qus}{#6}%
\DTLnewdbentry{CS2}{url}{#7}%
\DTLnewdbentry{CS2}{exp}{#8}%
\DTLnewdbentry{CS2}{ans}{#9}%
}

\newproblem{1}{2017-ii}{DE}{number}{1}{{The representation of the value of a 16-bit unsigned integer $X$ in hexadecimal number system is BCA9. The representation of the value of $X$ in octal number system is}\\
(A)571244\\
(B)736251\\
(C)571247\\
(D)136251\\
\hspace*{\fill} GATE 2017-II,1 MARK\\}{\url{http://gatefreaks.com/index.php?qa=9446&qa_1=de-gate-2017-2-1}}{$( BCA9)_{16}=(1011 \ 1100 \ 1010 \ 1001)_2$\\
   =$(001 \ 011 \ 110 \ 010 \ 101 \ 001)_2 = (136251)_8$.}{Ans:d}


\newproblem{2}{2017-ii}{C}{fun}{1}{{Match the following:}\\
\begin{tabular}{|p{0.05in}|p{0.85in}|p{0.05in}|p{1.5in}|p{0.15in}|p{1.0in}|p{1.0in}}
  \hline
P.& static char var;    &i.& Sequence of memory locations to store addresses\\ \hline
Q.& m=malloc(10); m=NULL;&  ii.& A variable located in data section of memory\\ \hline
R.& char *ptr[10];  &iii.& Request to allocate a CPU register to store data\\ \hline
S.& register int varl;  &iv.& A lost memory which cannot be freed\\
  \hline
\end{tabular}\\
(A)P-ii; Q-iv; R-i; S-iii\\
(B)P-ii; Q-i; R-iv; S-iii\\
(C)P-ii; Q-iv; R-iii; S-i\\
(D)P-iii; Q-iv; R-i; S-ii\\
\hspace*{\fill} GATE 2017-II,1 MARK\\}{\url{http://gatefreaks.com/index.php?qa=9447&qa_1=c-gate-2017-2-2}}{static char var = A: variable located in data section of memory.\\
m= malloc(10); m= null : A lost memory which cannot be freed because memory location m is not being freed.\\
Char *Ptr[10]: Sequence of  memory locations to store addresses, it can store 10 addresses.\\
register int var1 :register storage class is used so request to alloacte a CPU register to store data\\
Option a is correct.\\
}{Ans:a}


\begin{document}

\begin{enumerate}
\DTLforeach[\DTLisclosedbetween{\seq}{1}{100}]%
           {CS2}%
           {\seq=seq,\yr=yr,\sub=sub, \top=top, \mar=mar,\qus=qus, \ans=ans}%
          {\DTLifstringeq{\yr}{2017-ii} { \item \qus }{}}
\end{enumerate}
\end{document}

giving the result (without errors):

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .