  We develop a method for calculating the fundamental electronic gap of
semiconductors and insulators using grand canonical Quantum Monte Carlo
simulations. We discuss the origin of the bias introduced by supercell
calculations of finite size and show how to correct the leading and subleading
finite size errors either based on observables accessible in the finite-sized
simulations or from DFT calculations. Our procedure is applied to solid
molecular hydrogen and compared to experiment for carbon and silicon crystals.
