The delta f particle-in-cell method for gyrokinetic simulations with kinetic electrons and electromagnetic perturbations [Y. Chen, S. Parker, J. Comput. Phys. 189 (2003) 463] is extended to include arbitrary toroidal equilibrium profiles and flux-surface shapes. The domain is an arbitrarily sized toroidal slice with periodicity assumed in toroidal direction. It is global radially and poloidally along the magnetic field. The differential operators and Jacobians are represented numerically which is a quite general approach with wide applicability. Discretization of the field equations is described. The issue of domain decomposition and particle load balancing is addressed. A derivation of the split-weight scheme is given, and numerical observations are given as to what algorithmic change leads to stable algorithm. It is shown that in the final split-weight algorithm the equation for the rate of change of the electric potential is solved in a way that is incompatible with the quasi-neutrality condition on the grid scale. This incompatibility, while negligible on the scale of interest, leads to better numerical stability on the grid scale. Some examples of linear simulations are presented to show the effects of flux-surface shaping on the linear mode growth rates. The issue of long-term weight growth in delta f simulation and the effect of discrete particle noise are briefly discussed. (c) 2006 Elsevier Inc. All rights reserved.