They can be compensated through Creative Commons. Creative Commons does not mean that the book cannot be charged for. A book can still be charged for. It's just the creation of the work is made available for free.
Cory Doctorow makes money on his books. It's exactly the same model as a textbook. He creates a book and then the physical book is sold. He sells e-book copies and he makes a PDF available for anyone for free. He is able to make more money as a result because his product is available more widely and people are more likely to purchase the book because a PDF is less readable on a Kindle, on an e-reader. It's the same thing with textbooks.