Flexible radiofrequency (RF) surface coils used in simultaneous PET/MR imaging are currently disregarded in PET attenuation correction (AC) since their position and individual geometry are unknown in whole-body patient scans. The attenuation of PET emission data due to the presence of RF surface coils has been investigated by several research groups but so far no automatic approach for the incorporation of RF surface coils into PET AC has been described. In this work, an algorithm is presented and evaluated which automatically determines the position of multiple RF surface coils and corrects for their attenuation of the PET emission data. The presented algorithm nonrigidly registers pre-acquired CT-based three-dimensional attenuation templates of RF surface coils into attenuation maps used for PET AC. Transformation parameters are obtained by nonrigid B-spline landmark registration of marker positions in the CT-based attenuation templates of the RF surface coils to marker positions in the current MR images of the patient. The use of different marker patterns enables the registration algorithm to distinguish multiple partly overlapping RF surface coils. To evaluate the registration algorithm, two different PET emission scans of a NEMA standard body phantom with six active lesions and of a large rectangular body phantom were performed on an integrated whole-body PET/MR scanner. The phantoms were scanned with and without one (NEMA phantom scan) or three (large body phantom scan) flexible six-channel RF surface coils placed on top. Additionally, the accuracy and performance of the algorithm were evaluated on volunteer scans (n=5) and on a patient scan using a typical clinical setup of three RF surface coils. Overall loss of true counts due to the presence of the RF surface coils was 5.1% for the NEMA phantom, 3.6% for the large body phantom, and 2.1% for the patient scan. Considerable local underestimation of measured activity concentration up to 15.4% in the top part of the phantoms and 15.5% for a lesion near the body surface of the patient was measured close to the high attenuating hardware components of the RF coils. The attenuation maps generated by the registration algorithm reduced the quantification errors due to the RF surface coils to values ranging from -3.9% to 4.3%. Concerning the volunteer examinations, the attenuation templates of the three RF surface coils were registered to their correct positions with an overall accuracy of about 3 mm. The presence of flexible RF surface coils leads to considerable local errors in the simultaneously measured PET activity concentration up to 15.5% especially in regions close to the coils. The presented automatic algorithm accurately and reliably reduces the PET quantification errors caused by multiple partly overlapping flexible RF surface coils to values of 4.3% or better.