Last month, I asked this question, about how to personalize a flowchart based on data available in a text file. The idea was to be able to adjust the width of arrows depending on numbers in the text file. Now I have been wanting to go one step further, which is: not plotting the arrow in case the corresponding number in the data file is zero.

I managed to introduce a conditional to test whether my data is larger than zero, which works if I use an arbitrary number (e.g. \ifnum2>0), but not if I use my custom-defined command for fetching the data (e.g. \ifnum\flowwidth{A2B}>0, see below in the code chunk)

I have tried a few different options to try to make it work. Here is the base code, on which I started to make modifications (some parts come from the answer to this other question I asked last month):


A2B, 110$\pm$6, 1.5 mm
A2C, 0$\pm$0, 0 mm
A2D, 110$\pm$6, 0.4 mm


% USE readarray  TO GET THE DATA INTO A \def


% For importing data

\begin{tikzpicture}[BOX/.style   ={rectangle, draw, text centered},
                    ARROW/.style ={draw,-latex', line width = 0.5mm}]

\node [BOX] (a) {A};   
\node [BOX, right= of a] (c) {C};   
\node [BOX, above= of c] (b) {B};

\draw [draw,-stealth, line width = \flowwidth{A2B}] (a.north) |- (b.west);
\draw [draw,-stealth, line width = \flowwidth{A2C}] (a.east) -- (c.west);  


I have tried to store the width in an intermediate variable instead of having the command after the if:

    \draw [draw,-stealth, line width = \flowwidth{A2B}, color = red] (a.north) |- (b.west);

Or use \pgfmathsetmacro :

    \draw [draw,-stealth, line width = \flowwidth{A2B}, color = red] (a.north) |- (b.west);

Or use \expandafter :

    \draw [draw,-stealth, line width = \flowwidth{A2B}, color = red] (a.north) |- (b.west);

But those approaches yield nothing. I have also tried to play around with \csname and \endcsname. I have to admit that I made these changes rather randomly, with no true understanding of the programming principles behind. I would be very glad if someone would have suggestions on how to solve this and also if anyone knows a good resource/tutorial that explains that sort of LaTeX programming.

  • The test for \flowwidth should be \ifdim\flowwidth{A2B}>0pt, because the variable contains a length.
    – egreg
    Oct 20, 2017 at 10:49
  • That does indeed do the trick. I was looking way too far it seems. Thank you very much!
    – Delphine
    Oct 20, 2017 at 11:22

1 Answer 1


The final expansion of \flowwidth{A2B} is 1.5mm, so a test for it being positive should use \ifdim:


(remember to leave a space, or end-of-line, after pt in order to avoid untimely expansion of what follows).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.