Yes, it is true. From Diophantine Equations on Wikipedia
The simplest linear Diophantine equation takes the form ax + by = c,
where a, b and c are given integers. The solutions are completely
described by the following theorem: This Diophantine equation has a
solution (where x and y are integers) if and only if c is a multiple
of the greatest common divisor of a and b. Moreover, if (x, y) is a
solution, then the other solutions have the form (x + kv, y - ku),
where k is an arbitrary integer, and u and v are the quotients of a
and b (respectively) by the greatest common divisor of a and b.
Look at the Wikipedia article for more details of a proof.
To try to connect things, consider the equation: 5x+3y=4 as x could represent the number of filling or emptying of the 5 quart jug while y represents the same thing for the 3 quart jug. If there was a common factor between these, this could be factored out so that any answer would be a multiple of that integer. Given that a solution is (2,-2) to that Diophantine equation, this could imply that one fills the 5 quart jug and empties it over the 3 quart jug a couple of times to get exactly 4 quarts assuming one has another container to hold the 4 quarts.
I'll admit that I've seen this problem from Die Hard 3, so I know of an alternate solution.
Consider the case where there is a common factor between the jug sizes where one has jugs of size 8 and 12. Now, the greatest common divisor of 8 and 12 is 4 and thus any combination of pourings will leave you with a multiple of 4 for an answer as 8x+12y=4(2x+3y) and thus while one can easily solve 2x+3y=1, it is a bit different to solve 4(2x+3y)=1 where x and y are integer values as no solutions exist here.
In contrast, consider that if for a given pair of jug sizes that one can get exactly 1 of the unit then this could be repeated for any Natural number greater than 1 so to get any other value is rather easy if you can get 1.
The first part of my answer covers this in a general case, but for the sake of argument let's take $5x+3y=z$. If $z=1$ then by inspection I can notice that x=-1,y=2 is a solution. There are many solutions as one could take that solution and make the parametrized solution of $x=-1+k,y=2-k$ for k being any integer. Now, if z is some other value, I could just multiply the initial solution to get that value. Thus, if $z=4$ then $x=-4,y=8$ is a solution which works as $5*(-4)+3*8=-20+24=4$.
This last part is fairly trivial to my mind if you remember that one can take an equation and multiply both sides by a non-zero value and maintain equality.