For better efficiency as photocatalysts, N-doping for visible light reactivity has been intensively studied in Lamellar niobic and titanic solid acids (HNb3O8, H2Ti4O9), and its microscopic structures have been debated in this decade. We calculate the layered solid acids' structures and bandgaps. Bandgap reduction by carbon nitride adsorption in interlayer space is observed computationally. It originates from localized nitrogen states which form delocalized top-valence states by hybridizing with the host oxygen states and can contribute to photo-current.