It all comes down to more calories in than out. I also recommend calculating your Basal Metabolic Rate, this is the rate that your body burns calories while in resting state. From there you can adjust your calorie needs in order for you to gain weight. I also highly recommend doing cardio, and gaining from natural foods such as nuts, and limit your sugar intake. Adding heavy whipping cream to your coffee can help you gain weight too.