6

I apologize that this is not strictly a LaTeX question, but I thought this StackExchange would be most suitable; all of what I describe below is done in LaTeX, BTW.

In my thesis I want to make sure that certain examples are illustrated with attached code; while I could put the code as files on my personal webpage, I would prefer if the thesis could be self-contained because you never know what might happen in 10 years: the webpage might be gone, while someone actually wants the code and has a paper/PDF version of the thesis.

However, putting too much code is pointless, because it is difficult to see someone typing 5-20 pages of code. I thought of doing something new: encoding my code using QR/Data Matrix and putting the resulting images as figures.

I was wondering how would you go about it, if at all? The style I am using for typesetting is Classic Thesis.

BTW: My initial approach would be to use square QR codes (they are most popular) of the largest possible size and stack them if necessary (vertically, two blocks per page). The QR codes would be generated automatically from live program listings using a Makefile (file.cpp -> file.pdf) and attached to the thesis project.

Comments regarding data capacity: While comments about capacity are clearly relevant here, a 144x144 square encoded as Data Matrix would contain about 2300 ASCII characters. However, using special encoding modes can bring this up to about 64,000 characters (most code is made of letters and whitespaces). Also, using 80 characters per line is a flawed methodology because multiple lines have very little to no characters. Finally, nothing stops one from using multiple squares to do the encoding.

  • Is the question about how to generate the QR code (off topic in this site) or how to typeset the QR code in LaTeX? – jub0bs Oct 10 '13 at 21:53
  • I know how to generate QR codes; what I want to know is how to typeset them in LaTeX to make it all look "edible", or if putting QR codes in a LaTeX-typeset thesis is at all something I should do. – ANSI C Mastah Oct 10 '13 at 22:03
  • 1
    Text files can be embedded in the PDF with the embedfile package. – egreg Oct 10 '13 at 22:16
  • According to QR storage, the biggest number of characters you're able to store would be 1,852. At 80 characters per line, that about 25 lines of code, per QR code... – Werner Oct 10 '13 at 22:17
  • If you want the code to go with your thesis, just put it in the Appendix. It's simple, clean, and most important, it's readable with naked eyes. There is no good fit for QR codes here. – juliohm Oct 10 '13 at 22:34
  • Egreg: I want to add program listings as QR codes to conserve space and make them 'machine-readable', so anyone with a scanner or maybe a webcam can quickly get text files without the need to manually type text. – ANSI C Mastah Oct 10 '13 at 22:39
  • Werner: According to Wiki, a readable (after printing and scanning) qr code can store 48 seconds of 32kbps ogg file per A4 page: link. – ANSI C Mastah Oct 10 '13 at 22:42
  • Juliohm: I will have algorithms written using pseudocode; however, i want to put 'example codes' in a form that can be quickly copied and compiled; putting text in appendices would take way too much space. – ANSI C Mastah Oct 10 '13 at 22:42
  • 2
    I'd think twice about this. One downside of encoding your source code in QR is that your reader won't be able to parse it without a machine. I can imagine the confusion and irritation of your reviewer(s) as a result... – jub0bs Oct 11 '13 at 08:21
  • 1
    I would just put the code in a public repository (either GitHub, BitBucket or any other provider) and link to the example code in your document. And add contact information in your thesis, so the keen reader can contact you for the source code if he/she cannot find it online in 10 years. Also, if you put in the code examples as appendix, they are also machine-readable. – Habi Oct 17 '13 at 08:41

1 Answers1

1

As noted in comments, this is borderline for off-topic. My suggestion from a typesetting point of view would be do not do this. If you want to include large amounts of data with your thesis, do one or more of

  • Go for the traditional approach of a printed appendix
  • Include a CD/DVD containing the data with your printed thesis
  • Provide a link to a data store you feel is reasonably-likely to remain available
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036