I have seen the similar question here Does "the GPL doesn't cover the ouput of a program" also apply if...... However, I think the use of LaTex to write a book with code examples that were licensed under Gplv3 is a different case. There is also this similar question How could I copyleft a document that contains a substantial amount of both code and prose?, but they didn't have code examples in text already licensed under Gplv3.

If I was to write a book in LaTex and,

  1. Protect its source code and by proxy the text to be printed in pdf format with Gplv3.
  2. It contained code examples in text previously covered under Gplv3 to be printed in pdf format.

It seems like the pdf will also be covered,

  1. Because the source code contains all text in the pdf book.
  2. Adapted code blocks in the source code that are printed in the pdf book are covered under gplv3 per the terms of the license.
  3. There are no user defined inputs and the output is always the same because its just compiling and producing the pdf book.

Is my interpretation incorrect?

  • 1
    I don't know LaTex well; is this a duplicate in terms of question scope? opensource.stackexchange.com/questions/2735/…
    – apsillers
    Commented Mar 17, 2022 at 20:07
  • 1
    It is very similar, but I did not come across before because of the way the question is asked. It does appear that the pdf is considered "object code" or a derivative work. My question doesn't ask in reference to a use of a template, but the answer is likely the same. A diffinative answer in this instance would be nice for searchability. Also different from the previous gpl version version 3 allows pointing to a github repo in text and source. Additionally, the op seems uncertain in their interpretation with the respondent providing clarity in a round about way i.e., did not say yes, correct Commented Mar 17, 2022 at 21:03
  • 1
    Looking it over, I agree: your case doesn't concern a template and probably deserves a simpler answer than that other question, which would be good for readers (and yourself) who don't need an answer to the additional questions posed there.
    – apsillers
    Commented Mar 17, 2022 at 21:06
  • 1
    Alternatively, other respondents suggest in terms of use of the template the pdf would not be covered under gpl. Thus, I think this question could use a "definitive" answer. Commented Mar 17, 2022 at 21:10

2 Answers 2


As apsillers says very clearly in Does "the GPL doesn't cover the output of a program" also apply if the output is source code?, "the license of a program's output data is a function of the license on the particular input data used to produce that output, rather than a function of the license on the program that performed the input-to-output conversion". Not only is the case you quote - using LaTeX to produce a PDF of a program's source code - not an exception to this rule (as you suggest), it's one of the more perfect examples of the rule I have come across.

That is to say, if you take GPLv3 source code and so typeset it, then yes, the output PDF will most definitely be covered by GPLv3; if you did the same with CC BY-SA code, the output PDF will be covered by CC BY-SA or a specified compatible licence; and so on. In no such case will the output PDF be covered by the Latex Project Public Licence simply because it was made with LaTeX, whose distribution and modification is governed by the LPPL.

  • (Part 1) While I fully agree with the first paragraph of your answer, I have questions about the second part. You wrote "the output PDF will most definitely be covered by GPLv3". This sounds like there is no other way to do it. My interpretation is that the book will cover much more than just the code of the GPL-licensed software (and it is different from the purpose when Zimmermann published PGP code in a book. If that is a common (obvious) assumption, --> Part 2 Commented Mar 20, 2022 at 10:09
  • (Part 2) ... then why would you exclude concepts such as using the code in the book under 'fair use' or 'right to quote' copyright exceptions, or even as an Aggregate (the theories of 'Linking' or 'Dependencies' in software are certainly not applicable within the text of a book)? Commented Mar 20, 2022 at 10:09
  • 1
    Fair use rights are vanishingly small in many jurisdictions, and should not form the basis of a business plan. As for part 1, please read what I wrote: if you take GPLv3 source code and typeset it, the resulting PDF will definitely be covered by GPLv3. If you typeset GPL source code plus some text under other licence(s), the licence on the output will be, as you say, more complex. But that takes us to Drauglis v. Kappa Map Group, and other places I didn't want to go in my answer, so I kept it simple and considered only the PDF resulting from typesetting GPLv3 source.
    – MadHatter
    Commented Mar 20, 2022 at 18:50

While it is possible to put the entire PDF under GPL license, I would not do it. The reason is that any distribution of the PDF itself would trigger the requirement to also provide the source-code of the PDF. See the ansers in the GPL-FAQ. Of course you could have a license statement in the PDF which points to the download-page for the PDF-source-code. But GPL is not made for books.

If you just use code snippets under GPL and not the complete code of a library or app, you could claim to use it under the fair-use rights, and then you can put your book under any license (even commercial) you want. I have seen that concept used a lot in printed books, you just should not overstretch the fair-use goodwill and provide proper license and attribution language. There is an answer to another question on this site, which explains the 'right to quote', which might also be interesting for you to read.

Another way would be to create the book as an 'Aggregate', where you clearly identify each source-code snippet with the appropriate license and attribution (you can do that with a foot note and put the boring language into an exhibit). This way you can have the code of the software you copied in with its original (GPL) license, and you can put the rest of the book under a license that is more appropriate for literature, such as CC-BY-SA. In the same way you can also include code snippets from other software with licenses that might be incompatible with GPL.

  • 1
    I have no problem providing source code. Based on my interpretation OF GPLv3 I could just add a pointer in the beginning of the pdf to a github repo containing the LaTex source code. Link: gnu.org/licenses/quick-guide-gplv3.en.html Commented Mar 18, 2022 at 12:45
  • I assume attributation doesn't make them an author of the book? I know it makes the owner of their parts and code contributor, but does contributor = author? Commented Mar 19, 2022 at 6:11
  • 2
    @DevonOliver Providing proper attribution to the copyright owners of the code you are showing does not make them co-authors of your book. I know what a contributor in a software project is, but I don't think the same concept applies to authorship of a book. Commented Mar 19, 2022 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.