As direct-drive actuators, permanent-magnet linear synchronous motors (PMLSMs) are widely used in high velocity and high precision applications. The detent force, however, can deteriorate the performance and even excite the mechanical resonance. This paper focuses on a novel detent force compensation scheme for PMLSM systems through a combination of structural design and control method. First, due to the bandwidth constraint of the control system, eliminating high frequency ripples is unfeasible; skewed permanent magnets (PMs) considering an optimal skewing length are designed to suppress high order harmonic components. Second, based on the model of PMLSM with skewed PMs, a linearization observer is derived and applied independently to the velocity controller for further diminishing low-order harmonic components. To facilitate implementation in the digital control system, a discretization method taking account of estimated errors is designed. Through the online calculation, the estimated detent force is injected to the control system in a feedforward way. To tune the proposed scheme properly, the convergence of the algorithm is analyzed by utilizing Lyapunov stability theory. Simulation studies are performed to prove the effectiveness of the proposed method, and experiments are provided to confirm the theoretical analysis and simulation results.