  We study the bond-alternating Heisenberg model using the finite-size
density-matrix renormalization group (DMRG) technique and analytical arguments
based on the matrix product state, where we pay particular attention to the
boundary-condition dependence on the entanglement spectrum of the system. We
show that, in the antiperiodic boundary condition (APBC), the parity quantum
numbers are equivalent to the topological invariants characterizing the
topological phases protected by the bond-centered inversion and $\pi$ rotation
about $z$ axis. We also show that the odd parity in the APBC, which
characterizes topologically nontrivial phases, can be extracted as a two-fold
degeneracy in the entanglement spectrum even with finite system size. We then
determine the phase diagram of the model with the uniaxial single-ion
anisotropy using the level spectroscopy method in the DMRG technique. These
results not only suggest the detectability of the symmetry protected
topological (SPT) phases via general twisted boundary conditions but also
provide a useful and precise numerical tool for discussing the SPT phases in
the exact diagonalization and DMRG techniques.
