The solution of differential problems, and in particular of quantum wave equations, can in general be performed both in the direct and in the reciprocal space. However, to achieve the same accuracy, direct-space finite-difference approaches usually involve handling larger algebraic problems with respect to the approaches based on the Fourier transform in reciprocal space. This is the result of the errors that direct-space discretization formulas introduce into the treatment of derivatives. Here, we propose an approach, relying on a set of sinc-based functions, that allows us to achieve an exact representation of the derivatives in the direct space and that is equivalent to the solution in the reciprocal space. We apply this method to the numerical solution of the Dirac equation in an armchair graphene nanoribbon with a potential varying only in the transverse direction.