我如何才能在考试班上在线

我如何才能在考试班上在线

我需要画一条水平线来表示答案。这是 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

您可以修改\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

或使用xpatch

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

完整代码:

\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}

在此处输入图片描述

答案2

\hrulefill可以用来达到预期的效果

相关内容