将代码拆分到工作表中的单独页面上

将代码拆分到工作表中的单独页面上

我试图将以下代码分成 3 个独立的页面,其中第一页是问题,第二页是工作内容,第三页是答案。但我似乎只能将这三页放在连续的行上。

\documentclass{article}
%AdditionCode
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{tikz}
\pgfmathsetseed{\number\pdfrandomseed}
\usepackage{xlop}

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{~\\56 Problem Practice Worksheet}
\rhead{Name: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \\}
\lfoot{Number Correct: ~ \Large $\dfrac{~}{20}$}
\cfoot{~}


\newcommand*{\DifficultyOne}{999}%
\newcommand*{\DifficultyTwo}{99}%
%---------------------------------------%
\newcommand{\AddQuestion}[1]{%
    \foreach \i in {1,...,#1}{%

  \pgfmathtruncatemacro{\AddOnea}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwoa}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOneb}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwob}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOnec}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwoc}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOned}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwod}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOnee}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwoe}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOnef}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwof}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOneg}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwog}{random(\DifficultyTwo)}
  \pgfmathtruncatemacro{\AddOneh}{random(\DifficultyOne)}%
  \pgfmathtruncatemacro{\AddTwoh}{random(\DifficultyTwo)}

  \hspace*{\fill}
  \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOnea} {\AddTwoa} \hfill  \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOneb}{\AddTwob} \hfill \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOnec}{\AddTwoc} \hfill \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOned}{\AddTwod} \hfill \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOnee}{\AddTwoe} \hfill \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOnef}{\AddTwof} \hfill \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOneg}{\AddTwog} \hfill \opadd[carryadd=false, voperator=bottom, resultstyle=\color{white}]{\AddOneh}{\AddTwoh}  \hspace*{\fill}\\
  ~\newline
  ~\newline
  
   \hspace*{\fill}
  \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOnea} {\AddTwoa} \hfill  \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOneb}{\AddTwob} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOnec}{\AddTwoc} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOned}{\AddTwod} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOnee}{\AddTwoe} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOnef}{\AddTwof} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOneg}{\AddTwog} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{white}]{\AddOneh}{\AddTwoh}  \hspace*{\fill}\\
  ~\newline
  ~\newline
  
   \hspace*{\fill}
  \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOnea} {\AddTwoa} \hfill  \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOneb}{\AddTwob} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOnec}{\AddTwoc} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOned}{\AddTwod} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOnee}{\AddTwoe} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOnef}{\AddTwof} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOneg}{\AddTwog} \hfill \opadd[carryadd=true, voperator=bottom, resultstyle=\color{black}]{\AddOneh}{\AddTwoh}  \hspace*{\fill}\\
  ~\newline
  ~\newline

    }%
    }%

    \begin{document}

    \vspace{2cm}

    \AddQuestion{5}

    \end{document}

我尝试过 minipage,但没有成功

答案1

更新

尝试一下这个代码。

代码经过简化以避免重复。每行 8 个问题由 生成;

\OneXLine{<true or false>}{<result color>}

第一个参数控制进位(真或假);第二个参数控制答案的颜色。

完成 n 行 x 8 个问题/工作/答案后,将发布新页面。

每个问题使用的数字都是随机的,但是通过为每组选择相同的种子,可以在“工作”和“答案”中重复使用相同的数字。

要制作一组不同的工作表,需要将一个整数添加到种子中,用于标识构建。作为参考,该数字打印在右侧页脚中。

如果需要的话,这允许在以后的场合重现相同的构建。

d

% !TeX TS-program = pdflatex

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{tikz}
    
\usepackage{xlop}

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{~\\48 Problem Practice Worksheet}
\rhead{Name: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \\}
\lfoot{Number Correct: ~ \Large $\dfrac{~}{48}$}
\cfoot{~}
\rfoot{Ref:~\theRandSeed}% identify the worksheet <<<<<
    
\newcommand*{\DifficultyOne}{999}%
\newcommand*{\DifficultyTwo}{99}%

\newcounter{RandSeed}       
\setcounter{RandSeed}{6} % choose an integer random seed for this build of problems and answers <<<<<   

%%  \OneXLine{<true or false>}{<result color>}  
\newcommand{\OneXline}[2]{% one line of 8 problems, workings or answers
\hspace*{\fill}
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOnea} {\AddTwoa} \hfill
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOneb}{\AddTwob} \hfill
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOnec}{\AddTwoc} \hfill
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOned}{\AddTwod} \hfill
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOnee}{\AddTwoe} \hfill 
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOnef}{\AddTwof} \hfill 
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOneg}{\AddTwog} \hfill
\opadd[carryadd=#1, voperator=bottom, resultstyle=\color{#2}]{\AddOneh}{\AddTwoh}
\hspace*{\fill}\\
}

\newcommand{\GenerateRandom}{%  %   \GenerateRandom
\pgfmathtruncatemacro{\AddOnea}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwoa}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOneb}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwob}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOnec}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwoc}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOned}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwod}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOnee}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwoe}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOnef}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwof}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOneg}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwog}{random(\DifficultyTwo)}
\pgfmathtruncatemacro{\AddOneh}{random(\DifficultyOne)}%
\pgfmathtruncatemacro{\AddTwoh}{random(\DifficultyTwo)} 
}
    
%---------------------------------------% 
\newcommand{\AddQuestion}[1]{%

    \foreach \i in {1,...,#1}{% 
        \pgfmathsetseed{\i+\value{RandSeed}}
        \GenerateRandom
        \OneXline{false}{white}
        ~\newline
        ~\newline
    }
    
    \newpage% added <<<<<<<<<<      
    
    \foreach \i in {1,...,#1}{%
        \pgfmathsetseed{\i+\value{RandSeed}}
        \GenerateRandom
        \OneXline{true}{white}  
        ~\newline
    }
    \newpage% added <<<<<<<<<<          
    
    \foreach \i in {1,...,#1}{%
        \pgfmathsetseed{\i+\value{RandSeed}}
        \GenerateRandom
        \OneXline{true}{black}
        ~\newline
    }%
}%

\begin{document}
    \AddQuestion{6}     % 6 lines of 10 problems
\end{document}

相关内容