First, what do you mean by a "small space"? Code requires 16" on each side although retro fitting into a somewhat smaller space usually is allowed to slide. Standard rough-in for the drain is 12" measured from the finished wall to the center of the drain. I would strong advise you to forget about the box store toilets. They are cheap, but they are also inferior. They are commonly called, builder models because builders can buy them cheap. The homeowner usually ends up replacing them soon after buying the house because of their poor quality. The brand that most regulars on this site advise is the Toto. Terry has an excellent section on toilets of numerous brands linked from the home page, I'd suggest you start there and see what is available and what the prices are.