两种字体大小和 \xdef

两种字体大小和 \xdef

我需要图表内的\large和字体来让孩子们练习,比如说,加一个负数与减一个正数是一样的。\hugeTikZ

不幸的是,字体大小命令似乎无法在\xdef放置它们的命令中存活下来。

我正在尝试创建 MWE,但做起来非常困难...有人可以在没有 MWE 的情况下回答这个问题吗?我会继续研究 MWE,直到/除非有人能解决这个问题...


编辑:这实际上不是一个最低限度有效的示例,但是它有错误...我将其包含在评论中\makeatletter并按照建议执行。\protected@xdef

https://www.sharelatex.com/project/59f9f7ad53d7fe35b052e16b


编辑2:我想我可能已经把问题隔离在我的新帖子


或者

\documentclass{article}


\usepackage[margin=2cm]{geometry}
\usepackage{pgffor}
 \pgfmathsetseed{\number\pdfrandomseed}
\usepackage{tikz}


%BLANK VARIABLE STUFF
\newcommand{\Operator}{}
\newcommand{\Sign}{}
\newcommand{\Simplified}{}


\newcommand{\InitVariables}
{%
\pgfmathrandominteger{\Type}{1}{4}
\ifcase\Type\relax
 \or    \renewcommand{\Operator}{+}
        \renewcommand{\Sign}{+}
        \renewcommand{\Simplified}{+}
 \or    \renewcommand{\Operator}{+}
        \renewcommand{\Sign}{-}
        \renewcommand{\Simplified}{-}
 \or    \renewcommand{\Operator}{-}
        \renewcommand{\Sign}{+}
        \renewcommand{\Simplified}{-}
 \or    \renewcommand{\Operator}{-}
        \renewcommand{\Sign}{-}
        \renewcommand{\Simplified}{+}
\fi
\pgfmathrandominteger{\Magnitude}{1}{20}
\pgfmathrandominteger{\MagnitudeWithZero}{0}{20}
\pgfmathsetmacro{\NegativeMagnitudeWithZero}{int(-1*\MagnitudeWithZero)}
\pgfmathrandominteger{\VariedSignAndBracketType}{1}{16}
}


\newcommand{\fewer}
 {\draw[blue] (-2.2,-1) rectangle( -1.1,-1.6);}
\newcommand{\more}
 {\draw[blue] (-2.2,-1) rectangle (-1.1,-0.5);}
\newcommand{\gains}
 {\draw[blue] (-1,-1) rectangle (0.2,-0.5);}
\newcommand{\losses}
 {\draw[blue] (-1,-1) rectangle (0.2,-1.6);}
\newcommand{\good}
 {\draw[blue] (1.2,-1) rectangle (2.3,-0.5);}
\newcommand{\bad}
 {\draw[blue] (1.2,-1) rectangle (2.3,-1.6);}


%MORE BLANK VARIABLE STUFF
\newcommand{\TwoSignsExercise}{}
\newcommand{\TwoSignsSolution}{}

\newcommand{\TwoSignsGenerator}
{%
\InitVariables
\renewcommand{\TwoSignsExercise}
{%
\begin{tikzpicture}
\node[anchor=center] at (-1.35,0) {\huge $\Operator$};
\node[anchor=center] at (0,0) {\huge $(\Sign)=$};
\draw[dashed, thick] (1.3,-0.4) rectangle (2.3,0.6);
\node[anchor=center] at (-1.6,-0.8) {\large more};
\node[anchor=center] at (-1.6,-1.3) {\large fewer};
\node[anchor=center] at (-0.4,-0.8) {\large gains};
\node[anchor=center] at (-0.4,-1.3) {\large losses};
\node[anchor=center] at (0.6,-1.05) {\large is};
\node[anchor=center] at (1.8,-0.8) {\large good};
\node[anchor=center] at (1.8,-1.3) {\large bad};
\end{tikzpicture}
}
%
\renewcommand{\TwoSignsSolution}
{%
\begin{tikzpicture}
\ifcase\Type\relax
 \or \more \gains \good
 \or \more \losses \bad
 \or \fewer \gains \bad
 \or \fewer \losses \good
\fi
\node[anchor=center] at (-1.35,0) {\huge $\Operator$};
\node[anchor=center] at (0,0) {\huge $(\Sign)=$};
\draw[dashed, thick] (1.3,-0.4) rectangle (2.3,0.6);
\node[anchor=center, blue] at (1.8,0) {\huge {$\Simplified$}};
\node[anchor=center] at (-1.6,-0.8) {\large more};
\node[anchor=center] at (-1.6,-1.3) {\large fewer};
\node[anchor=center] at (-0.4,-0.8) {\large gains};
\node[anchor=center] at (-0.4,-1.3) {\large losses};
\node[anchor=center] at (0.6,-1.05) {\large is};
\node[anchor=center] at (1.8,-0.8) {\large good};
\node[anchor=center] at (1.8,-1.3) {\large bad};
\end{tikzpicture}
}
}

\makeatletter

\newcommand{\ManyTwoSignsSolutions}{}

\newcommand{\ManyTwoSignsExercises}
{%
 \foreach \x in {1,...,10}
  {%
   \TwoSignsGenerator \TwoSignsExercise \vskip 0.25cm
   \protected@xdef\ManyTwoSignsSolutions{\ManyTwoSignsSolutions \TwoSignsSolution}
  }
}


\setlength{\parindent}{0em}




\begin{document}

\section*{Exercises}

\ManyTwoSignsExercises

\section*{Solutions}

\ManyTwoSignsSolutions

\end{document}

相关内容