1

I need to draw an horizontal line for the answer. Here is MWE

\documentclass{exam}
\usepackage{multicol}
\begin{document}

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
OPD ENCOUNTER FORM}}}
\end{center}
\vspace{0.1in}

\makebox[\textwidth]{Name :\enspace\hrulefill}
\begin{multicols}{2}
\vspace{0.2in}
\makebox[0.45\textwidth]{Age:\enspace\hrulefill}
\makebox[0.5\textwidth]{Sex:\enspace\hrulefill}
\end{multicols}
\makebox[\textwidth]{Address:\enspace\hrulefill}

\begin{multicols}{2}
\makebox[0.45\textwidth]{City: \enspace\hrulefill}
\makebox[0.45\textwidth]{Ref: \enspace\hrulefill} 
\end{multicols} 
%
%Past and family history 
\section* {Past History}

\begin{questions}

        \question Diabetes Mellitus % here I need a choice box before the word "Diabetes Mellitus"and horizontal line after the word "Diabetes Mellitus" to specify duration in-front of Diabetes Mellitus ........

        \begin{oneparcheckboxes}

                \choice   Nephropathy
                \choice Retinopathy
                \choice Neuropathy
                \choice NASH
                \choice Gastroparesis
         \end{oneparcheckboxes}
         \question Systemic hypertension
\begin{oneparcheckboxes}    
        \choice since    
\end{oneparcheckboxes}
\question 
\begin{oneparcheckboxes}
\choice
\end{oneparcheckboxes}

\end{questions}


\end{document}
1

You can modify \answerline:

\makeatletter
\renewcommand\answerline[1][{}]{%
  % One optional argument, the default value of which is empty.
  \ifx\@queslevel\ques@ref
    \let\ans@l=\questionlabel
  \else
    \ifx\@queslevel\part@ref
      \let\ans@l=\partlabel
    \else
      \ifx\@queslevel\subpart@ref
        \let\ans@l=\subpartlabel
      \else
        \ifx\@queslevel\subsubpart@ref
          \let\ans@l=\subsubpartlabel
        \else
          % Oops; no question level defined.
          % We must be outide of the questions environment.
          % Just leave out the label, I guess:
          \def\ans@l{}%
        \fi
      \fi
    \fi
  \fi
  %\par \nobreak \vskip \answerskip
  \hfill
  \ifprintanswers
    \ans@l~\hbox to 0pt{\hbox to \answerlinelength{\hrulefill}\hss}%
    \raise \answerclearance\hbox to \answerlinelength{%
      \CorrectChoice@Emphasis \hfil #1\hss}%
  \else
    \ans@l~\hbox to \answerlinelength{\hrulefill}%
  \fi
  \par
}% answerline
\makeatother

or use xpatch

\usepackage{xpatch}
\xpatchcmd{\answerline}{\par \nobreak \vskip \answerskip}{}{}{}

Full code:

\documentclass{exam}
\usepackage{multicol}
\usepackage{xpatch}
\xpatchcmd{\answerline}{\par \nobreak \vskip \answerskip}{}{}{}


\begin{document}

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
OPD ENCOUNTER FORM}}}
\end{center}
\vspace{0.1in}

\makebox[\textwidth]{Name :\enspace\hrulefill}
\begin{multicols}{2}
\vspace{0.2in}
\makebox[0.45\textwidth]{Age:\enspace\hrulefill}
\makebox[0.5\textwidth]{Sex:\enspace\hrulefill}
\end{multicols}
\makebox[\textwidth]{Address:\enspace\hrulefill}

\begin{multicols}{2}
\makebox[0.45\textwidth]{City: \enspace\hrulefill}
\makebox[0.45\textwidth]{Ref: \enspace\hrulefill}
\end{multicols}
%
%Past and family history
\section* {Past History}

\begin{questions}

        \question Diabetes Mellitus \answerline

        \begin{oneparcheckboxes}
                \choice   Nephropathy
                \choice Retinopathy
                \choice Neuropathy
                \choice NASH
                \choice Gastroparesis
         \end{oneparcheckboxes}


         \question Systemic hypertension
\begin{oneparcheckboxes}
        \choice since
\end{oneparcheckboxes}
\answerline

\question
\begin{oneparcheckboxes}
\choice
\end{oneparcheckboxes}
\answerline

\end{questions}


\end{document}

enter image description here

3
  • But with oneparcheckboxes answer line is meaningless! – user11232 Nov 28 '14 at 10:28
  • Answerline prints the line below. I need it "in-line" like Diabetes Mellitus __________________ – Vaibhav Nov 28 '14 at 10:42
  • @Vaibhav I missed that bit. Now updated. – user11232 Nov 28 '14 at 10:54
0

\hrulefill can be used to get the desired effect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.