Analytical Formulae for the Surface Green’s Functions of Graphene and 1T’ MoS2 Nanoribbons