pgfmathtruncatemacro 疯了

pgfmathtruncatemacro 疯了

这真的很奇怪。当我用 pgfmathtruncatemacro 定义距离时,它通常有效,但有一个不起作用并且没有意义。如果距离的名称被实数覆盖,它就会起作用。但这只发生在一个距离上,无论你使用什么名称。这是代码:

\documentclass[tikz]{standalone}
\usepackage{tikz}%to draw
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.gates.logic.US}
\usetikzlibrary{shapes.gates.logic.IEC} 
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{backgrounds}
\usetikzlibrary{fit}
\usetikzlibrary{petri}
\usepackage{circuitikz}%para dibujos con pouertas logicas etc
\usepackage{pgfplots}%graficas en tikz
\usetikzlibrary{circuits.logic.US}
\usetikzlibrary{matrix}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.geometric}
\usepackage{rotating}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{positioning}
\pgfmathtruncatemacro \patitas {1mm}%distance for patitas de las puertas lógicas etc
\pgfmathtruncatemacro \ypatitas {1mm}
\pgfmathtruncatemacro \xpatitas {0mm}
\pgfmathtruncatemacro \auxd {1}
\pgfmathtruncatemacro \noded {1 cm}%distancia entre nodos
\begin{document}

\begin{tikzpicture}[circuit logic US,
                tiny circuit symbols,
                every circuit symbol/.style={fill=white,draw, logic gate                    input sep=1mm},
                node distance = \noded,
                decoration={
                markings,
                mark= at position 0.5 with {\node[font=\footnotesize] {\rotatebox{70}{/}};}
                }
]


\tikzset{font=\scriptsize}
%logic gate nodes

\node[and gate, draw, logic gate inputs=nn] at ($(1,0.5)$) (andpriman) {}; 
\node[and gate, draw, logic gate inputs=nn] [above of =andpriman] (andprima1) {};
\node[and gate, draw, logic gate inputs=nn] [node distance=\auxd cm,above of =andprima1] (andn) {};
\node[and gate, draw, logic gate inputs=nn] [above of =andn] (and1) {}; 


% vdots

\path (and1.south) -- (andn.north) node [black, font=\large,midway,yshift= 1*\auxd mm] (vdots1) {$\vdots$}; 
\path (andprima1.south) -- (andpriman.north) node [black, font=\large,midway,yshift= 1*\auxd mm] (vdots2) {$\vdots$}; 

% carry on with nodes

\node[or gate, draw, logic gate inputs=nn] [right of =vdots1] (orexcitatorias) {}; 
\node[nor gate, draw, logic gate inputs=nn] [right of =vdots2] (norinhibitorias) {}; 
\node at ($ (orexcitatorias) !.5! (norinhibitorias) $) (aux1) {}; 
\node[and gate, draw, logic gate inputs=nn] [right of =aux1]  (andgatherer) {};  

%connections        

\draw (andpriman.input 1) -- ++ (left:1mm) node[yshift= \ypatitas, left=\xpatitas,blue] (xpriman) {$x'_{M}$};
\draw (andpriman.input 2) -- ++ (left:\patitas) node[yshift=-\ypatitas, left=\xpatitas,blue] (wprimajn) {$i_{M}$};
\draw (andprima1.input 1) -- ++ (left:\patitas) node[yshift=\ypatitas, left=\xpatitas,blue] (xpriman) {$x'_1$};
\draw (andprima1.input 2) -- ++ (left:\patitas) node[yshift=-\ypatitas, left=\xpatitas,blue] (wprimajn) {$i_1$};
\draw (andn.input 1) -- ++ (left:\patitas) node[yshift=\ypatitas, left=\xpatitas,blue] (xpriman) {$x_N$};
\draw (andn.input 2) -- ++ (left:\patitas) node[yshift=-\ypatitas, left=\xpatitas,blue] (wprimajn) {$e_N$};             
\draw (and1.input 1) -- ++ (left:\patitas) node[yshift=\ypatitas, left=\xpatitas,blue] (xpriman) {$x_1$};
\draw (and1.input 2) -- ++ (left:\patitas) node[yshift=-\ypatitas, left=\xpatitas,blue] (wprimajn) {$e_1$};


\end{tikzpicture}

\end{document}

上面代码的图片

答案1

我认为计算是使用pt“单位”进行的,因此 1mm 转换为点。因此,

\pgfmathtruncatemacro{\patitas}{1mm}

保持\patitas值 2,因为 1mm 大约为 2.8pt。同样注意,\pgfmathtruncatemacro \noded {1 cm}实际上会\noded扩展到 28。

如果你想创建一个保存长度的宏,你可以使用

\newcommand\patitas{1mm}

或者如果你需要进行计算,请使用

\pgfmathsetlengthmacro\patitas{1mm}

如果您这样做,您还会得到更符合预期的东西++ (left:\patitas pt),请注意pt,但由于truncate,距离将约为 0.7 毫米而不是 1 毫米。

相关内容