TransWikia.com

TikZ: Declare Function vs Macro: use of cm

TeX - LaTeX Asked on December 20, 2020

Code:

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;}] 
            defbuffHeight{5};
            defvertDis{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}

Result:

enter image description here

vertDis and vertDis gave me the same results as well as buffHeight and buffHeight. But when I put in cm for the macro and the variable version i.e. vertDis cm and vertDis cm, the former worked, while the latter gave me an error. Why does the macro version work with cm, but not the non-macro version?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP