This was understandably a little confusing. The q in the picture is correct for the linearization of the dynamics equations. Here's why:
Define an angle, f, which is defined to be zero pointing down. We will want to linearize about f = p + q, where q is a small angle away from the vertical (as defined in the picture). In doing this linearization, we thus say that cos(f) = -1, sin(f) = -q, and all second-order terms vanish.
This is how and why the q is defined the way it is in these pictures.