0

Following-up this answer, I would like to:

1- specify the length over which the dots are spread

2- and center them in addition to controlling both the left and right margin skips.

\documentclass{exam}

\makeatletter
\newcount\my@repeat@count
\newcommand{\myrepeat}[2]{%
  \begingroup
  \my@repeat@count=\z@
  \@whilenum\my@repeat@count<#1\do{#2\advance\my@repeat@count\@ne}%
  \endgroup
}
\makeatother

\newcount\myloopcounter

\newcommand{\repeatit}[2][10]{%
  \myloopcounter0% initialize the loop counter
  \loop\ifnum\myloopcounter < #1 % Test if the loop counter is < #1
  #2%
  \advance\myloopcounter by 1 % 
  \repeat % start again
}

\usepackage{mdframed}
\newenvironment{mymdf}
  {\mdfsetup{
    innertopmargin=15pt   
    }
  \begin{mdframed}%
  }  
  {\end{mdframed}}



\begin{document}

\begin{questions}

\question Question
\begin{mymdf}
\repeatit[3]{\myrepeat{150}{.}\\} %3 row, 150 dot per row.
\end{mymdf}

\end{questions}
\end{document}

enter image description here

1 Answer 1

1

I think the \centering and the \vspace commands helps you. I hope I understand you right.

\documentclass[answers]{exam}

\makeatletter
\newcount\my@repeat@count
\newcommand{\myrepeat}[2]{%
  \begingroup
  \my@repeat@count=\z@
  \@whilenum\my@repeat@count<#1\do{#2\advance\my@repeat@count\@ne}%
  \endgroup
}
\makeatother

\newcount\myloopcounter

\newcommand{\repeatit}[2][10]{%
  \myloopcounter0% initialize the loop counter
  \loop\ifnum\myloopcounter < #1 % Test if the loop counter is < #1
  #2%
  \advance\myloopcounter by 1 % 
  \repeat % start again
}

\usepackage{mdframed}

\newenvironment{mymdf}
  {\mdfsetup{
  innertopmargin=15pt 
  }
  \begin{mdframed}%
    }  
  {\end{mdframed}}



\begin{document}

\begin{questions}

\question Approximate $\displaystyle \int_0^1 \sin x^2 \, dx$ within $.001$ of
its true value.
\begin{mymdf}
\centering
\repeatit[5]{\myrepeat{90}{.}\\} %3 row, 150 dot per row.
\end{mymdf}

\question A question with a long solution.
\begin{mymdf}
\centering
\vspace{10mm}
\repeatit[10]{\myrepeat{130}{.}\\} %10 row, 150 dot per row.
\vspace{10mm}
\end{mymdf}


\end{questions}
\end{document}
1
  • Thanks for your answer. You are near to what I mean; in order to understand what I want, you can replace the number of dots in the second question with 200, then you will find them overflow out of the box right border. So, what I need is, regardless of the number of the dots, I need them to be equally spaced over the box width minus the margin skip.
    – Diaa
    Aug 31, 2018 at 21:45

You must log in to answer this question.

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