exam-mdframed:将特定数量的点分布在特定长度上并使其居中

exam-mdframed:将特定数量的点分布在特定长度上并使其居中

后续行动这个答案, 我想:

1-指定点分布的长度

2- 除了控制左边距和右边距跳过之外,还将它们居中。

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

在此处输入图片描述

答案1

我认为\centering\vspace命令对您有帮助。希望我理解正确。

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

相关内容