I've instructed on countless trips over the last few years, and I can tell you that the number one needlessly heavy thing that beginner trampers usually bring is too much food. Now, let me be clear, it is always better to bring too much food rather than too little. However, there is definitely a happy middle ground. This article is intended as a broad guide to hiking food, and is just what I've found works for me. You can get REALLY detailed about this, and people do, but for now, here is a starting point.
Aim for 500g-800g per day if doing a shorter trip; if doing a longer trip (5+ days), after day 5 up the amount to more like 700g-1kg depending on how much you eat.
Aim for a good mix of carbs, protein, fat and sugar.
Try and find energy dense food, i.e. food that has a lot of calories for its weight.
The food should ideally be non-perishable, though some things last longer than you might think (like cheese and pesto). It can also be nice to bring fresh food for the first day.
Bring food with minimal packaging; this is more environmentally friendly and saves weight.
Bring food you actually want to eat! Junk food, salty food, lollies, M&Ms, Crunchy Bars, they're all good. It is more important, in my opinion, to take slightly less healthy food you'll actually eat, rather than healthy food you won't be able to stand the site of after 2 days.
I've found aiming for 700g per day works for me quite well, but this is a very individual-specific. The general range is 500-1kg per day. Working out how much food works for you takes a lot of trial and error. Here's what this actually looks like for me:
100g breakfast - usually porridge, energy bars or muesli with milk powder. I find I need carbs and sugar in the morning. I often add dehydrated berries or nuts.
400g snacks/lunch - I don't usually bring a dedicated lunch; I like to eat a little more often rather than one big meal. What this usually looks like is peanuts and chocolate for protein, fat, and sugar (takes a variety of forms, like M&Ms; muesli bars, etc), some form of energy bars for carbs and sugar (something like One Square Meals but better, I hate OSMs), and usually some form of crackers and cheese or sometimes tuna and pesto. I find I tend to run on carbs mostly, but some people run better on fat. It is also important to have salty foods with you, as these will help keep you hydrated.
200g dinner - mainly carbs and protein, but with lots of added fat. Fat is very energy efficient; i.e. 1 g of fat has much more energy than 1 gram of carbs. So a high source of fat is a great way to add calories to a meal. I often bring a little bottle of olive oil and add it to my dinner to boost my caloric intake. Dinner is where you can be most creative, as you have much more time to cook. It is important to have protein to restore your muscles. Dinner for me usually looks like pasta, rice, or couscous with some form of flavouring (like pesto, cheese, seasoning etc...), protein like jerky or tuna, and fat from cheese and olive oil. The other characteristic I like in my dinner is being fast to prepare, with minimal cleanup. By the end of the day, I am tired, and I don't feel like screwing around too much before I can eat. For some great recipes, that I use often, have a look at Andrew Skurka's dinner ideas.
You should aim for high energy food. Look at the nutritional information on the back of wrapping, and look for the number that has 'kJ' after it. One of the ways to figure out what is good tramping food is to divide this number by the net weight of the item. The bigger the result of this calculation, the more energy dense the food is, so the more efficient it is to take tramping. This is a really good way to compare like for like items. For example, when comparing Muesli Bars, look for the one with the highest 'kJ' number. From there, try and get a good balance of the different food groups; i.e protein, carbs, fat and sugar. You also want non-perishable food obviously, though on the first few days it can be nice to carry some fresh meat and veg if you're not walking too far. If you're doing a trip that is longer than 5-6 days, for the days after that (i.e. days 7,8,9 etc) you will most likely want to up your intake to more like 800g-1kg, as you will find yourself getting a lot hungrier (probably because you body has stopped burning your fat reserves by then).
Like I said, people can get really into this, right down to working out exactly how many calories they need. I have done this before, but mostly I follow the above guidelines and I turn out alright. If I'm going into an area where I could get stuck or delayed, I just add either an extra half or full days food, depending on the likelihood of something happening. However, I don't carry extra 'emergency' food as a matter of course. If I'm going into an area where it's almost impossible that I'll be stuck, I don't see the point. If I run out of food, I'm not gonna die. However, in carrying 700g per day I usually find I have enough left over to get me through an extra day. However, on a long South Island trip, I can easily take 2-3 extra days worth of food. It all comes down to what conditions you expect to encounter. If you are on a guided trip, like a Duke of Edinburgh trip however, 24 hours worth of emergency food is often required.
Finally, make the food you bring something you actually want to eat! Scroggin, healthy muesli bars, porridge and all that stuff are all well and good, but people, including me, often get sick of it very quickly. Eating regularly while hiking is important, and if you get sick of your food and don't eat, you will get tired and stop having fun. So, break out all the junk food that you deny yourself the rest of the time. As long as it fits the above criteria, it's fine, you'll use the energy. So as long as it's calorie dense, has more than just sugar (protein, fat etc..) and tastes good, that is what you want. I've never seen someone turn yellow from eating junk food for two weeks.
A note on water. A very easy way to save weight is to carry less water. You have to be VERY careful about this though. Water is very heavy for the benefit it gives. So minimising the amount you are carrying is an easy way to save weight as well. In some places, like many parts of the South Island where you spend the whole day walking by a river, you barely need to carry any at all. More commonly, you can save weight by working out how many water sources are along your route, and planning to refill at those rather than carrying all the water you need for the day from the start of the day. Also remember that if you are going to make frequent water stops, you need to be aware of the methods of water treatment. See my article on water treatment for more on this. However, you don't want to screw this up, as being without water sucks. So better to er on the side of more water rather than less. If you are not sure if there are going to be good water sources along the way, or if you don't have a way to treat the water (boiling takes too long and uses too much fuel), carry all the water you need for the day
[Disclaimer: I am not a dietician, and don't know much at all about the science behind this. I highly encourage you to investigate further. But above is what I've found to work through long experience, but this is just my opinion, there are people much better at this than I am who've written copious amounts on it. If you google 'hiking food' or something similar, you'll find heaps of stuff.]