Dirac cones in two-dimensional systems: From hexagonal to square lattices