Engineering geological disasters such as rockburst have always been a critical factor affecting the safety of coal mine production. Thus, residual stress is considered a feasible method to explain these geomechanical phenomena. In this study, electron backscatter diffraction (EBSD) and optical microscopy were used to characterize the rock microcosm. A measuring area that met the requirements of X-ray diffraction (XRD) residual stress measurement was determined to account for the mechanism of rock residual stress. Then, the residual stress of a siliceous slate-containing quartz vein was measured and calculated using the sin2ϕ method equipped with an X-ray diffractometer. Analysis of microscopic test results showed homogeneous areas with small particles within the millimeter range, meeting the requirements of XRD stress measurement statistics. Quartz was determined as the calibration mineral for slate samples containing quartz veins. The diffraction patterns of the (324) crystal plane were obtained under different ϕ and φ. The deviation direction of the diffraction peaks was consistent, indicating that the sample tested had residual stress. In addition, the principal residual stress within the quartz vein measured by XRD was compressive, ranging from 10 to 33 MPa. The maximum principal stress was parallel to the vein trend, whereas the minimum principal stress was perpendicular to the vein trend. Furthermore, the content of the low-angle boundary and twin boundary in the quartz veins was relatively high, which enhances the resistance of the rock mass to deformation and promotes the easy formation of strain concentrations, thereby resulting in residual stress. The proposed method for measuring residual stress can serve as a reference for subsequent observation and related research on residual stress in different types of rocks.