Under U.S. copyright law, the legality of a specific work of fanfiction is primarily determined by three legal doctrines: (1) the underlying source work's copyrightability; (2) the derivative work right; and (3) fair use. The first thing to understand about making a legal fan fiction is that it is not a new concept. Literary fans have been writing stories about their favorite characters for years now, and many of these stories have become officially published works under various names. The most common way for literary fans to express themselves about their favorite subjects is through fan fiction. Fan fiction is when authors write stories about their characters using information from other sources, such as other books or movies. Fans often copy large sections of text from their sources and paste them into new stories. Sometimes they change small details to fit with the character's world building or different themes may be explored. For example, one could write a story in which Batman fights against Superman if one did not know who was good and who was evil at the start of a movie/book series. There are many more examples that can be given but this should give you an idea of how literary fans interact with their sources material. Because fan fiction involves copying large chunks of text from other sources, it is important to understand what rights those original authors might have asserted or implied over their work.