为了给我的数学课生成大量的练习表,我想将问题设置在网格中,以便孩子们有一个给定的结构来添加他们的计算。
来自 Gonzalo Medina 的回答的相当大代码块的示例更改xlop包中的显示样式
\documentclass{article}
\usepackage[german]{babel}
\usepackage[]{xlop}
%% this part is from
%% https://tex.stackexchange.com/questions/110050/change-display-style-in-xlop-package
%% Answer by Gonzalo Medina
\makeatletter
\def\op@divdisplayone{%
\begingroup
\op@count@z=\z@\relax
\op@count@i=\OP@a@w
\loop
\ifnum\@nameuse{OP@a@\the\op@count@i}=0
\advance\op@count@i by-1
\advance\op@count@z by1
\repeat
\op@count@i=\op@firstlength
\advance\op@count@i by\op@count@z
\xdef\op@firstlength{\the\op@count@i}%
\setbox2=\vbox{%
\op@count@i=\op@firstlength
\advance\op@count@i by1
\hbox{%
\ifx\op@displayintermediary\op@string@none\else
% add 0.25
\ifx\op@displayintermediary\op@string@None\else
% end add 0.25
\kern\opcolumnwidth
\advance\op@count@i by1
% add 0.25
\fi
% end add 0.25
\fi
\ifop@dividendbridge
\vrule width0pt depth0pt height\oplineheight
\opvline(0,1){0.4}%
\ophline(0,1){\op@firstlength}%
\opvline(\op@firstlength,1){0.4}%
\fi
\op@display{operandstyle.1}{a}%
\ifnum\op@shift=0\relax\else
\op@count@v=\op@shift
\advance\op@count@v by\OP@a@d
\oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
\fi
}%
\op@count@z=\OP@q@w
\op@count@ii=1\relax
\ifx\op@displayintermediary\op@string@none
\advance\op@count@i by-1\relax
% add 0.25
\else\ifx\op@displayintermediary\op@string@None
\advance\op@count@i by-1\relax
% end add 0.25
\else
\op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
\op@count@iii=\op@count@i
\advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
\hbox{%
% \ifx\op@voperator\op@string@center
% \oplput(0,0.5){\op@subsymbol}%
% \else\ifx\op@voperator\op@string@top
% \oplput(0,1){\op@subsymbol}%
% \else
\oplput(0,0){\op@subsymbol}%
% \fi\fi
\ophline(1,-0.25){\op@firstlength}%
\advance\op@count@ii by1
\kern\op@count@iii\opcolumnwidth
\op@display{intermediarystyle.1}%
{T\the\op@count@iv}%
}%
% modif 0.25
\fi\fi
% end modif 0.25
{\global\setbox4=\hbox{}\setbox4=\box4}%
\loop
\advance\op@count@z by-1
\advance\op@count@i by1\relax
\ifnum\op@count@z>0\relax
\op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
\ifnum\op@count@iv=0
\ifx\op@displayintermediary\op@string@all
\op@count@v=\op@count@i
\advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
\hbox{%
\kern\op@count@v\opcolumnwidth
\op@display{remainderstyle.\the\op@count@ii}%
{R\the\op@count@ii}%
}%
\op@count@iii=\op@count@i
\advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
\hbox{%
\kern\op@count@v\opcolumnwidth
% \ifx\op@voperator\op@string@center
% \oplput(-1,0.5){\op@subsymbol}%
% \else\ifx\op@voperator\op@string@top
% \oplput(-1,1){\op@subsymbol}%
% \else
\oplput(-1,0){\op@subsymbol}%
% \fi\fi
\ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
\kern-\op@count@v\opcolumnwidth
\kern\op@count@iii\opcolumnwidth
\op@display{intermediarystyle.\the\op@count@ii}%
{T\the\op@count@iv}%
}%
\else
\ifnum\@nameuse{OP@R\the\op@count@ii @w}=2
\ifnum\@nameuse{OP@R\the\op@count@ii @2}=0
\op@makebox{1}{0}{remainderstyle.\the\op@[email protected]}{zero}%
\setbox4=\hbox to\opcolumnwidth{\hss\box0\hss}%
\fi
\fi
\fi
\advance\op@count@ii by1\relax
\else
\op@count@v=\op@count@i
\advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
\ifvoid4\relax\else
\advance\op@count@v by-1
\fi
\hbox{%
\kern\op@count@v\opcolumnwidth\copy4
\op@display{remainderstyle.\the\op@count@ii}%
{R\the\op@count@ii}%
}%
\advance\op@count@ii by1\relax
\ifx\op@displayintermediary\op@string@none
% add 0.25
\else\ifx\op@displayintermediary\op@string@None
% end add 0.25
\else
\op@count@iii=\op@count@i
\advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
\hbox{%
\kern\op@count@v\opcolumnwidth
% \ifx\op@voperator\op@string@center
% \oplput(-1,0.5){\op@subsymbol}%
% \else\ifx\op@voperator\op@string@top
% \oplput(-1,1){\op@subsymbol}%
% \else
\oplput(-1,0){\op@subsymbol}%
% \fi\fi
\advance\op@count@ii by-1
\ifvoid4\relax
\ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
\else
\ophline(0,-0.25){\@nameuse{OP@T\the\op@count@iv @w}}%
\ophline(\@nameuse{OP@T\the\op@count@iv @w},-0.25){1}%
{\setbox4=\box4}%
\fi
\advance\op@count@ii by1
\kern-\op@count@v\opcolumnwidth
\kern\op@count@iii\opcolumnwidth
\op@display{intermediarystyle.\the\op@count@ii}%
{T\the\op@count@iv}%
}%
% modif 0.25
\fi\fi
% end modif 0.25
\fi
\repeat
\advance\op@count@i by-1
\op@count@iii=\op@count@i
\advance\op@count@iii by-\@nameuse{OP@R\the\op@count@ii @w}%
\hbox{%
\kern\op@count@iii\opcolumnwidth
\op@display{remainderstyle.\the\op@count@ii}%
{R\the\op@count@ii}%
}%
}%
\setbox3=\vbox{%
\op@count@v=\op@max{\OP@qq@w}{\OP@b@w}
\hbox{%\ophline(-0.5,-0.25){\the\op@[email protected]}%
\op@display{operandstyle.2}{b}%
\ifnum\op@shift=0\relax\else
\op@count@v=\op@shift
\advance\op@count@v by\OP@b@d
\oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
\fi}
%\hbox{XXX\op@display{resultstyle}{qq}}
}%
\dimen0=\ht2
\ifdim\dimen0>\ht3
\ht3=\ht2
\else
\ht2=\ht3
\fi
\ifx\op@voperation\op@string@top
\dimen0=\ht2
\advance\dimen0 by-0.5\oplineheight
\ht2=0.75\oplineheight
\ht3=0.75\oplineheight
\dp2=\dimen0
\dp2=\dimen0
\fi
\setbox1=\hbox{%
\box2
\kern0.5\opcolumnwidth
\kern-0.5\op@hrulewidth
\ifx\voperation\op@string@top
KKK\vrule width\op@hrulewidth
\else
: %\vrule width\op@hrulewidth :@:
\fi
\kern0.5\opcolumnwidth
\kern-0.5\op@hrulewidth
\box3
= \hbox{\op@display{resultstyle}{qq}}
}%
\ifx\op@voperation\op@string@center
\setbox1=\hbox{$\vcenter{\box1}$}%
\fi
\leavevmode\box1
\endgroup
}
\makeatother
\opset{divsymbol={$\colon$}}
\newcommand\hole[1]{\texttt{\_}}
\usepackage{tikz}
\newcommand{\karos}[2]{
\begin{tikzpicture}
\draw[step=0.5cm,color=gray] (0,0) grid (#1 cm ,#2 cm);
\end{tikzpicture}
}
%% here is my sample
\begin{document}
I'd like to set this
$$154548 \colon 86 =$$
so that each numeral uses one cell of the grid starting top--left
\karos{9}{5} % Karos der Breite 8cm und Höhe 3cm
so the kids can fill out the whole calculation:
\opidiv[voperation=top,displayintermediary=all,maxdivstep=30]{154548}{86}
\end{document}
我想这样设置
\karos{8}{5}{154548 \colon 86 =}
因此我可以用一系列相同的命令生成大量的练习表(我打算使用随机数生成器编写一个 shell 或 perl 脚本来完成这项任务)。
答案1
感谢史蒂文,我找到了一个很好的解决方案。
我减少了在如何将字符(数字)放入方格纸中?满足我的需要:
\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen}
\newcounter{gridypos}
\newenvironment{squaredpaper}[3][.5cm]{\obeyspaces%
\setcounter{gridypos}{#3}
\newcommand\gridtext[1]{
\node[anchor=west,black] at (0,0) [yshift=\value{gridypos}*#1-.5*#1]%
{%
\hspace{-.25\dimexpr#1\relax}%
\spaceout{#1}{##1}%
};
\addtocounter{gridypos}{-1}%Next \gridtext one line lower
}
% Make the grid
% Source: http://texwelt.de/wissen/fragen/2639/wie-kann-ich-kastchenpapier-zeichnen
\begin{tikzpicture}[gray,step=#1]
\draw (0,0) rectangle (#2*#1,#3*#1) (0,0) grid (#2*#1,#3*#1);
}{
\end{tikzpicture}
}
\newcommand\spaceout[2]{\def\charwd{#1}\spaceouthelp#2\relax\relax\relax}
\def\spaceouthelp#1#2\relax{%
\ifx#1\relax\else%
\makebox[\charwd]{#1}%
\spaceouthelp#2\relax%
\fi%
}
\newcommand{\Aufgabe}[3]{
\begin{squaredpaper}{#1}{#2}
\gridtext{#3}
\end{squaredpaper}
}
\begin{document}
\ttfamily%\scriptsize% WILL WORK IF UNCOMMENTED
\Aufgabe{16}{10}{154548{$\colon$}86=}
\end{document}
一旦我弄清楚了,数学模式只有在拥抱时才会起作用并且必须适合一个单元格,这就很容易了。
感谢您提供这个快速的解决方案。
它看起来是这样的:
\Aufgabe{16}{10}{154548{$\colon$}86=}