In the examples given in textbooks, two or more sides of an infinite rectangular box are grounded, or have the same potential, so it becomes easier to put boundary conditions in solution obtained from the Laplace equation. If we apply separation of variables, we will get sinosudial and exponential functions.
When potential of two opposite sides were zero, we could take potential along that direction to be a sine function, and apply boundary condition to get quantization of the parameter, and calculate the Fourier coefficients of the sum of product of sin and exponential functions.
When potential of two opposite sides are equal but non zero, we could subtract that potential from everywhere to make the potential zero at those plates and apply the above procedure. After solving, we can add the potential back.
However, when we have, say, an infinite rectangular box with the four sides having different potentials $V_1$, $V_2$, $V_3$, and $V_4$, how to evaluate the Fourier coefficients?