I have progressed pretty far in Japanese, but when I construct Japanese sentences, I still get these two particles mixed up. For example, when talking about being inside something, I don't know when to use "の中に" and when to use "の中で." Likewise, when speaking about being next to something, I sometimes don't know if I should use "となりに" or "となりで." How do you know which one to use in a sentence?
Which of these is correct?