I am currently producing a new edition of an old book of mine; this new book will incorporate code samples from several different computing environments. I can using the listings package quite happily for this.

My question - and it's more a general typesetting/layout question than a TeX/LaTeX question - is how do you best differentiate the two codes in your document? I can of course say so in the text:

This is how it's done in foogle:

and this is how it's done in scronk:


assuming I've defined the styles foogle and scronk. And I can set up the styles so that they have different borders, backgrounds, etc. The idea is that glancing over the page it should be immediate to see what code sample relates to which language.

Is there a "best practice" for this sort of thing? Most texts concentrate on just one language, so this is rarely an issue.

Note: the book will be printed in black and white, with only a few pages in color.

Following from Jubobs' comments, what would be nice is a sort of gray box with a title indicating the system being used in the bottom left of the frame, with an appearance (except for position) of How to insert title in mdframed?, and that frame containing the code. I don't need all the functionality of listings; in fact something like fancyvrb would do fine, if it allowed colored backgrounds.

And in fact it turns out that the tcolorbox does provide an easy way to put a title on a frame, as shown here: Combining `tikzpicture` and `lstlisting` and in fact I can make this work. I need to do some more fiddling to work out the best way of doing it, though.

closed as off-topic by jub0bs, Jesse, Masroor, Heiko Oberdiek, Sean Allred Apr 29 '14 at 13:23

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Depending on the languages, I wouldn't have any particular visual difference between the two (certainly nothing drastic). I would just have them be listed separately: Foogle Listing n and Scronk Listing k. – Sean Allred Apr 29 '14 at 3:19
  • Maybe the languages have identifying symbols or logos. You could put them in the header or margin. – Stephan Lehmke Apr 29 '14 at 7:10
  • Aside from Sean's idea, I also suggest putting your listings in tcolorboxes, but use tints of complementary colours (e.g. aquamarine and red-orange) for the two languages in question. That way, your readers should be able to differentiate the two immediately. Hmmm... perhaps your question would fit better on GraphicDesign.SX... – jub0bs Apr 29 '14 at 7:11
  • Feel free to reverse my edit if you don't like it. – jub0bs Apr 29 '14 at 7:53
  • 4
    This question appears to be off-topic because it is more about graphic design than TeX. – jub0bs Apr 29 '14 at 12:46