Using a bioenergetic model we show that the pattern of foraging preferences greatly determines the complexity of the resulting food webs. By complexity we refer to the degree of richness of food-web architecture, measured in terms of some topological indicators (number of persistent species and links, connectance, link density, number of trophic levels, and frequency of weak links). The poorest food-web architecture is found for a mean-field scenario where all foraging preferences are assumed to be the same. Richer food webs appear when foraging preferences depend on the trophic position of species. Food-web complexity increases with the number of basal species. We also find a strong correlation between the complexity of a trophic module and the complexity of entire food webs with the same pattern of foraging preferences.