The real question isn't gold vs food but gold vs fiat and other centrally managed paper assets with a high counter-party risk. Obviously you aren't going to be able to eat gold, so if you are worried that things could get as bad as a severe disruption of the food supply, you should stock up on food. But to be realistic, who is going to be spending their whole wealth on bags of rice, sugar and flour that are going to expire and aren't liquid assets that can be easily sold back if things take longer to fail or don't really quite fail that badly as expected after all?
Here, and everywhere where the question of what asset to hold in crisis times is being asked, it's assumed that basic necessities as food, water, shelter, autonomous energy sources and physical security are already in order.
The real question is where to invest the remaining wealth in such a way as to have a reasonable chance of maintaining control over one's wealth when governments and banksters come looting, of evading capital controls when they hit and of conserving some buying power in the future when economy has sufficiently recovered and people start trading again. What form of wealth can reasonably be carried around concealed? What will have value when the world resumes trading after a total collapse and a decade of depression ponctuated by civil wars and starvation. What will be considered to have value in the future and can be kept hidden for any amount of time? What will other rational and forward looking people in these dark times consider as something possibly credible and valuable enough (in the future) to accept it in the course of bartering?
Gold and other precious metals is the obvious answer. Gold has been accepted as a form of money for thousands of years, since the very dawn of mankind. Gold can't be destroyed. It can't be diluted. It can't be inflated away. It's fungible and infinitely divisible. It can be trivially quantified with elementary tools or even with no tools at all. It doesn't oxidate. It can be melt at temperatures that are easily achievable with rudimentary means. It can be easily shaped to take any form. It can be minted into coins. It is very rare. It is easy to recognize and there are no other elements that even remotely look alike and could be mistaken for it. It is one of the densest element that is naturally available, which again makes it very difficult to fake. It's detection and extraction is very costly, and involves an important amount of human labor, even more so in a situation where technology has regressed, which means that it is and always will be a good almost direct proxy for human work and sacrificed life time which is the most valuable thing in the whole universe and underlies the meaning of value itself: gold cannot possibly be worth less than the value of the time and effort spent to procure and extract it, which is already pretty high. And last but not least: it is attractive.
You may take my last statement as something superficial and cosmetic, but think about it again. We are the product of millions of years of evolution. Our sense of attraction has been honed to lead us to what we need to survive. Attraction is the central principle of survival, it underlies reproduction, feeding, nesting, migration. It is our primitive mental compass, the very phenomenon that led us to the absolute domination of our ecosystem.
Among hundreds of elements of the periodic table, gold is the one element that the human mind considers as possibly the most irresistibly attractive. This could be completly arbitrary as there could be a much deeper reason to it that we don't understand. But regardless of the reason, what really matters is the fact that this attraction is common to our entire species with very little exceptions, which means that should any physical substance ever be used again as a form of money, the odds that this would be gold are ridiculously high.