Let $a,b,c,d$ be positive integers such that the number of pairs $(x,y) \in (0,1)^2$ such that both $ax+by$ and $cx+dy$ are integers is equal with 2004. If $\gcd (a,c)=6$ find $\gcd (b,d)$.
1. Given the problem, we need to find the number of pairs \((x, y) \in (0,1)^2\) such that both \(ax + by\) and \(cx + dy\) are integers. We are also given that \(\gcd(a, c) = 6\) and the number of such pairs is 2004.

2. We start by considering the general form of the problem. If \(a, b, c, d\) are positive integers such that \(ad - bc = k > 0\) and \(\gcd(a, c) = \gcd(b, d) = 1\), then there are exactly \(k\) pairs \((x, y) \in [0,1)^2\) such that both \(ax + by\) and \(cx + dy\) are integers. This is a known result from number theory.

3. In our problem, we are given that \(\gcd(a, c) = 6\). Let \(a = 6a_1\) and \(c = 6c_1\) where \(\gcd(a_1, c_1) = 1\). This substitution simplifies the problem because it reduces the gcd condition to 1 for \(a_1\) and \(c_1\).

4. The number of pairs \((x, y) \in (0,1)^2\) such that both \(ax + by\) and \(cx + dy\) are integers is given to be 2004. This implies that the determinant of the matrix formed by \(a, b, c, d\) must be 2004. Specifically, we have:
   \[
   ad - bc = 2004
   \]

5. Since \(a = 6a_1\) and \(c = 6c_1\), we substitute these into the determinant equation:
   \[
   (6a_1)d - (6c_1)b = 2004
   \]
   Simplifying, we get:
   \[
   6(a_1d - c_1b) = 2004
   \]
   Dividing both sides by 6, we obtain:
   \[
   a_1d - c_1b = 334
   \]

6. We need to find \(\gcd(b, d)\). Since \(\gcd(a_1, c_1) = 1\), the equation \(a_1d - c_1b = 334\) implies that \(b\) and \(d\) must be such that their gcd divides 334. The prime factorization of 334 is:
   \[
   334 = 2 \times 167
   \]

7. Since \(\gcd(a_1, c_1) = 1\), and \(a_1d - c_1b = 334\), the gcd of \(b\) and \(d\) must be a divisor of 334. Given that \(a_1\) and \(c_1\) are coprime, the gcd of \(b\) and \(d\) must be 1, 2, 167, or 334. However, since \(a_1\) and \(c_1\) are coprime, the gcd of \(b\) and \(d\) must be the same as the gcd of 334, which is 2.

The final answer is \(\boxed{2}\).