在薛定谔猫的帮助下,我能够创建一个制作立方体块棱镜的宏。我还希望能够在宏中启动宽度、高度、深度的定义,以便继续在表格中进行计算。我不能把表格放在宏中,因为我并不总是需要计算(对于学生来说它是空白的)
这是我的代码:
\documentclass[12pt]{examdesign}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{tikz,ifthen,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all} %%%because I'm using overleaf
\usetikzlibrary{quotes,angles,decorations}
\usetikzlibrary{shapes.geometric,calc}
\class{Needed for examdesign}
%%%%%%%%%%%%%%%%%%%%%% tikz set for cube%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\cubelength}{0.93}
\tikzset{
cube/.pic={
\draw[] (0,0,0) -- (0,\cubelength,0) -- (\cubelength,\cubelength,0) -- (\cubelength,0,0) -- cycle;
%draw the back-right of the cube
\draw[] (0,0,0) -- (0,\cubelength,0) -- (0,\cubelength,\cubelength) -- (0,0,\cubelength) -- cycle;
%draw the back-left of the cube
\draw[] (0,0,0) -- (\cubelength,0,0) -- (\cubelength,0,\cubelength) -- (0,0,\cubelength) -- cycle;
%draw the front-right of the cube
\draw[fill=magenta!50] (\cubelength,0,0) -- (\cubelength,\cubelength,0) -- (\cubelength,\cubelength,\cubelength) -- (\cubelength,0,\cubelength)-- cycle;
%draw the front-left of the cube
\draw[fill=orange!50] (0,\cubelength,0) -- (\cubelength,\cubelength,0) -- (\cubelength,\cubelength,\cubelength) -- (0,\cubelength,\cubelength) -- cycle;
%draw the top of the cube
\draw[fill=cyan!50] (0,0,\cubelength) -- (0,\cubelength,\cubelength) -- (\cubelength,\cubelength,\cubelength) -- (\cubelength,0,\cubelength) -- cycle;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%To draw a cubeblocks object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Macro for Mystery Hypotenuse cubeblocks
\newcommand{\cubeblocks}[2][]{\resizebox{5cm}{!}{
\begin{tikzpicture}[scale=1,#1,
cubeblocks/.cd,w/.initial=1,d/.initial=1,unit/.initial=cm,h/.initial=1]
\tikzset{cubeblocks/.cd,#2}
\newcommand{\Width}{\pgfkeysvalueof{/tikz/cubeblocks/w}}
\newcommand{\Depth}{\pgfkeysvalueof{/tikz/cubeblocks/d}}
\newcommand{\Height}{\pgfkeysvalueof{/tikz/cubeblocks/h}}
\pgfmathsetmacro{\effDepth}{\Depth-1}
\pgfmathsetmacro{\effHeight}{\Height-1}
\pgfmathsetmacro{\effWidth}{\Width-1}
%%%%%draws coordinates
\coordinate (A) at (0,0,0);
\coordinate (B) at (\Width,0,0);
\coordinate (C) at (\Width,0,\Depth);
\coordinate (D) at (0,0,\Depth);
\coordinate (E) at (0,\Height,\Depth);
\coordinate (F) at (0,\Height,0);
\coordinate (G) at (\Width,\Height,0);
\coordinate (H) at (\Width,\Height,\Depth);
\begin{huge}
\draw[<->,blue,>=latex]([xshift=5mm]B)--node[fill=white,xshift=3mm]{$\pgfmathprintnumber\Height\,$\pgfkeysvalueof{/tikz/cubeblocks/unit}}([xshift=5mm]G);
\draw[<->,blue, >=latex]([yshift=-5mm]C)--node[fill=white,yshift=-2mm]{$\pgfmathprintnumber\Width\,$\pgfkeysvalueof{/tikz/cubeblocks/unit}}([yshift=-5mm]D);
\draw[<->,blue]([xshift=5mm,yshift=-2mm]B)--node[xshift=3mm,yshift=-4mm,fill=white]{$\pgfmathprintnumber\Depth\,$\pgfkeysvalueof{/tikz/cubeblocks/unit}}([xshift=5mm,yshift=-2mm]C);
\end{huge}
\foreach \x in {0,...,\effWidth,\effWidth}{
\pgfmathifisint{\x}{\pgfmathsetmacro{\myx}{1}}{\pgfmathsetmacro{\myx}{\x-int(\x))}}
\foreach \y in {0,...,\effHeight,\effHeight}{
\pgfmathifisint{\y}{\pgfmathsetmacro{\myy}{1}}{\pgfmathsetmacro{\myy}{\y-int(\y))}}
\foreach \z in {0,...,\effDepth,\effDepth}{
\pgfmathifisint{\z}{\pgfmathsetmacro{\myz}{1}}{\pgfmathsetmacro{\myz}{\z-int(\z))}}
\path (\x+1-\myx,\y+1-\myy,\z+1-\myz)
pic[z={(-0.5*\myz,-0.5*\myz)},x={(\myx,0)},y={(0,\myy)}] {cube};
}}}
\end{tikzpicture}
}%%%closes tikzpicture
}%%%%closes resize box
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\newcommand{\Width}{3} %%%%
\newcommand{\Height}{5}
\newcommand{\Depth}{4}
%%\cubeblocks{w=3,d=4,h=5,unit=cm}\\
\pgfmathsetmacro{\baselayer}{\Width*\Depth}
\pgfmathsetmacro{\volume}{\baselayer*\Height}
\renewcommand{\arraystretch}{1}
\hspace{-2cm}\begin{tabular}{|p{4cm}|p{4cm}|}
\hline
Base Layer Shape and Dimensions &rectangle \\
\hline
Base Layer Area & $A=$ \\
\hline
Volume of 1 layer & $V=$ \\
\hline
Prism Height & Prism height is \\
\hline
Volume & $\volume\text {cm}^3$ \\
\hline
\end{tabular}
\end{document}
我遇到的问题是,它说命令、宽度、高度和深度已经定义,而我之所以遇到这个问题,是因为我的宏想要再次定义它们。我想知道如何修复我的宏来定义宽度、高度和深度,并让这些定义在特定问题中保留在体积宏中。也许像 Steven 建议的那样,使用\let
和\relax
函数?- 但我不知道该怎么做。
我之所以觉得我必须包含宽度、高度、深度的定义为,如果不这样做,\volume
似乎没有参数,因为我只能猜测,它无法从 cubeblocks 宏中提取这些值(但我确实希望他们从 cubeblocks 宏中提取值)我应该提到,我将针对不同的学生问题使用不同的值重复 cubeblocks 宏。
我不知道该怎么做。总结:1. 使用 cubeblocks 宏 2. 让宏使用\volume
cubeblocks 宏的宽度、深度、高度值 3. 使用正确的范围重复其他问题。
谢谢大家,我也非常感谢大家对我的代码做出的任何建议。
答案1
由于所有操作都发生\cubeblocks
在 中\resizebox
,而 又在某个局部范围内排版一个框,而该框本身也形成一个局部范围,因此如果没有一些全局分配,你就无法摆脱它。
您可以在当前范围/当前组内使用宏进行重新定义/“(重新)初始化” ,并根据键的值 / / :\pgfkeysgetvalue{⟨full key⟩}{⟨macro⟩}
\Width
\Depth
\Height
/tikz/cubeblocks/w
/tikz/cubeblocks/d
/tikz/cubeblocks/h
\pgfkeysgetvalue{/tikz/cubeblocks/w}{\Width}
将(在当前范围/组内)(重新)定义宏\Width
来扩展为形成键值的标记/tikz/cubeblocks/w
。
\pgfkeysgetvalue{/tikz/cubeblocks/d}{\Depth}
将(在当前范围/组内)(重新)定义宏\Depth
来扩展为形成键值的标记/tikz/cubeblocks/d
。
\pgfkeysgetvalue{/tikz/cubeblocks/h}{\Height}
将(在当前范围/组内)(重新)定义宏\Height
来扩展为形成键值的标记/tikz/cubeblocks/h
。
如果您不介意全局重新定义\Width
、\Depth
和\Height
,您可以执行\global\let\Width=\Width
、\global\let\Depth=\Depth
和\global\let\Height=\Height
从限制在当前范围/组的重新定义中进行全局分配 - 全局分配不仅限于当前范围/组,而且适用于所有上级范围/组也。
(分配在执行分配时具有的含义。以 为前缀的结果是分配不仅限于当前范围/组,而且还适用于所有上级范围/组。)\let⟨control-sequence-token⟩=⟨token⟩
⟨control-sequence-token⟩
⟨token⟩
\let
\global
\documentclass[12pt]{examdesign}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{tikz,ifthen,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all} %%%because I'm using overleaf
\usetikzlibrary{quotes,angles,decorations}
\usetikzlibrary{shapes.geometric,calc}
\class{Needed for examdesign}
%%%%%%%%%%%%%%%%%%%%%%%%%%% tikz set for cube%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\cubelength}{0.93}
\tikzset{%
cube/.pic={%
\draw[] (0,0,0) --
(0,\cubelength,0) --
(\cubelength,\cubelength,0) --
(\cubelength,0,0) --
cycle;
% draw the back-right of the cube
\draw[] (0,0,0) --
(0,\cubelength,0) --
(0,\cubelength,\cubelength) --
(0,0,\cubelength) --
cycle;
% draw the back-left of the cube
\draw[] (0,0,0) --
(\cubelength,0,0) --
(\cubelength,0,\cubelength) --
(0,0,\cubelength) --
cycle;
% draw the front-right of the cube
\draw[fill=magenta!50] (\cubelength,0,0) --
(\cubelength,\cubelength,0) --
(\cubelength,\cubelength,\cubelength) --
(\cubelength,0,\cubelength)--
cycle;
% draw the front-left of the cube
\draw[fill=orange!50] (0,\cubelength,0) --
(\cubelength,\cubelength,0) --
(\cubelength,\cubelength,\cubelength) --
(0,\cubelength,\cubelength) --
cycle;
% draw the top of the cube
\draw[fill=cyan!50] (0,0,\cubelength) --
(0,\cubelength,\cubelength) --
(\cubelength,\cubelength,\cubelength) --
(\cubelength,0,\cubelength) --
cycle;
}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%To draw a cubeblocks object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Macro for Mystery Hypotenuse cubeblocks
\newcommand{\cubeblocks}[2][]{%
\resizebox{5cm}{!}{ %<- The empty line yields \par - do you want that?
\begin{tikzpicture}[scale=1,
#1,
cubeblocks/.cd,
w/.initial=1,
d/.initial=1,
unit/.initial=cm,
h/.initial=1
]
\tikzset{cubeblocks/.cd,#2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfkeysgetvalue{/tikz/cubeblocks/w}{\Width}%
\pgfkeysgetvalue{/tikz/cubeblocks/d}{\Depth}%
\pgfkeysgetvalue{/tikz/cubeblocks/h}{\Height}%
\global\let\Width=\Width
\global\let\Depth=\Depth
\global\let\Height=\Height
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfmathsetmacro{\effDepth}{\Depth-1}
\pgfmathsetmacro{\effHeight}{\Height-1}
\pgfmathsetmacro{\effWidth}{\Width-1}
%%%%%draws coordinates
\coordinate (A) at (0,0,0);
\coordinate (B) at (\Width,0,0);
\coordinate (C) at (\Width,0,\Depth);
\coordinate (D) at (0,0,\Depth);
\coordinate (E) at (0,\Height,\Depth);
\coordinate (F) at (0,\Height,0);
\coordinate (G) at (\Width,\Height,0);
\coordinate (H) at (\Width,\Height,\Depth);
\begin{huge}
\draw[<->,blue,>=latex]([xshift=5mm]B)--%
node[fill=white,xshift=3mm]{%
$\pgfmathprintnumber\Height\,$%
\pgfkeysvalueof{/tikz/cubeblocks/unit}%
}([xshift=5mm]G);
\draw[<->,blue, >=latex]([yshift=-5mm]C)--%
node[fill=white,yshift=-2mm]{%
$\pgfmathprintnumber\Width\,$%
\pgfkeysvalueof{/tikz/cubeblocks/unit}%
}([yshift=-5mm]D);
\draw[<->,blue]([xshift=5mm,yshift=-2mm]B)--%
node[xshift=3mm,yshift=-0mm,fill=white]{%
$\pgfmathprintnumber\Depth\,$%
\pgfkeysvalueof{/tikz/cubeblocks/unit}%
}([xshift=5mm,yshift=-2mm]C);
\end{huge} %<- The empty line yields \par - do you want that?
\foreach \x in {0,...,\effWidth,\effWidth}{%
\pgfmathifisint{\x}{%
\pgfmathsetmacro{\myx}{1}%
}{%
\pgfmathsetmacro{\myx}{\x-int(\x))}%
}%
\foreach \y in {0,...,\effHeight,\effHeight}{%
\pgfmathifisint{\y}{%
\pgfmathsetmacro{\myy}{1}%
}{%
\pgfmathsetmacro{\myy}{\y-int(\y))}%
}%
\foreach \z in {0,...,\effDepth,\effDepth}{%
\pgfmathifisint{\z}{%
\pgfmathsetmacro{\myz}{1}%
}{%
\pgfmathsetmacro{\myz}{\z-int(\z))}%
}%
\path (\x+1-\myx,\y+1-\myy,\z+1-\myz)
pic[z={(-0.5*\myz,-0.5*\myz)},x={(\myx,0)},y={(0,\myy)}]
{cube};
}%
}%
}%
\end{tikzpicture}%
}%%%%closes \resizebox
}%%%%closes definition-text
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Scratch-macros for width, height and depth; they get redefined by
% \cubeblocks globally:
\newcommand{\Width}{}
\newcommand{\Height}{}
\newcommand{\Depth}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%\begingroup
\cubeblocks{w=3,d=4,h=5,unit=cm}\\
%\show\Width
%\show\Height
%\show\Depth
%\endgroup
%\show\Width
%\show\Height
%\show\Depth
\pgfmathsetmacro{\baselayer}{\Width*\Depth}%
\pgfmathsetmacro{\volume}{\baselayer*\Height}%
\renewcommand{\arraystretch}{1}%
\hspace{-2cm}%
\begin{tabular}{|p{4cm}|p{4cm}|}
\hline
Base Layer Shape and Dimensions &rectangle \\
\hline
Base Layer Area & $A=$ \\
\hline
Volume of 1 layer & $V=$ \\
\hline
Prism Height & Prism height is \\
\hline
Volume & $\volume\text{cm}^3$ \\
\hline
\end{tabular}
\end{document}
如果您希望\Width
、\Height
和\Depth
仅在当前范围内重新定义,则可以全局定义一个临时宏来在临时宏扩展的范围内重新定义\Width
、\Height
和,然后在重新定义、和的范围内调用该临时宏。\Depth
\Width
\Height
\Depth
\Width
如果这样做,您需要确保、\Height
和的值得\Depth
到正确扩展。
\edef
根据问题的主题,不使用是前提条件。
因此我建议使用\romannunmeral0
-expansion 作为扩展控制的手段。
-expansion的要点\romannunmeral0
是:
\romannueral
工作原理如下:\romannumeral
触发 TeX 将 TeX- 转换⟨number-quantitiy⟩
为类别代码 12(其他)的字符标记序列,以⟨number-quantitiy⟩
小写罗马符号表示所讨论的 TeX-。
如果 TeX “发现” 要转换的数字不是正数(例如数字 0),则构成该 TeX- 的标记⟨number-quantitiy⟩
将被默默“吞掉”,并且不会传递任何标记。
TeX 将在搜索属于相关 TeX 的更多数字⟨number-quantitiy⟩
或终止搜索更多数字的内容时扩展可扩展标记。
与终止搜索更多数字的其他事物不同,终止数字序列的空格标记将被默默丢弃。
所有这些意味着,您可以很好地(ab?)使用\romannumeral
它来触发大量的扩展工作并翻转宏参数,只要确保在完成所有扩展工作之后⟨number-quantitiy⟩
找到一个值不是正值的 TeX- 即可。
我倾向于按如下方式执行此操作:搜索更多数字,从而通过 触发扩展事物\romannumeral0
。完成所有扩展和参数翻转工作后,标记流中的下一个标记将是空格标记。因此会找到非正数 0,从而导致 TeX-⟨number-quantitiy⟩
被默默吞噬,而不会提供标记作为回报。空格标记被丢弃。
\documentclass[12pt]{examdesign}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{tikz,ifthen,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all} %%%because I'm using overleaf
\usetikzlibrary{quotes,angles,decorations}
\usetikzlibrary{shapes.geometric,calc}
\class{Needed for examdesign}
%%%%%%%%%%%%%%%%%%%%%%%%%%% tikz set for cube%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\cubelength}{0.93}
\tikzset{%
cube/.pic={%
\draw[] (0,0,0) --
(0,\cubelength,0) --
(\cubelength,\cubelength,0) --
(\cubelength,0,0) --
cycle;
% draw the back-right of the cube
\draw[] (0,0,0) --
(0,\cubelength,0) --
(0,\cubelength,\cubelength) --
(0,0,\cubelength) --
cycle;
% draw the back-left of the cube
\draw[] (0,0,0) --
(\cubelength,0,0) --
(\cubelength,0,\cubelength) --
(0,0,\cubelength) --
cycle;
% draw the front-right of the cube
\draw[fill=magenta!50] (\cubelength,0,0) --
(\cubelength,\cubelength,0) --
(\cubelength,\cubelength,\cubelength) --
(\cubelength,0,\cubelength)--
cycle;
% draw the front-left of the cube
\draw[fill=orange!50] (0,\cubelength,0) --
(\cubelength,\cubelength,0) --
(\cubelength,\cubelength,\cubelength) --
(0,\cubelength,\cubelength) --
cycle;
% draw the top of the cube
\draw[fill=cyan!50] (0,0,\cubelength) --
(0,\cubelength,\cubelength) --
(\cubelength,\cubelength,\cubelength) --
(\cubelength,0,\cubelength) --
cycle;
}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%To draw a cubeblocks object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Macro for Mystery Hypotenuse cubeblocks
\newcommand{\cubeblocks}[2][]{%
\resizebox{5cm}{!}{ %<- The empty line yields \par - do you want that?
\begin{tikzpicture}[scale=1,
#1,
cubeblocks/.cd,
w/.initial=1,
d/.initial=1,
unit/.initial=cm,
h/.initial=1
]
\tikzset{cubeblocks/.cd,#2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfkeysgetvalue{/tikz/cubeblocks/w}{\Width}%
\pgfkeysgetvalue{/tikz/cubeblocks/d}{\Depth}%
\pgfkeysgetvalue{/tikz/cubeblocks/h}{\Height}%
\expandafter\gdef\expandafter\globalscratchmacro\expandafter{%
\romannumeral0%
\expandafter\Exchange\expandafter{%
\expandafter\renewcommand\expandafter\Height\expandafter{\Height}%
}{%
\expandafter\Exchange\expandafter{%
\expandafter\renewcommand\expandafter\Depth\expandafter{\Depth}%
}{%
\expandafter\Exchange\expandafter{%
\expandafter\renewcommand\expandafter\Width\expandafter{\Width}%
}{ }%<-This space terminates \ronannumeral0-expansion.
}%
}%
}%
%\show\globalscratchmacro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfmathsetmacro{\effDepth}{\Depth-1}
\pgfmathsetmacro{\effHeight}{\Height-1}
\pgfmathsetmacro{\effWidth}{\Width-1}
%%%%%draws coordinates
\coordinate (A) at (0,0,0);
\coordinate (B) at (\Width,0,0);
\coordinate (C) at (\Width,0,\Depth);
\coordinate (D) at (0,0,\Depth);
\coordinate (E) at (0,\Height,\Depth);
\coordinate (F) at (0,\Height,0);
\coordinate (G) at (\Width,\Height,0);
\coordinate (H) at (\Width,\Height,\Depth);
\begin{huge}
\draw[<->,blue,>=latex]([xshift=5mm]B)--%
node[fill=white,xshift=3mm]{%
$\pgfmathprintnumber\Height\,$%
\pgfkeysvalueof{/tikz/cubeblocks/unit}%
}([xshift=5mm]G);
\draw[<->,blue, >=latex]([yshift=-5mm]C)--%
node[fill=white,yshift=-2mm]{%
$\pgfmathprintnumber\Width\,$%
\pgfkeysvalueof{/tikz/cubeblocks/unit}%
}([yshift=-5mm]D);
\draw[<->,blue]([xshift=5mm,yshift=-2mm]B)--%
node[xshift=3mm,yshift=-0mm,fill=white]{%
$\pgfmathprintnumber\Depth\,$%
\pgfkeysvalueof{/tikz/cubeblocks/unit}%
}([xshift=5mm,yshift=-2mm]C);
\end{huge} %<- The empty line yields \par - do you want that?
\foreach \x in {0,...,\effWidth,\effWidth}{%
\pgfmathifisint{\x}{%
\pgfmathsetmacro{\myx}{1}%
}{%
\pgfmathsetmacro{\myx}{\x-int(\x))}%
}%
\foreach \y in {0,...,\effHeight,\effHeight}{%
\pgfmathifisint{\y}{%
\pgfmathsetmacro{\myy}{1}%
}{%
\pgfmathsetmacro{\myy}{\y-int(\y))}%
}%
\foreach \z in {0,...,\effDepth,\effDepth}{%
\pgfmathifisint{\z}{%
\pgfmathsetmacro{\myz}{1}%
}{%
\pgfmathsetmacro{\myz}{\z-int(\z))}%
}%
\path (\x+1-\myx,\y+1-\myy,\z+1-\myz)
pic[z={(-0.5*\myz,-0.5*\myz)},x={(\myx,0)},y={(0,\myy)}]
{cube};
}%
}%
}%
\end{tikzpicture}%
}%%%%closes \resizebox
\globalscratchmacro
}%%%%closes definition-text
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Helpers and scratch-macros:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Argument-exchanging for expansion-trickery:
\newcommand\Exchange[2]{#2#1}
% General-purpose-scratch-macro; gets redefined by \cubeblocks globally:
\newcommand\globalscratchmacro{}%
% Scratch-macros for width, height and depth; they get redefined by
% \cubeblocks locally:
\newcommand{\Width}{}
\newcommand{\Height}{}
\newcommand{\Depth}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%\begingroup
\cubeblocks{w=3,d=4,h=5,unit=cm}\\
%\show\Width
%\show\Height
%\show\Depth
%\endgroup
%\show\Width
%\show\Height
%\show\Depth
\pgfmathsetmacro{\baselayer}{\Width*\Depth}%
\pgfmathsetmacro{\volume}{\baselayer*\Height}%
\renewcommand{\arraystretch}{1}%
\hspace{-2cm}%
\begin{tabular}{|p{4cm}|p{4cm}|}
\hline
Base Layer Shape and Dimensions &rectangle \\
\hline
Base Layer Area & $A=$ \\
\hline
Volume of 1 layer & $V=$ \\
\hline
Prism Height & Prism height is \\
\hline
Volume & $\volume\text{cm}^3$ \\
\hline
\end{tabular}
\end{document}
顺便说一句:
我接受\begin{huge}...\end{huge}
你个人的说法{\huge...}
。;-)