I'm currently writing an article for school in literate Haskell, which is basically a file format/syntax that's a LaTeX document but for anything written in \begin{code}...\end{code} is code that could compile into a library. (So something like following)

Now we'll implement a mapping from $x$ to $x+3$

f x = x + 3


But if my knowledge is correct, GPLv3 (which is the license I would like to use) is a license for code, not documents. Which made me think does this mean I'll need to license my work under two licenses? Like GPLv3 (for code) and CC-BY-SA (for documentation)? And if that's the case, what will my LICENSE.txt file's format be like?

Perhaps something like following?

License for code:
(Paste GPL here)

License for others:
(Paste CC-BY-SA here)

P.S. Notice (another complicated part is) that the code parts and documentation parts are all contained within one single TeX/PDF file. Hence licensing on a file-by-file basis won't solve my issue.

  • 2
    Do you want people to be able to edit your document (e.g. to change the wording) and produce derivatives of that under the same conditions (i.e. that they also must deliver the corresponding source to the LaTeX document itself) ? If so, then GPL probably makes sense for the whole document as well. "Source code" in GPL terms just means "the preferred form for making modifications to it." For example, if someone gives me a mathematical or technical document only in PDF form, then in my opinion, it's not source code by the GPL's definition. A .zip file with all the .tex files I need would be.
    – Brandin
    Sep 12, 2022 at 12:10
  • 1
    It seems just like source code with an idiosyncratic syntax for distinguishing verbose “comments” from code. Oct 11, 2022 at 23:22
  • 1
    This is probably more on-topic for opensource.stackexchange.com/ Oct 12, 2022 at 9:15

1 Answer 1


There is nothing about the GPL (any version) tha says or implies that it may or shouyld br used only for code. It is not uncommon that an entire package, incl;uding both code and documentation, is put under the GPL. It is true that the GFDL was designed to work with the GPL for documentation, but it was pretty clearly intended for complete documents, stored in complete files. A CC-BY-SA license could also be used in such a case, or any of several other licenses. When code and documentation are mixed together in a single file, as in your example, I think it is bertter to use a single license for both, and the GPL would be quite adequate for the purpose.

  • Well, GPL does refer to "source code form" and "object code" quite a bit, but it does explicitly define both of them. For example, 'object code' is defined as anything other than the source code form of the work, so for something like this, probably even a paper printout of a technical document could be considered 'object code' if it is distributed under a GPL license.
    – Brandin
    Sep 12, 2022 at 12:33
  • 1
    PDF files are in practice “object code” with corresponding source code. If you send me a GPL-licensed pdf file I expect I can ask you for the source code, that is the original document that you converted to pdf. A printed book, even more so. I should be able to print a new version with the name of a character changed.
    – gnasher729
    Feb 9, 2023 at 7:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .