  We develop a continuum theory to model low energy excitations of a generic
four-band time reversal invariant electronic system with boundaries. We propose
a variational energy functional for the wavefunctions which allows us derive
natural boundary conditions valid for such systems. Our formulation is
particularly suited to develop a continuum theory of the protected edge/surface
excitations of topological insulators both in two and three dimensions. By a
detailed comparison of our analytical formulation with tight binding
calculations of ribbons of topological insulators modeled by the
Bernevig-Hughes-Zhang (BHZ) hamiltonian, we show that the continuum theory with
the natural boundary condition provides an appropriate description of the low
energy physics. As a spin-off, we find that in a certain parameter regime, the
gap that arises in topological insulator ribbons of finite width due to the
hybridization of edges states from opposite edges, depends non-monotonically on
the ribbon width and can nearly vanish at certain "magic widths".
