Remnant magnetization causes a change in the direction and intensity of the magnetization vector. If inversion is performed regardless of remnance, in some cases it may have unreliable and misleading results. For inversion with respect to remnant magnetization, several solutions have been proposed so far, one of which is to convert the data of total magnetic field into data that is independent of the direction of magnetization. In this study, the transformation of Total Field Anomaly (TFA) into Total Magnitude Anomaly (TMA) is used. The inversion algorithm is based on improving compact inversion method and is just two-dimensional. In compact inversion, anomalies may concentrate on the surface of the earth, and thus the response is unreliable. To solve this problem, a combination of matrices and weighting functions have been used, including elements such as magnetic susceptibility and depth function. The resulting model can be smooth or compact (with sharp edges) based on changing compactness factor. The method has been tested using several synthetic and real data. The synthetic data are a 2D tabular prism, of which the top buried-depth is 20 m and the length and width are 40 to 20 m, a dipping prism with a vertical tabular nearby. The real example is magnetic data over Galinge iron-ore deposit in Qinghai province of China, and the data of four profiles have been considered for 2D inversion. Inversion even smooth or sharp, have been conducted with all models, and especially sharper models are consistent with the known geologic attributes of the magnetic sources.