代码:
\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{float}
\pgfplotsset{compat=1.17}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows.meta, automata, positioning, matrix, calc}
\usepackage[RPvoltages, american,siunitx]{circuitikz}
\usepackage[margin=1in]{geometry}
\begin{document}
\begin{figure}[H]\centering
\begin{tikzpicture} [declare function = {buffHeight = 5; vertDis = 2;}]
\def\buffHeight{5};
\def\vertDis{2};
\draw(0,0) node[draw, minimum width = 1.25cm, minimum height = \buffHeight] (Samp1){};
\draw(\vertDis,0) node[draw, minimum width = 1.25cm, minimum height = \buffHeight] (Samp2){};
\draw(0,-6) node[draw, minimum width = 1.25cm, minimum height = buffHeight] (Samp3){};
\draw(vertDis,-6) node[draw, minimum width = 1.25cm, minimum height = buffHeight] (Samp4){};
\end{tikzpicture}
\end{figure}
\end{document}
结果:
\vertDis
和以及vertDis
给出了相同的结果。但是当我输入宏和变量版本,即和 时,前者有效,而后者给出错误。为什么宏版本可以与 一起使用,而非宏版本却不行?\buffHeight
buffHeight
cm
\vertDis cm
vertDis cm
cm