I found a great answer to the question of flatulence and vegan diets from VegWeb. It's far better than anything I can come up with.
I'll add to that, though, if you have a dietary allergy to something that you consume in large quantities, such as soy, it can cause gas. I have a bit of an allergy to soy, and if I eat too much of it, or if I have a lot of chocolate (this I don't understand, but it happens) then the gas is flying out of me in a big and potentially embarrassing way. I'm allergic to dairy too, and it used to do this to me even more so, but that is completely eliminated from my diet since becoming vegan.
So, figure out what in your diet is making you gassy, cut back on it, or eat your culprit food and try to avoid society for a few hours.