h_km_layout function

Helper function to prepare a KM layout