Is it ethical to profit by having my students buy my textbook? This question was suggested to me by How can I sell my text book to my students in e-book format? which asked about the practicalities, but attracted many comments about the ethics.  So this question is to ask about the ethics directly.

Suppose I have written and published a textbook, and I want to use it as the text for a course I am teaching.  I receive royalties from each copy of my book that is sold, so if my students are required to buy my textbook for the course, I will make some money.  Is it ethical to do so?

Well-reasoned opinions would be useful answers, but even more useful would be pointers to institutional policies, professional codes of ethics, etc, that address this issue.

Of course, there are many ways to avoid profiting from the sale of my book to my students.  If my contract with my publisher allows it, I could distribute PDFs to my students, or have the university bookstore print out copies and sell them at cost.  Another approach I've heard of is to compute how much I earn in royalties on each copy, and refund that amount from my pocket to each student who buys a copy.  Or, use my royalty earnings to buy pizza for the class.  Certainly these are nice gestures, but I would like opinions on whether they are ethically required.

Edit: To address some questions that have arisen in the comments:


This question is hypothetical.  I haven't published any textbooks myself and have no immediate plans to do so.  In any case, my personal preference would be to make the book available to students for free, if at all possible.  So I've phrased this question in the first person for rhetorical convenience only.
I had intended the question to be only about the potential financial conflict of interest that could arise if I make money by assigning my own book.  Some of the answers feel that it is improper for me to assign my own textbook at all, whether I make money or not, but I don't think this point of view is prevalent within the academic community.  If it happens that my book (as a pithy but now-deleted comment put it) "blows", I think most would agree that my decision to assign it is pedagogically unfortunate, but not unethical.  
I don't literally mean that students would be required to buy the book, only that they'd be expected to have it.  I might assign readings or homework problems from the book, so that the student needs access to the book in order to do them, but they could certainly achieve this by getting a used copy or borrowing from a friend.  But probably most students would buy new copies anyway, since that is the most convenient way.
This comes down to potentially conflicting principles.  Academic freedom requires that professors should be able to choose the most appropriate references for their courses, and of course the professor's own book will often be a perfect fit for the course that inspired it.  On the other hand, it's important to avoid even the appearance of assigning one's own book in order to make a profit: that would be offensive at any university, and often illegal at public universities (violating conflict of interest laws for government employees).  The American Association of University Professors statement on this subject elaborates on both of these issues, but doesn't find a good way of resolving the tension.

University policies are often more specific.  In many cases assigning one's own book either requires administrative permission or giving any royalties earned to the university.  See, for example, this report for a survey of the policies at eighteen public universities in the U.S.  My impression is that private universities are more likely to be flexible about this issue, but that's not based on a lot of data.

In practice, I doubt anyone cares very much unless the textbook is particularly expensive or the class is large, but in those cases I would strongly recommend donating the royalties to the department even if it is not required.  After all, you're then no worse off than you would have been if you had assigned someone else's book.  If you're not willing to do this, then it suggests that the royalties are attractive after all and may have played some role in the choice of text.

One special case is when you have self-published the book (or own the publishing company).  That looks terrible, because there you have full control over pricing and may be earning far more than typical royalties.  This is one of the few cases where I believe a strict rule is appropriate: if you are legally authorized to offer free or at-cost copies of your book to your students, then you should do so.  Anything less is clearly taking advantage of your students.