Can you hook directly to the batteries? VIA A PROPER FUSE yes, directly no
Can they be in the same compartment.. No, the one next to it.
Suggestion.. The two cables that run from the Inverter negative to the battery negative and inverter positive to the fuse.. Tape them side by side or run 'em through a split loom (that plastic wrapping) so they lie next to each other as close as insulation permits.
NOTE: Inverters come in 2x2 types.. I assume in your case it is a "Stand-alone" (As opposed to inline)
The next type is True Sine Wave / MSW Some Televisions, Sat receivers, Digital converters, Audio systems (including most all AM radios) do not much like some MSW inverters.
Others... (Either different models of electronics or different inverters) work fine.