We obtain a new equation of state for the nucleonic and hyperonic inner core of neutron stars that fulfils the 2 M e observations as well as the recent determinations of stellar radii below 13 km. The nucleonic equation of state is obtained from a new parameterization of the FSU2 relativistic mean-field functional that satisfies these latest astrophysical constraints and, at the same time, reproduces the properties of nuclear matter and finite nuclei while fulfilling the restrictions on high-density matter deduced from heavy-ion collisions. On the one hand, the equation of state of neutron star matter is softened around saturation density, which increases the compactness of canonical neutron stars leading to stellar radii below 13 km. On the other hand, the equation of state is stiff enough at higher densities to fulfil the 2 M e limit. By a slight modification of the parameterization, we also find that the constraints of 2 M e neutron stars with radii around 13 km are satisfied when hyperons are considered. The inclusion of the high magnetic fields present in magnetars further stiffens the equation of state. Hyperonic magnetars with magnetic fields in the surface of ∼10 15 G and with values of ∼10 18 G in the interior can reach maximum masses of 2 M e with radii in the 12-13 km range.