Submission Deadline and Voting are over, thank you for participating!



  1. Gonzalo Medina – 31
  2. Andy – 19
  3. cmhughes – 11
  4. mbork – 6


  1. Yiannis Lazarides – 38
  2. szantaii – 20
  3. Ant – 15
  4. Paulo Cereda – 14
  5. Count Zero – 13
  6. Aditya – 12
  7. Andrew Stacey – 9
  8. Max Lambertini – 7

The votes were counted at the end of the one week voting period, Nov. 25, 2011 14:00 UTC.

Congratulations to Gonzalo and Yiannis! And a big thank you to the twelve submitters, the high number of votes and views shows that the community took great interest in your work. As for the prizes, I think we're still waiting to hear back from Stack Exchange, so you'll have to be patient, sorry :(.

And here's the contest post itself:

What's going on?

TeX.sx turned one on November 11, 2011. This contest is part of our celebrations. This question doesn't meet the normal question form requirements on this site, but it is considered an exception, and was approved of on meta.

What's the task?

Show off the knowledge in TeX & friends that you've gathered over the time. Include things that a more-or-less everyday document can benefit from.

Final number of submissions: 12

Any conditions my document has to fulfill?

  • Form

    • Limit your document to a few pages, maximally three or four. Additional pages for a title page, table of contents, an index etc. are allowed.
    • All common formats (LaTeX, Plain TeX, ConTeXt) and engines (pdfTeX, XeTeX, LuaTeX) are allowed. However, the "ingredients" are limited to things provided on CTAN or otherwise easily publicly and freely available, so that everybody can reproduce and compile the document.
    • The source must be included and you agree that other users can reuse your code.
    • Annotate your source extensively, so that non-expert users can understand which package and which hack does what.
  • Contents

    • Your document should mainly be text, but content doesn't matter -- feel free to show the most beautiful lorem ipsum ever. Reuse of something you have already written earlier is fine as well.
    • Academic paper-like submissions are as welcome as cooking recipes, role-playing game sheets, CVs or anything text-based that can be produced with TeX & friends. [see "Update"]
    • Include whatever visual stimuli you can think of, e.g. figures, tables, margin notes, background pictures, drop caps / initials — but in the end, it has to look good, not cluttered.
    • Make it typographically, aesthetically and perhaps even funwise maximally appealing.

How do I participate?

  • Post your submission, in an answer to this question and delete it immediately — in consequence, it won't be publicly visible, but the site moderators can restore it later.

  • When you add a new answer, please edit the question to update the current number of submissions.

  • Include 1) screenshots of your output, 2) the full compilable code, and 3) links to any additional material that needs to be downloaded. Specify if a particular compiler or compiling sequence is required. This question will be locked on Nov. 18, 14:00h UTC, so that no more answers can be added. Then all answers will be undeleted and voting starts.


Yes, there will most likely be prizes, but it hasn't been decided yet which in particular, see Which prizes for contests?. Besides that, chances are you enjoy TeX & friends at any rate, there are the usual answer badges to win (no reputation though), and the community can benefit from contributions enormously!

Who determines the winner; who votes?

You do!

Once the submissions are visible, you can vote for all submissions that you want to support. Thus, each TeX.sx user has as many votes as there are submissions, but each submission can only get one vote from each user. Downvoting is possible but, but strongly discouraged. If you feel you have to downvote, please explain why in a comment (e.g. if a document is in HTML instead of TeX or one of its friends). You can determine what you consider a good contribution, things to consider are:

  • Are above conditions met?
  • Is the submissions useful for other users of TeX & friends?
  • Is the source comprehensibly annotated?
  • Do you enjoy the submission?

Voting ends after a week, I'll try to note down the vote counts Nov. 25 around 14h UTC, these will determine the winner, regardless of votes cast afterwards.

A note to high rep users

You might be able to see the temporarily deleted submissions. You've proven trustworthy to the community in the past, so just pretend you couldn't see them.

Please lock the question on Nov. 18, 14:00h UTC and undelete the answers. Rollback any edits to the contributions after this deadline.

Any help in overseeing this contest is highly appreciated.

Update (per meta)

  1. There is a limit of three submissions per user.
  2. There are two categories: academic and other. Please indicate to which one your submission belongs. The result of the voting will be split into these categories.

None of this is in any way legally binding. TeX.sx and I reserve the right to change all conditions of this contest at any point as it seems reasonable to us. (We don't plan to, though.)

  • 1
    If you have any questions or comments about this contest, please don't comment here, but on meta.tex.stackexchange.com/questions/1966/….
    – doncherry
    Commented Nov 11, 2011 at 14:13
  • 4
    Shouldn't it be "TeX" skills without the "La" part? Commented Nov 11, 2011 at 16:56
  • @KhaledHosny: Have a look at the discussion page I linked to in the comment above yours.
    – doncherry
    Commented Nov 11, 2011 at 17:23

12 Answers 12


Here is a small bag of tips and tricks that I use to improve the handling and presentation of images in publications, which I want to share with you.

enter image description hereenter image description here

Use non-floating images

Most people think that the only way to insert an image in a publication is by using the LaTeX environment \begin{figure}...\end{figure}. This has many advantages but also many disadvantages. Inserting images directly into the text i.e., by using the macro \includegraphics[]{} gives you full control, but also full responsibility for the layout.

Enclose them in minipages

It is better to use an approach similar to HTML/CSS and use divs to enclose these, except these boxes are now minipages. You can the resize them to suit the layout as well as move them in any direction using vskip and hskip or the LaTeX equivalent of hspace and vspace. All the page layouts shown here were achieved using such an approach.

enter image description hereenter image description here

Use \newgeometry and \restoregeometry.

Sometimes it is much easier to adjust a layout by simply using the geometry package's new commands, \newgeometry and \restoregeometry.

enter image description hereenter image description here

Create a TeX Database

Another useful technique is to store all the images in a TeX database. This is not as complicated as it sounds. Remember that any macro actually can be used to store information. What I do is something resembling the following:

enter image description hereenter image description here

Create variations of commands using \csname..endcsname holding the data for each image.


These are created automatically via a command \addtoDB{}{}{} or similar. This also adds the original name into a list, which acts as the index.


This enable easy use of multiple images, in a @for loop. This is how the images above were inserted. The techniques can be used for almost everything, for example see some of the code at Cunning (La)TeX tricks and Adding a list of bios to the book class.

Keep the main file code to a minimal by leverage the filecontents package.

While developing pages, if you write everything in one file the code becomes bloated and confusing. What I do is to develop the page, first in the main file and then to use filecontents to write it to the file. I then delete the relevant section and use \input to load it onto the main file. I find it easier than opening and closing too many windows. I also use this to develop small packages, have the code first in the preamble, test as you go and when I am happy delete the filecontents. An example of how to use this can be found at internationalization. In What is a good strategy to internationalize a document class?, I used this technique to create a package-on-the-fly for whoever was to use the MWE.


Use a bit of innovation for these layouts see for example the images below which have a three column caption. (I use the caption package for numbering).

enter image description hereenter image description here

I am currently incorporating all these into a class. Unfortunately the code is too lengthy to post here and also the class is not in a shape that I would feel comfortable to upload it to ctan yet. With LaTeX's 3 coffins, I think I can also leverage the layouts a bit more and publish it sometimes over the next few months.

In the meantime if you need any help to incorporate these suggestions with what you are busy with, post a question and I can extract some of the code to help you out.

enter image description hereenter image description here

Not only for Modern books

The last example is from mathematics, from Newton's Principia. The left figure below shows my attempt using LaTeX and a bit of modern approach. The image on the right below is a scan of the original page. This was achieved using wrapfig and a minimum of manual adjustment, just a negative vskip a few points up to position the image better.

enter image description here enter image description here

All the tools are here, go and make great books. thanks for reading this far.

  • 4
    Those look awesome, looking forward to seeing the code on CTAN. Also, thanks for the comment about filecontents. Although I have used filecontents numerous times to compose MWE for this site, it never occurred to me to use it the way you suggest. I will certainly start taking advantage of that right away. Commented Nov 18, 2011 at 17:09
  • 2
    Fantastic, Yiannis! :) Commented Nov 19, 2011 at 9:02
  • Sorry, no edits after the deadline, no matter how minute they may be. I rolled your answer back to the version submitted before the deadline.
    – doncherry
    Commented Nov 19, 2011 at 18:22
  • @doncherry Sorry had a few typos, did not realize this was part of the rules.
    – yannisl
    Commented Nov 19, 2011 at 18:45
  • 3
    I have to admit I find it strange this won, when it's really the only one without any actual (La)TeX! Nevertheless, beautiful pics.
    – Steve D
    Commented Dec 7, 2011 at 4:28

My contribution is the little package gridleno.sty whose code I include below. This package was designed to enhance the functionality of grid.sty regarding the difficult task of grid typesetting in double column LaTeX documents. The package still needs a lot of improvements, this is only a starting point.

The package was conceived to help producing lecture notes in the spirit of the question How to add some visual style and pizzazz to course notes? and the popular answer by Yiannis Lazarides. In fact, some days ago in the chat room, Yiannis himself suggested me the idea of writing this package for the contest.

The images below illustrate the basic layout and some of the features provided by the package. The code for the sample document can be found here in pastebin (it was the first time I used the LaTeX way \(...\) for in-line math instead of $...$; all I can say is that old habits die hard and that it was probably also the last time ;-)).

enter image description here

enter image description here

enter image description here

A brief description of the package:

Usage: load the package after having loaded the grid package in a LaTeX document :


Some of the features implemented by the package

  • Theorem-like structures:

    Predefined styles= proofstyle, thmstyle, defistyle, remastyle (similar to those of the amsthm package).

    Predefined environments: proof, theorem, proposition, corollary, lemma definition, example, remark.

  • Special environments and commands:

    summary: shaded environment, with a centerd "Summary" header and italiziced text indented 10pt on both sides.

    grcmpage: a shaded minipage; it takes two mandatory arguments: the minipage width and the shading color (thanks to egreg for his decisive help in his answer to my question How to keep a constant baselineskip when using minipages (or \parboxes)?).

    exercises: centered header "Exercises" with rules on both sides. Inside this environment enumerate is redefined to produce a list with 0pt left margin for the first level.

    \makeheader produces a framed box in all the pages of the document. The box contains information about the course. This box borrows some code from the file rvdtx.sty (used toproduce the documentation of the grid package).

    The commands \course, \courseid, \professor, \term, \topic (one mandatory argument) are used to define the course information; these commands do not typeset anything; the actual typesetting is done throught the \makeheader command.

    Some commands to allow the redefinition of the predefined names.

Other features:

The caption headers are colored by default.

\refname has been redefined to produce "Suggested Readings".

\@biblabel was redefined to produce bullets instead of the standard labels inside the thebibliography environment.

The predefined colors can easily be changed.

The default color schema uses some of the colors of the TeX.SX site, as an homage to its first birthday.

The file gridleno.sty:

%% This is file `gridleno.sty',
%% Copyright (C) 2011 Gonzalo Medina
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.


% some colors that will be used (taken form the colors used at TeX.sx)
\definecolor{headtitle}{RGB}{167,63,63} %(red)
\definecolor{headbg}{RGB}{244,218,151} %(yellow)
\definecolor{grlngreen}{RGB}{208,212,171} %(green)
\definecolor{grlnblue}{RGB}{100,169,212} %(blue)
\definecolor{grlngray}{RGB}{76,76,74} %(gray)

% we set the colors for the different elements

% definition of user commands to define course, professor, the course id,
% the topic and the term; the date is produced with the standard \date.
% \makeheader will actually typeset this information.

% default values for the different names used
\newcommand\lecturenotename{Lecture Notes}

% when invoked, \makeheader will produce the header box
% with information about the course, topic, professor, term, date.
% The background package is used to place this header in all the pages
% of the document.
          \color{headtitle}\Huge\lecturenotename \\[6pt]
          \fontfamily{cmr}\fontsize{17pt}{20pt}\selectfont\scshape\@topic \\[6pt]
            \coursename  & \@course\ \@courseid \\[1ex]
            \termname & \@term \\[1ex]
\SetBgPosition{current page.north}

% definitions for \section, \subsection and \subsubsection
\renewcommand\section{\@startsection {section}{1}{\z@}%

% predefined theorem-like styles defined with the thmtools front-end
% using amsthm as the back-end

% \qedsymbol will be a colored solid square

% style for the proof environment
spaceabove=\baselineskip, spacebelow=\baselineskip,
notefont=\mdseries, notebraces={(}{)},

% style for theorems, propositions, corollaries, lemmata
spaceabove=\baselineskip, spacebelow=\baselineskip,
notefont=\mdseries, notebraces={(}{)},

% style for definitions and examples
spaceabove=\baselineskip, spacebelow=\baselineskip,
notefont=\mdseries, notebraces={(}{)},

% style for remarks
spaceabove=\baselineskip, spacebelow=\baselineskip,
notefont=\normalfont, notebraces={(}{)},

% predefined theorem-like structures




% enumerate-like environment designed for the exercises
% first level labels without indentation.
  \ifnum \@enumdepth =\z@\addtolength\labelwidth{-5pt}\else
    \ifnum \@enumdepth =\@ne\addtolength\labelwidth{-1pt}\else
  \ifnum \@enumdepth >\thr@@\@toodeep\else
        \csname label\@enumctr\endcsname
\let\endexenumerate =\endlist

% An environment similar to minipage but keeping a constant
% baseline before and after; it only has one mandatory argument
% controlling the minipage width

% An environment for shaded minipages but keeping a constant
% baseline before and after; the first mandatory argument sets the 
% minipage width and the second mandatory argument sets the
% shading color (default: white)  

% environment for a summary
     \parshape 1 10pt \dimexpr\linewidth-20pt\relax\itshape}

% similar to \hrule but above the base line
\def\Hrulefill{\leavevmode\leaders\hrule height 0.8ex depth -0.6ex\hfill\kern0pt}

% environment for exercises: facy title and redefines enumerate as exenumerate
% to remove labels indentation

% caption label will receive a color

% \refname will produce "Suggested Reading" and \@biblabel will
% produce a bullet
\AtBeginDocument{\renewcommand\refname{Suggested Readings}}
%% End of file `gridleno.sty'.
  • 1
    Awesome code, Gonzalo! Congrats! :) Commented Nov 19, 2011 at 9:04
  • @GonzaloMedina, awesome! I am trying to LaTeX your code, but I keep getting errors. One error is due to extra spaces in \ definecolor{grlngray}{RGB}{76,76,74} %(gray). After I fixed that, I still get the following error: miktex-makemf: The fourier-bb source file could not be found. Commented Nov 29, 2011 at 22:24
  • @dochar: Thank you. Yes, those spaces are superfluous and shouldn't be there; it was something the site added automatically when I pasted the code... so, don't leave blank spaces between ` and definecolor. As for the other error, it seems as if your system doesn't have the fourier` fonts; try commenting out the line \usepackage{fourier}. Commented Nov 29, 2011 at 22:28
  • 1
    That's a very good template!
    – user10130
    Commented Dec 19, 2011 at 22:16
  • 2
    @GonzaloMedina Just came across this and I can hardly believe it...this is incredible what you have done. Can't wait to use this for months to come! The design is awesome!! Commented Aug 6, 2015 at 11:10

I prepared a two page sample of my lecture notes. The general book design is heavily inspired by Edward Tufte, R. Bringhurst and the tufte-latex-class. Then, with the advent of e-books, I wanted something that can be prepared for many different reader devices. It turned out that LaTeX is about the perfect tool to achieve this. I came up with some kind of markup in the document and different style files to optimize the text for different devices. I prepared a few book pages and a kindle document as an example. The main concern was to allow an automatic preparation of all output files out of one input file. It would consume to much time to optimize the handout, the book chapter, the kindle file etc.

I used lualatex, biblatex and the beta version of microtype. The style files are available on Github and the additional functionality is provided by the sidenotes package on CTAN.

Please note that recto and verso page and incorrectly next to each other in my screenshot to allow a 'book' look with only two pages.

example book example kindle


% auto adjust the marginals
% -- provide more floats

% -- graphics --

% -- language: German --

% -- biblatex --
\usepackage[backend = biber, style = cleopatra,language=american]{biblatex}
% fix export function of papers

%% -- start --
\smallfigure{c01_01_Onnes}{Heike Kamerlingh Onnes. © Museum Boerhaave.}
\smallfigure{c01_02_TransitionHg}{Erste Messkurve des supraleitenden Zustands, replot nach Kamerlingh Onnes.}
Der Begriff \emph{Supraleitung} geht auf die Beobachtung zurück, dass unterhalb einer kritischen Temperatur manche Materialien ihren elektrischen Widerstand sprunghaft verlieren. Dies wurde erstmals 1911 von Heike Kamerlingh Onnes beobachtet.\reference{}{}{Kamerlinghonnes:1911p1320} Abbildung \ref{c01_02_TransitionHg} zeigt eine Reproduktion der ersten Messkurve aus seiner Originalarbeit, die in Leiden veröffentlicht wurde. Kamerlingh Onnes erhielt 1913 den Nobelpreis für Physik \quotetext{for his investigations on the properties of matter at low temperatures which led, inter alia, to the production of liquid helium}.\reference{}{}{nobel:onnes} Das charakteristische Merkmal der Supraleitung ist jedoch der Meißner-Ochsenfeld-Effekt.
Stellen wir uns folgendes vor: Ein hypothetisches Material \tinyfigure{c01_Meissner10} sei ein Metall, welches oberhalb einer bestimmten Temperatur einen endlichen elektrischen Widerstand besitzt. Nun kühlen wir das Material \tinyfigure{c01_Meissner8} ab und es verliert seinen elektrischen Widerstand. Schließlich wird ein magnetisches Feld \tinyfigure{c01_Meissner7} eingeschaltet. Die Änderung des Magnetfelds führt zu Induktionsströmen im Material. Diese wirken nach der Lenzschen Regel ihrer Ursache entgegen und führen zum Verschwinden des Magnetfelds \tinyfigure{c01_Meissner2} im Inneren des Materials. Da kein elektrischer Widerstand vorhanden ist, können die Induktionsströme ewig weiter fließen. Jetzt ändern wir die zeitliche Abfolge von Abkühlung und Anlegen des Magnetfelds. Zunächst wird das Magnetfeld \tinyfigure{c01_Meissner5} eingeschaltet und nach dem Abklingen der Induktionsströme ist das Material vom Magnetfeld \tinyfigure{c01_Meissner4} komplett durchdrungen. Dies ändert sich auch nicht, wenn es abgekühlt wird, da es keine Flussänderung gibt. Der Leiter bleibt in einem felddurchdrungenen \tinyfigure{c01_Meissner3} Zustand. 

Nun werden diese beiden Experimente mit dem Supraleiter wiederholt. Auch dieser hat oberhalb einer Temperatur, die in diesem Fall kritische Temperatur genannt wird, einen endlichen elektrischen Widerstand \tinyfigure{c01_Meissner10}. Unterhalb der kritischen Temperatur ist er im supraleitenden Zustand \tinyfigure{c01_Meissner9} ohne elektrischen Widerstand. Wird im supraleitenden Zustand ein Magnetfeld \tinyfigure{c01_Meissner6} eingeschaltet, haben wir den gleichen Fall \tinyfigure{c01_Meissner} wie vorher. Nun wird in einem neuen Experiment der Supraleiter zunächst einem Magnetfeld ausgesetzt \tinyfigure{c01_Meissner4} und danach abgekühlt. Der Supraleiter \tinyfigure{c01_Meissner} verdrängt immer das Magnetfeld. Er kann nicht je nach Vorgeschichte in verschiedene Zustände gebracht werden. Der supraleitende Zustand ist also eine thermodynamische Phase und der Übergang vom normalleitenden in den supraleitenden Zustand ist demnach ein Phasenübergang.\reference{Siehe z. B.:}{}{nolting4}

Insgesamt wird das Verhalten \tinyfigure{c01_Meissner} nach den beiden Physikern Walther Meißner und Robert Ochsenfeld als Meißner-Ochsenfeld-Effekt bezeichnet.\reference{}{}{Meissner:1933p7229} Es kann nicht allein aus $R=0$ abgeleitet werden. Es sollte als charakteristisches Kennzeichen der Supraleitung angesehen werden, da ein Material ohne elektrischen Widerstand nicht alle Eigenschaften eines Supraleiters zeigt. Angemessener wäre der Begriff \emph{Superdiamagnet}, historisch hat sich aber der Begriff \emph{Supraleiter} durchgesetzt.
Betrachten wir eine Minispule in der ein Kreisstrom fließt. Der Strom $I$ und der magnetische Fluss $Φ$ können über die Induktivität $L=Φ/I$ verknüpft werden. Die kleinste Einheit von sich bewegenden Ladungen ist die Elementarladung $e$ des Elektrons. Es sollte also auch der magnetische Fluss $Φ$ quantisiert sein, denn der Kreisstrom kann nicht stufenlos eingestellt werden, sondern es müssen Vielfache der Elementarladung in die Runde fließen. In einem supraleitenden Ring sollte dies besonders einfach untersucht werden können, da ein einmal induzierter Kreisstrom ewig weiter fließt. Doll und Nähbauer haben 1961 solche Messungen veröffentlicht,\reference{}{}{Doll:1961p3784} eine Wiedergabe dieser Messungen ist in Abbildung \ref{c01_06_FluxQuantization2} gezeigt. Deutlich sind die Stufen zu sehen, welche die beschriebene Quantisierung zeigen.
\smallfigure{c01_06_FluxQuantization2}{Magnetische Flussquantisierung in einem supraleitenden Ring.}

Wie im Abschnitt zuvor, wollen wir uns an dieser Stelle überlegen, was zu erwarten wäre. London sagte 1950 als erster die Flussquantisierung voraus. Laut neuerer \textsc{bcs}-Theorie erwarten wir Cooper-Paare, die die Träger des Suprastroms sind. Die kleinste Einheit des Flusses, das Flussquant $Φ_0$, sollte somit in Vielfachen der doppelten Elektronenladung auftreten. Lars Onsager hatte dies bereits 1959 realisiert und W.M. Fairbanks mitgeteilt.\reference{Dies brachte Onsager seinen Beinamen \emph{Lars, the oracle} ein.}{}{Careri:2000p12789}

\smallfigure{c01_07_FluxQuantization1}{Magnetischer Fluss in einem supraleitenden Zylinder}
Experimentell kann also aus dem Wert des Flussquants verifiziert werden, dass der Nenner tatsächlich $2e$ beträgt. Deaver und Fairbanks haben dies zeitgleich mit Doll und Nähbauer 1961 gezeigt.\reference{}{}{Deaver:1961p3782} In Abbildung \ref{c01_07_FluxQuantization1} sehen wir einen Neuplot der Daten, der Fluss ist dabei, genau wie in der Originalarbeit, schon normiert in Einheiten von $h/2e$ aufgetragen. Dies ist ein sehr starkes Indiz für Cooper-\emph{Paare} als supraleitende Ladungsträger.

To make it easier to gather all the parts, I prepared a zip-file with all documents and pictures and the microtype beta.

  • What are the reasons for using the microtype beta version? Commented Nov 19, 2011 at 21:09
  • I had some issues with letterspacing small caps in the non-beta version. I do not think it matters in my example code.
    – Andy
    Commented Nov 20, 2011 at 14:11
  • 1
    Links are dead.
    – orlp
    Commented Dec 29, 2015 at 11:19
  • 1
    Hi, Andy! Any chance to get the the zip-file operative again? Link to Dropbox is dead. Thanks!!!
    – José
    Commented Jul 4, 2016 at 15:21
  • @Andy Just beautiful! But can you have a look at the link to your zip file? Commented Aug 15, 2016 at 17:08

This my submission in the other category for the Show Off Your Skillz in TeX & Friends Contest. I call it TypoTux, this is more like a hack than a usual typographic layout.

See source and detailed description below the picture.


% TypoTux
% Created by István Szántai
% Compiled with pdflatex using TeX Live 2011
% Use it as you like, but please send me an e-mail if you do.


% Specifying input encoding

% Using the TikZ library for drawing Tux, and clipping

% Loaded for unnumbered captions

% For inserting lorem ipsum text

% Setting baselines smaller



\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt,scale=0.25]

            % Tux's path used for clipping
            % Generated with Inkscape / http://inkscape.org/
            % Using the inkscape2tikz extension / http://code.google.com/p/inkscape2tikz/
            \path[clip] (265.5000,1063.0000) .. controls (252.9000,1061.0000) and
            % Tux's path used for clipping cut from here because it's too long to include.
            % See link for full compilable source at the end of the answer.

            % Adding lorem ipsum text using TikZ nodes, and the lipsum package
            \node[inner sep=0,text width=10cm] (text1) at (450,450) {\LARGE\textit{\lipsum[1]}};
            \node[inner sep=0,text width=10cm] (text1) at (500,500) {\LARGE\textit{\lipsum[2]}};
            \node[inner sep=0,text width=10cm] (text1) at (450,450) {\textit{\lipsum[3-4]}};
            \node[inner sep=0,text width=10cm] (text1) at (500,500) {\textit{\lipsum[5-6]}};
            \node[inner sep=0,text width=10cm] (text2) at (450,450) {\scriptsize\textit{\lipsum[7-11]}};
            \node[inner sep=0,text width=10cm] (text2) at (475,475) {\scriptsize\textit{\lipsum[12-16]}};
            \node[inner sep=0,text width=10cm] (text2) at (500,500) {\scriptsize\textit{\lipsum[17-21]}};




I always wanted to create something like this. After I read about this contest I decided to make a Tux who's drawn by text. I chose TikZ & PGF for this purpose since it's very powerful, and I used it several times before for path clipping.

Step-by-step description how I made this:

  1. Grabbed a 2D vectorized Tux image from Wikipedia.
  2. Removed colored and unnecessary white paths from the image, resized page with Inkscape.
  3. Saved the black & white image as a standalone TikZ image with Inkscape using the inkscape2tikz extension.
  4. Removed some unnecessary paths from the tex source file, changed path filling to clipping.
  5. Added nodes filled with different size of lorem ipsum text using the lipsum package. Note: this was the hardest part, because there was no other way but trying to place the text under the clip path.
  6. A little bit of fancying, and cleaning up.

Use it for whatever you want to, but please let me know if you do. I compiled it with pdflatex using TeX Live 2011.


Macro package: ConTeXt (ver: 2011.10.20)
Engine: LuaTeX
Category: Other

Block comments in TeX

In \TEX\ \type{%} creates a line comment, i.e., \TEX    ignores the material % CHECK: use text instead?
from \type{%} until the end of the line. As a result,
often % CHECK: use sometimes instead?
you have to bream lines just to comment some material.

% The line comment mechanism also makes it hard to comment
% blocks of text. A \TEX\ aware engine makes it easier to 
% add such block comments, but a powerful editor does not 
% hide the fact that \TEX\ does not have block comments.

It is possible to define a macro for block comments. For example


works well for simple comments. However, the content of such a macro is parsed by TeX, so such a macro fails miserably on input like

blah blah \hide{\iffalse} blah blah

Another option is to use buffers for block comments. ConTeXt already defines a hiding buffer for this purpose. For example

blah blah \starthiding \iffalse \stophiding blah blah

works fine. (For non-ConTeXt users, ConTeXt buffer is roughly equal to the functionality of the LaTeX fileconent and comment packages but on steroids. For the purpose of hiding content, the comment package can be used, but IIRC, the \end{comment} statement must be on a line of its own, defeating its purpose a block comment marker). Nonetheless, using buffers for block comments is not ideal. For one, it is a lot of typing! But more importantly, buffers cannot be part of the argument of another comment. So,

\section{Will this work \starthiding of course, not \stophiding}

does not work.

With LuaTeX, it is possible to have true block comments in TeX. LuaTeX allows you to intercept and filter text before it is passed on to TeX. We can write an appropriate Lua code to implement block comments as such a filter. An example, is the m-translate module which allows for creative solution to text substitution questions. For example, see:

The code below grew out of a question about block contents on the ConTeXt mailing list. Save the block below as t-comments.mkvi. Yes, that's right, the extension must be mkvi. This allows for named arguments for TeX macros (See comments on code below).

%D \module
%D   [     file=t-comments,
%D      version=2011.11.14,
%D        title=\CONTEXT\ User Module,
%D     subtitle=Block comments,
%D       author=Hans Hagen and Aditya Mahajan,
%D         date=\currentdate,
%D    copyright=Hans Hagen and Aditya Mahajan,
%D      license=Simplified BSD License]

\writestatus{loading}{Block comments (ver: 2011.11.14)}

     thirddata          = thirddata or { }
     local comments     = { filters = { } }
     thirddata.comments = comments

     local textlineactions = resolvers.openers.helpers.textlineactions
     local sequencers      = utilities.sequencers
     local constants       = interfaces.constants

     local gsub, find, format = string.gsub, string.find, string.format

     local empty_line = "%%" -- FIXME Make catcode independent!

     function comments.install(name,settings)
         local settings = utilities.parsers.settings_to_hash(settings)
         local start = string.escapedpattern(settings[constants.start] or "")
         local stop  = string.escapedpattern(settings[constants.stop] or "")
         local any   = ".-"
         if start ~= "" and stop ~= "" then
            local strip_inline     = function(s) return gsub(s, start .. any .. stop, "", 1) end
            local strip_from_start = function(s) return gsub(s, start .. any ..  "$", "", 1) end
            local strip_to_stop    = function(s) return gsub(s, "^"   .. any .. stop, "", 1) end 
            -- A simple state based parser for multi-line comments
            local insideComment = false 
            local cleaned_line = ""
            comments.filters[name] = function(s)
                local currentfilter = comments.filters[name]
                if s == "" then
                    return s
                elseif insideComment then
                    if find(s,stop) then
                        insideComment = false
                        return cleaned_line .. currentfilter(strip_to_stop(s))
                        return empty_line
                elseif find(s,start) then
                    if find(s, stop) then
                        return currentfilter(strip_inline(s))
                        insideComment = true 
                        cleaned_line = strip_from_start(s)
                        return empty_line
                    return s

     function comments.enable(name)
     function comments.disable(name)




% NOTE that I use named arguemnts \type{#name} etc instead of \type{#1}
% The translation of \type{#name} to \type{#1} etc is implemented as a
% file filter in ConTeXt. This filter is active only for files starting with 
% \type{.mkvi}. Hence, we need to save this file with that extension.

   {\ctxlua{thirddata.comments.enable (\!!bs#name\!!es)}}



This module defines three macros. The main macro is to define a block comment using

\installcomments[<identifier>][start=..., stop=...]

where identifier is the name of the block comment, and the start and the stop keys indicate the start and the stop markers. To activate block comments use:


To deactivate comments use:


Thus, this module can be used as follows:


\installcomments[C]   [start=/*,stop=*/]


Comments are /*disabled*/ right now.


Now comments are /*really*/ enabled.

\section{First /*now that is redundant*/ section}

Random text to demonstrate /*really well*/ how the concept /* of multi line
comments works. This particular example uses C style multi-line comments,
but other styles also */ work.

A/* single line comment*/B

A/* multi line
comment \iffalse
with line breaks*/B


which gives

enter image description here

The filtering of block comments is done by the comments.filters[name] function. This function reads each line one by one and removes the content inside the block comment markers. Most of the code is straightforward. The only tricky part is handling multiline comment such as

A/* multi line
comment \iffalse
with line breaks*/B

For such comments, when we encounter a line that contains a start marker but no stop marker (like the first line), we store the contents before the start marker in the variable cleaned_line, set the flag inside_comment to true, and return %. When we are inside a block comment and encounter a line that does not contain the stop marker (like the second line in the example above), we return %. When we are inside a block comment and encounter a line that contains the stop marker, we replace the text until the stop marker by the variable cleaned_line. Thus, the above example is translated to


This ensure that the output has the same number of lines as the input but no spurious white spaces are introduced in the output.

The above implementation is not perfect because we have to hard code % as a TeX comment. So, the above code will fail if we are working with a different catcode regime.

The above code is a complete working example. For ease of copying, the code is also available on github

  • 2
    Fantastic code, Aditya! You've got a fan. :) Commented Nov 22, 2011 at 8:59

Academic submission: This document is part of a project I am working on for my students- it consists of problems, examples, and solutions (at the end). The final document will be many more than 4 pages, but this part gives a flavour :)

First of all, to help you decide if you want to read the rest of my answer :), here are screen shots of my 4 pages

screenshot enter image description here

Some of the packages that are important for my document:

  • answers to typeset solutions to problems, which are included separately at the end
  • hyperref to link between the problems and solutions
  • pstricks to typeset the graphs
  • xstring to help determine if the problems are even or odd numbered
  • cleveref to get clever references

Some features that I have designed:

  • There are two booleans, showoddsolns and showevensolns which can be set as true or false. Naturally, these toggle if the odd or even solutions are shown or not
  • Both the problem and subproblem environments can take an optional argument [special] which will label it with a *. Furthermore, these 'special' problems can be listed using \listspecialproblems; this works on a per-section basis
  • If you click on the problem numbers, you will be hyperlinked to the solution; if you click on the solution number, you will be hyperlinked back to the problem
  • I have used a newpsobject to help make global changes to my graphs

Note that because I have used pstricks the code should be compiled with

pdflatex -shell-escape myfile.tex

or else through the latex-> dvips-> ps2pdf routine.

I've pasted the code on pastebin, which perhaps makes it more accessable

The code for the mainfile.tex is also below.

\usepackage[left=6cm,right=1cm,showframe=false,                 % page settings (showframe is useful!)
\usepackage{amsmath}                            % mathematical content
\usepackage{amssymb}                            % mathematical content
\usepackage[amsmath,standard,framed,thmmarks]{ntheorem} % custom enumerations *Needs to stay here, otherwise cross references can go wrong*
\usepackage{ifthen}                             % conditionals
\usepackage{xcolor}                             % colour
\usepackage{answers}                            % solutions to problems done *beautifully*
\usepackage{framed}                             % needed for putting boxes round theorems, examples 
\usepackage{multicol}                           % multicols
\usepackage{changepage}                         % needed for hanging paragraphs
\usepackage{calc}                               % calculations (such as \textwidth/2)
\usepackage{fancyhdr}                           % headers & footers
\usepackage[small,bf]{caption}                  % figures/tables in margins, and not floating
\usepackage{subcaption}                         % subfigures, subtables (replaces subfig)
\usepackage{xstring}                            % needed to determine if problems are odd or even
\usepackage{enumitem}                           % enumerate & itemize
\usepackage{placeins}                           % FloatBarrier
\usepackage{minitoc}                            % mini-table of contents
\usepackage{marginfix}                          % fixes margin notes (otherwise they can cut through pages)
\usepackage{needspace}                          % needed to keep problems looking good (stops ugly pagebreaks)
\usepackage{xargs}                              % helps with optional arguments for environments
\usepackage{booktabs}       % used with tables (allows \toprulewidth etc)
\usepackage{flafter}          % ensures that floats don't appear until after their placement in the text
% pstricks
% load the hyperref last
\usepackage{hyperref}           % to allow hyper refs in the final pdf document

                                % hyperref NEEDS TO STAY AT THE END!
\usepackage[all]{hypcap}        % needed to help hyperlinks direct correctly;
                                % note that this needs to be loaded AFTER
                                % the hyperref package; the option [all]
                                % makes hyperlinks to figures & tables go 
                                % to the top
\usepackage{cleveref}       % needs to be loaded after hyperref

% hyperref settings- it seemed to work better here rather than
% as options to the \usepackage call above

\psset{algebraic=true}           % set up options for PS figures

% custom ps options

% grid stuff

% set figure width

% setwindow command: takes 6 arguments (1st is optional)
%       [1]. aspect ratio (height = aspect ratio * width) default=1
%         2. xmin (number)
%         3. ymin (number)
%         4. xmax (number)
%         5. ymax (number)
%         6. figurewidth (length)
                           % set up xunit
                           \psset{xunit=\result pt}
                           % set up yunit
                           % set up aspect ratio
                           \psset{yunit=\result pt}%

% caption settings

% enumerate settings

% paragraph settings

% use left margin

% Define fix command
%   - it puts a comment in the margin
%   - it writes to a file with a list of things that need fixing
 \marginpar{\huge \color{red} \framebox{FIX}}%
\typeout{FIXTHIS: p\thepage : #1^^J}%


% standard environments
% custom environments
% conjunction between range; e.g Figures 1.2-1.3

%   BEGIN MARGIN ENVIRONMENTS (shamelessly copied from tufte documentclass)
% Margin float environment
  {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.

% Margin figure environment
   \capstart\endgraf}% <-- Hyperlink jumps to start of 'marginfigure'

% Margin table environment
   \capstart\endgraf}% <-- Hyperlink jumps to start of 'margintable'


% open the answer files (short, long, and hints)

% put titles in the solution files
% Begin by (re-)setting the chapter counter to 0
% which is used for hyperlinks from solutions to questions
% This allows us to put Problem 1, 2, 3, etc in every chapter
% as the hyperlinks have the form \hypertarget{soln:#1\thechapter}{}


%   BEGIN CUSTOM THEOREMS (for problems, subproblems)
% set up showoddsolns and showEVEN

% this boolean is used in the problem and subproblem definition (don't change!)

% PROBLEM environment
% \begin{problem}[1][6]
%   ...
% \end{problem}
%  [1]: description of the problem
%  [2]: special
% Both arguments are optional; the second argument
% can be left off, empty, or special. If it is non-empty
% and anything other than special (case-sensitive), it 
% will be ignored.
\newcommand{\specialsymbol}{$\bigstar$ }
            {}% true (by default)
            {}% true (by default)
    {%  NOT special problem
        % if no second argument (special or not)
        {% Problem withOUT description
                 {{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem}}}\newline}%
                 {\bfseries Problem \theproblem}\newline%
        {% Problem with description
                 {{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem} \,(#1)}}\newline}%
                 {\bfseries Problem \theproblem\, (#1) }\newline%
    {%  special problem
            % write problem number to specialfile
            {%  special problem with no description
                     {\hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem}}}\newline}%
                    \hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \theproblem}\newline%
            {% special problem with description
                {% with links
                     {\hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem} \,(#1)}}\newline}%
                {%  no links
                     \hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \theproblem\, (#1) }\newline%
        }{ \textbf{Problem} \theproblem \, (#1) {\bf\huge\color{red}special?}\par}%

% subproblem environment
            {}% true (by default)
            {}% true (by default)
        {% special problem
            {%  hyperlink to solution
                \begin{enumerate}[label=\llap{$\bigstar$ }\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem,leftmargin=*]
            {%  no hyperlink
                \begin{enumerate}[label=\llap{$\bigstar$ }\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem,leftmargin=*]
        {% NOT special problem
            {%  hyperlink to solution
            {%  no hyperlink

% definition
%   END CUSTOM THEOREMS (for examples, problems)

%   BEGIN special PROBLEMS

% redefine the \section command to increment probSectCounter
% note that this could also be done for \subsection if desired


% need a command to bring the \contentsline
% into the problemlist environment
    % renew the \contentsline command so that it just gives 
    % the problem number as a hyperlink (and no page number)
    % if we renewed the command outside of the environment, it would
    % affect \tableofcontents, \minitoc, and perhaps more- bad!
                % if we're at the beginning, no comma
                Special problems in this section (\specialsymbol\unskip): \Contentsline{##1}{##2}{}{##4}%
                % otherwise put a comma and a space
                \unskip, \Contentsline{##1}{##2}{}{##4}%

% open the appropriate file do everything in a 
% new environment so that we can renew the 
% \contentsline command locally 
\read\File to\fileline%

% enable the \jobname.prb file
% (hacked from the ntheorem package)
\expandafter\newwrite\csname tf@prb\endcsname%
\immediate\openout \csname tf@prb\endcsname \jobname.prb\relax%

% enable the \jobname.prb<counter> files at the end
% of the document


%   END special PROBLEMS

% horizontal lines

% custom chapter
\LARGE\MakeUppercase{#1} \psshadowbox{\Huge\thechapter}}

% write to the solutions files to step the chapter counter

% From the titlesec package
% \titlespacing{command}{left spacing}{before spacing}{after spacing}[right]
% spacing: how to read {12pt plus 4pt minus 2pt}
%           12pt is what we would like the spacing to be
%           plus 4pt means that TeX can stretch it by at most 4pt
%           minus 2pt means that TeX can shrink it by at most 2pt
%       This is one example of the concept of, 'glue', in TeX

\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{-5pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}




% needed for the mini-tableofcontents

\fancyhf{} % delete current header and footer



% change to one-sided mode
% change the pagestyle to plain
% change the page geometry using \newgeometry

% close the solutions files

% SHORT solution to problem (show only odd, even, all)
% Note: this renewenvironment needs to go here
%       so that the answers package can still
%       display correctly to the page if needed
    \exploregroups % needed to ignore {}
    % before the environment starts - this is a stretchable space
    \vskip 0.1cm plus 2cm minus 0.1cm%
    \fullexpandarg % need this line so that '.' are counted
    % either problems, or subproblems, e.g: 3.1 or 3.1.4 respectively
    % determine which one by counting the '.'
    % find the problem number by splitting the string
        % problems, such as 4, 5, 6, ...
        % problems, such as 4.3, 1.2, 10.5
        % subproblems such as 1.3.1, 1.2.4, 7.5.6
     % determine if the problem number is odd or even
     % and depending on our choices above, display or not
         % set a boolean that says the problem number is odd (used later)
         % display or not 
            % if we want to show the odd problems
            {\bfseries \hypertarget{soln:#1:\thechapter}{}\hyperlink{prob:#1:\thechapter}{#1}.}%
            % otherwise don't show them!
         % even numbered problem, set the boolean (used later)
            % if we want to show the even problems
            {\itshape \hypertarget{soln:#1:\thechapter}{}\hyperlink{prob:#1:\thechapter}{#1}.}%
            % otherwise don't show them!
    % after the environment finishes
        % odd numbered problems 
            % if we want to show the odd problems
            % then the environment is finished
            % otherwise we need to finish the comment
        % even numbered problems
            % if we want to show the even problems
            % then the environment is finished
            % otherwise we need to finish the comment


% set solution figure width

% input the SHORT solutions file


  • I managed to compile your code in TeXShop by choosing the "LaTeX typesetting program". However, it does not compile under "XeLaTeX" or "LualaTeX" typesetting programs. This is the first time I encountered this. Usually it is the other way around.
    – Sony
    Commented Dec 21, 2011 at 13:26
  • @Sony Interesting... I usually use latex=>dvips=>ps2pdf on this file because of the PSTricks. If you generate the graphs in something else (e.g TikZ) then you could use anything.
    – cmhughes
    Commented Dec 21, 2011 at 17:13

I created a document in which Rubik's cube is built from small cubes and demonstrated:

%Author: Count Zero
%*free to be reused both partially and in whole by anyone*


\usepackage{pxfonts}% change the font from Computer Modern to Adobe Palatino
\usepackage{marvosym}% special characters used in the document :)
\usepackage{tikz}% that's what does to the 'nice' things, that is the drawings ;)
\usepackage{lipsum}% some random text, known as 'Lorem ipsum'
\usepackage{hyperref}% enable hyperlinks

%Here the a command is defined to draw a cube (only the visible faces) in isometric view.
%The cube need not be in the origin, the distances of the bottom-behind corner from the origin are taken as parameters.
%It takes 7 (!) parameters:
%1 - length of an edge
%2 - color of the front face
%3 - color of the top face
%4 - color of the right face
%5 - x-position in space
%6 - y-position in space
%7 - z-position in space
    \pgfmathparse{#1+#5}\let\dx\pgfmathresult% calculate the 'displacement' (distance from the origin) of the far corners of the cube along the x axis from the arguments
    \pgfmathparse{#1+#6}\let\dy\pgfmathresult% calculate the 'displacement' (distance from the origin) of the far corners of the cube along the y axis from the arguments
    \pgfmathparse{#1+#7}\let\dz\pgfmathresult% calculate the 'displacement' (distance from the origin) of the far corners of the cube along the z axis from the arguments
% draw the visible faces
    \draw[ultra thick,fill=#2] (#5,#6,\dz) -- (\dx,#6,\dz) -- (\dx,\dy,\dz) -- (#5,\dy,\dz) -- cycle;%The thickest line was selected with the first option, then the color specified in the 2nd argument is used to fill the front face of the small cube. Finally the rectangle is drawn and filled. 'cycle' closes the path. The 'rectangle' command does not work with 3D coordinates, so this is the way to draw the squres with space coordinates
    \draw[ultra thick,fill=#3] (#5,\dy,\dz) -- (\dx,\dy,\dz) -- (\dx,\dy,#7) -- (#5,\dy,#7) -- cycle;
    \draw[ultra thick,fill=#4] (\dx,#6,\dz) -- (\dx,#6,#7) -- (\dx,\dy,#7) -- (\dx,\dy,\dz) -- cycle;

%another command to draw a solved Rubik's cube more easily. The arguments used are:
%1 - number of cubes along each side (e.g. 3 x 3 x 3 cube)
%2-4 - colors of the visible faces
    \pgfmathparse{#1-1}\let\ncubes\pgfmathresult%the value 1 has to be subtracted from the given number of cubes/side to avoid the origin of the initial cube to be displaced
    \foreach \x in {0,...,\ncubes}{%
        \foreach \y in {0,...,\ncubes}{%
            \foreach \z in {0,...,\ncubes}{%


\title{Rubik's Cube}

\abstract%The part of text I wrote and would like you to read. :)
Rubik's cube is a famous puzzle, known worldwide. Lots of enthusiastic fan communities exist around the world. It is amazing, how a simple mechanism like this can catch on and enjoy the attention of people for such long time.

%a hyperlink has been included to the site that inspired me
I found a \href{http://www.rubiks.com}{site} where solutions to Rubik's cube are given and I thought it could be fun to produce the solutions in \LaTeX. Unfortunately (or fortunately? \Smiley) I found no package on CTAN to draw it. So here is an attempt to do it, making use of TikZ' rather paltry 3D support and with possible reuse for other purposes, e.g. draw hypermatrices. I would like to further develop it into a package and upload it to CTAN.

One feature I really want to implement is 3D rotation to show how you actually have to rotate the cube itself.

If you like it, please vote for it! This is for me an opportunity to test the waters, and, independently of whether I win something or not \Smiley, if there are enough interested people, I will finalize the package. It's all up to you! Happy voting! \Smiley

(Below in an excerpt from the solution manual found on \href{http://www.rubiks.com}{Rubik's Official Site}.)

\section{Solution to Obtain the ``White Cross''}

Holding your cube with the white center piece on the top face, you must create a white cross as shown:

\begin{figure}[!htb]%placement of the figure preferably right here, on top of the page or on the bottom of the page, but not on a separate floats page
    \centering%this way the figure will be centered across the page
    \begin{tikzpicture}[line join=round,line cap=round,scale=0.75]%The lines do not join nicely if the end of the lines and the line caps are not rounded (first two options). The last option scales the whole picture created with TikZ.
%I renamed some colors to save time typing and to make the code less cluttered.
        \colorlet{X}{black!50}%grey is used if the color of the face does not matter

%drawing the cube
%top face


%%right face



%front face


    \caption{Your goal}

Now I'll just insert a bit of \emph{Lorem ipsum}... (I am too lazy to type the content and I cannot copy-paste... Apparently the source has been scanned without OCR.) So, here we go.

\lipsum[1]%first paragraph from the lipsum random text

\section{Get the ``White Corners''}


    \begin{tikzpicture}[line join=round,line cap=round,scale=0.75]

%top face


%%right face



%front face


    \caption{Your new goal}


\section{Cube Solved}

Here I used loops to speed up the creation of the box, since all faces are the same color:

    \begin{tikzpicture}[line join=round,line cap=round,scale=0.75]

    \begin{tikzpicture}[line join=round,line cap=round,scale=0.75]

    \caption{The solution}


And another one with cubes with another number of sides:

    \begin{tikzpicture}[line join=round,line cap=round,scale=0.75,rotate=-10]%the last option rotates the picture - unfortunately no 3D-rotation, only in the plane of the sheet

    \begin{tikzpicture}[line join=round,line cap=round,scale=0.75]

    \caption{The solution}


And the output:

enter image description here enter image description here enter image description here

  • Nice.. How come the \colorlet were not defined in the preamble. I thought perhaps you were changing them for each figure, but that does not seem to be the case. Also minor suggestion: instead of \pgfmathparse{#1+#5}\let\dx\pgfmathresult you could just use \pgfmathsetmacro{\dx}{#1+#5}. Commented Nov 18, 2011 at 17:06
  • @PeterGrill: I was copy-pasting code snippets and was oblivious to this detail in the heat of the action... :)
    – Count Zero
    Commented Nov 18, 2011 at 17:12
  • Is this a submission for academic or other? I'd say other?
    – doncherry
    Commented Nov 25, 2011 at 14:33
  • That's right: I forgot to mention: it's OTHER.
    – Count Zero
    Commented Nov 25, 2011 at 15:36

My entry (which I suppose falls into the other category) is just to show off a little snippet of code that I developed when typesetting a programme for a play. A slightly fancier list style was needed for people's names than anything built in, and I got one by abusing TeX's hyphenation mechanism to insert pretty bullet points rather than hyphens. You can just type in a list of names (or whatever) and not worry about how many fit onto a line, but you can also use \\ to force a line break if necessary, or adjust the margins for better flow.

\usepackage{fourier-orns} % for some nice ornaments
\usepackage{baskervald} % and nice fonts
\usepackage{graphicx} % to scale the ornaments if desired


% Commands for changing the spacer and left and right ornaments

% Initially, have a simple centred dot spacer and no left or right ornament

% This is where the magic happens: the \discretionary hyphenation
% command is abused to provide a \@spacer only if the line is not
% breaking at this point, and a \@leftorn or \@rightorn if
% necessary. The @prevarg flag is to determine whether or not we are
% at the beginning of a list or after a line break (in which case we
% need a left ornament rather than a spacer).

% The "new line break" command puts in a right ornament, executes the
% usual line break code, and then sets @prevarg to false.

% This is the command used for each item in the list. We wrap it in a
% mbox to ensure that we don't get any genuine hyphenation (or
% breaking at spaces, which is not desirable in this case).

% And this is the environment that will surround the list. We abuse
% the list environment to provide wider margins if desired (specified
% by the optional argument), then define the @prevarg flag and add the
% hooks to the linebreaking code as redefined above. To finish the
% environment we add a final right ornament before closing the centre
% and list environments.


% A simple shopping list (?) with indented margins.
  \ci{banana bread}
  \ci{french fries}

% Fancier, and demonstrating the line breaking feature: the family of
% James I of England.

  \ci{James I of England}
  \ci{Anne of Denmark}\\
  \ci{Henry, Prince of Wales}
  \ci{Elizabeth of Bohemia}
  \ci{Margaret Stuart}
  \ci{Charles I of England}
  \ci{Robert Stuart, Duke of Kintyre}
  \ci{Mary Stuart}
  \ci{Sophia Stuart}

% Another fancier demonstration, this time with Christian III of Denmark.

  \ci{Christian III of Denmark}
  \ci{Dorothea of Saxe-Lauenburg}\\
  \ci{Anna of Denmark}
  \ci{Frederick II of Denmark}
  \ci{Magnus, King of Livonia}
  \ci{Johann II, Duke of Schleswig-Holstein-Sonderburg-Plon}
  \ci{Dorothea of Denmark}



Sample output from the center list code

Not something most of us would use in day-to-day typesetting, but perhaps someone may find it useful for the occasional special effect. Enjoy!

(All royal family details straight from Wikipedia, with no expert knowledge - or indeed knowledge of any other sort - about these implied!)

  • 1
    I really like this, have you considered turning it into a CTAN package?
    – doncherry
    Commented Nov 25, 2011 at 13:52
  • 1
    @doncherry: thank you! I had briefly considered this, but wondered whether it was too much of a one-off special effect to be really appropriate as a package. But I'll think again...
    – Ant
    Commented Nov 25, 2011 at 14:57
  • 3
    Well, it seems your concept is pretty flexible in terms of which symbols you use, whether there are symbols at the beginning and the end of a line etc., so there could be verious uses for it. I can even imagine it for a table of contents. You could include some different setups or "styles" to choose from plus the option to specify personalized symbols. But most of all, this could be a great learning opportunity for you; but that's of course assuming you have the time to spare and the intention of going into this direction.
    – doncherry
    Commented Nov 25, 2011 at 15:02

I'd like to add a humble contribution to the contest. But beware, don't expect too much. After all, it's me. :)

Before the code is properly unveiled, I'd like to provide some background, so everybody will understand why I came up with it. There we go.


I'm the coordinator of a small choir in a parish. I decided to come up with a personal songbook to help me on keeping track of songs we use during masses or processions. But it is not an easy task.

First of all, I decided to use the songs package. IMHO it's a nice package for handling songbooks and it really suits my purposes. As a bonus, it can handle chords beautifully. But unfortunately, the whole process of cataloging songs required much more than a good layout.

Catholic liturgy teaches us that music is an important part of the mass. So I had to have every rite or gesture mapped to the correct song, e.g, entrance song, Kyrie, Gloria, Alleluia, Presentation of the Gifts, and so forth.

So I wrote down how many categories I had to map to my songs. I came up with 22 categories. So far so good.

But it was not that simple. I had to map songs according to their categories and also taking the time of the liturgical year into consideration, e.g, Advent, Christmas, Ordinary Time, Lent and Easter. So I had to cross map all categories along the year. Besides, I also had to take into consideration the calendar of saints, feasts and the sacraments. Oh my!

How should I do such project using LaTeX? We will see how I did it.


First of all, the songs package is a prerequisite. I decided to use it and I'm quite satisfied with the result. I must warn you that the CTAN version is very outdated, so please download the updated one from here.

I had 22 categories, so I decided to convert them to 22 indices. I usually search songs by their category, so it was a natural choice. imakeidx is the way to go, very easy to use and powerful. Ah, I decide to use another one for a thematic index, so saints, feasts and sacraments were correctly mapped.

I won't write my real code, as it is more a monstruous example than a minimal one. :) But you will probably get the idea. Lets check it:

% the document class, no big deal

% the usual packages

% index features

No secret here. Now let's then create, say, four categories:

% four indices will be created, each
% one representing a category
\makeindex[name=foo,title=Index of Foo]
\makeindex[name=bar,title=Index of Bar]
\makeindex[name=foobar,title=Index of Foobar]
\makeindex[name=qux,title=Index of Qux]

Please, don't expect the 23 categories I have! :) Ah, in my real document, I use the splitindex option for imakeidx, otherwise we will run out of registers. Let's move on:

% my favorite layout lifesaver

% drawing stuff

% swiss army knife

% for string comparison

In every song, I want to display the categories, so I wrote the following code to display an acronym to represent every category:

% this command will draw a circle
% with #1 text inside it
    \node[draw,circle,inner sep=1pt, minimum height=0.5cm, minimum width=0.5cm] {\scriptsize #1};

The songs package, of course:

% songs

Remember the divisions of the liturgical year? I decided to use the following plan: Imagine five bullets in front of a song name. The order for the times of the liturgical year is well-defined, so each bullet represents one time. If, say, the first bullet is filled (\bullet), the song might be used in this time, otherwise an empty bullet (\circ) will be used. Let's say we have four times, A, B, C and D:

% print the bullets according to the
% #1 input

And I want to have the liturgical time being displayed in the song, so I wrote another code for it:

% draw a little square with #1 text
% inside it
    \node[draw,inner sep=1pt, minimum height=0.3cm, minimum width=0.3cm] {\tt\raisebox{0pt}[\height][0pt]{#1}};

% print a timebox and add a space

I love this part. Thanks to the etoolbox package, I can iterate through elements of a list, so I add a new list parser:

% declare a new list parser

Now I create a command to iterate through a list of times:

% create a command that will print a
% timebox for every letter found

This part is the heart of my implementation. I read the category of the current song and index it accordingly:

% index song according to the
% category
    \index[foo]{\songtitle@\songliturgy \songtitle}
      \index[bar]{\songtitle@\songliturgy \songtitle}
        \index[foobar]{\songtitle@\songliturgy \songtitle}
          \index[qux]{\songtitle@\songliturgy \songtitle}

Again, for every category of every song, let's index it:

% create a command to index the current song
% according to the list of categories

Now, I need to add support to these entries in my song environment:

% create a new song key to print the categories
{\def\songclassify{ #1 \par}}

% create a new song key to print the time

% Renew the song prelude to print
% the categories

Now I create both author and song indices required by the songs package and set the chorus font to be bold:

% create both song and author indices

% bold chorus font

Thanks to egreg, the following code will add the song number instead of the page number to my indices entries:

% add the song number instead of
% page number

Now it's simple enough. The document begins and the songs are added:


\showindex{My songs}{reltitleidx}


\beginsong{My cool song}[by={Some guy},sr={},cla={\classify{F,B}},cr={\settime{A,C}},tin={\drawbullets{A,C}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Another cool song}[by={Some guy},sr={},cla={\classify{B}},cr={\settime{A}},tin={\drawbullets{A}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Cool cool cool}[by={Some guy},sr={},cla={\classify{FB}},cr={\settime{D}},tin={\drawbullets{D}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Cooler song}[by={Some guy},sr={},cla={\classify{Q}},cr={\settime{A,D}},tin={\drawbullets{A,D}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Cool yeah}[by={Some guy},sr={},cla={\classify{F,FB}},cr={\settime{B,C}},tin={\drawbullets{B,C}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Coolness}[by={Some guy},sr={},cla={\classify{B,Q}},cr={\settime{C}},tin={\drawbullets{C}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Hallelujah cool!}[by={Some guy},sr={},cla={\classify{F,Q}},cr={\settime{B}},tin={\drawbullets{B}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!


\beginsong{Coolest song!}[by={Some guy},sr={},cla={\classify{F}},cr={\settime{A,B}},tin={\drawbullets{A,B}}]

This is a cool song, I wrote it by myself! \rep{2}

Meow, said the cat! Of course you will love this song!





The output is as we expect:

My songs

And the indices are correct:

My indices

I can now easily find the songs I want! By the way, my original songbook has now 2000+ songs, powered by LaTeX. :)

That's it, hope you guys like it! Happy birthday, TeX.sx! :)


I have a suspicion that I'm breaking too many rules with this submission. In particular:

  1. Include things that a more-or-less everyday document can benefit from.

    The purpose of this document is to provide a benefit for those times when you can't use TeX.

  2. Limit your document to a few pages, maximally three or four.

    I get kinda verbose when I get started. Oops.

  3. Annotate your source extensively, so that non-expert users can understand which package and which hack does what.

    I didn't do anything particularly amazing, so haven't annotated anything.

  4. Your document should mainly be text, but content doesn't matter

    Mine is all about the content.

As it's a bit long, the full source and resulting PDF can be found on my webpage. I'll confine myself to the highlights here.

The opening and closing pages:

first page

last page

The crucial part of the source:

  heavy line width=8pt,
  light line width=4pt,
  annotation style={thick,red,->,shorten >=1ex,shorten <=1ex},
  annotation shift={(1em,1em)},
  annotation node style={1}{fill=white,fill opacity=.5,circle,text     opacity=1,anchor=south west},
  annotation node style={2}{fill=white,fill opacity=.5,circle,text     opacity=1,anchor=south west},
  annotation node style={3}{fill=white,fill opacity=.5,circle,text     opacity=1,anchor=south},
   (-.5,1.2) -- (-.5,-.3) .. controls +(60:.4) and +(120:.4) .. (.7,-.3)
   (-.5,1.2) .. controls +(-60:.4) and +(-120:.4) .. (.7,1.2) -- (.7,-1.35) +(0,0) .. controls +(120:1) and +(140:1.5) .. (-.9,-1.7)
  • Is this a submission for academic or other? I'd say other since the "crucial part" is about calligraphy?
    – doncherry
    Commented Nov 25, 2011 at 14:34
  • 1
    Sounds fine to me. I should have specified, sorry. Commented Nov 25, 2011 at 14:46

Here's my contribution:

Like a lot of developers, I'm also a roleplayer who also happens to love DTP. In past years, I translated and/or laid out some free RPGs. One of these is The Shadow Of Yesterday, whose core rules are published under a CC license.

Using a converter written in python, I converted HTML in ConTeXt, added some flair and made available the whole package.

The Source, including fonts (free ones) and a resulting PDF, can be downloaded from here:.

So, here's my entry:

  • Name: The Shadow Of Yesterday
  • Category: Other
  • I agree that all code of mine can be reused; TSOY core rules are under CC, and AFAIK they pose no copyright problems. Same can be said for fonts.
  • The style and the font setup looks nice. I am also curious why you converted the HTML markup to ConTeXt markup. Usually, ConTeXt can handle HTML input fairly well.
    – Aditya
    Commented Nov 19, 2011 at 4:19
  • I tried following these instructions: wiki.contextgarden.net/HTML_and_ConTeXt , but I somehow got stuck. So, since I know some other languages, I set off and built a converter in python (which is by no means complete, but it can and it has dealt with some 300kb sized xhtml files). Commented Nov 19, 2011 at 6:28
  • No, I did not mean the method that you linked to. That method is using ruby to convert wiki markup to ConTeXt, so it is essentially same as what you did with python. What I meant was handling HTML as XML and processing it directly. For an example, see Thomas Schmitz's My way
    – Aditya
    Commented Nov 19, 2011 at 6:42
  • Ah, yes: I read this doc, too but I chose to write a converter and work on generated ConTeXt file because: 1) it would help me learn ConTeXt better; 2) it would help me tweak more the generated code; 3) as a coder, it's more fun for me writing some code for conversion; Commented Nov 21, 2011 at 8:45

Roll-call. Category: academic.

At the beginning of the semester, instead of a roll-call (which is impossible, since at my faculty the students are allowed to change groups during the first two weeks and thus there are no "official" lists of people enrolled to different courses) I ask all students to sign themselves on a sheet of paper. But then, it is quite time-consuming to convert this list (usually ordered by the place they are seated) into a nice, alphabetically ordered one. So I decided to prepare this sheet in ConTeXt, which essentially allows me to save work by doing the first step of a merge sort;). (The number of slots for different ranges of letters are chosen to be most pleasing visually for me and reasonable for Polish names; I've never run into "overfull" problems, my groups are usually less than 30 people.) roll-call ConTeXt sheet

\setupbodyfont[sans] % I prefer sans-serif font for this kind of stuff

\setuppagenumbering[state=stop]   % I don't want a page number
\setuppapersize[A4]               % I'm European
\setuplayout[                     % Small margins are fine
\setupheader[state=none]          % No headers...
\setupfooter[state=none]          % and footers
\setupinterlinespace[line=6.5mm]  % height is now divisible by baselineskip
\setupbodyfont[4mm]               % This is about 11pt

\startMPinclusions                % Right hook definition
  vardef rhook = 
    numeric r ; r := max(0.25 * OverlayHeight, 4pt);
    (0,0) -- ((OverlayWidth,0) xshifted -r){right} .. {up}(OverlayWidth,r)

\startuniqueMPgraphic{rhook}      % Gray right hook
  draw rhook withpen pencircle scaled 3pt withcolor 0.4white;
  setbounds currentpicture to OverlayBox;

\startuniqueMPgraphic{lhook}      % Right hook mirrored = left hook
  draw rhook reflectedabout((0.5*OverlayWidth,0),(0.5*OverlayWidth,1))
    withpen pencircle scaled 3pt withcolor 0.4white;
  setbounds currentpicture to OverlayBox;

\defineoverlay[rhook][\uniqueMPgraphic{rhook}] % Overlay definitions

\defineframed[lhookframed][       % New framed-like command
  location=low,     % this is equivalent to \inframed
  background=lhook, % background picture
  frame=off,        % no frame
  boffset=0.5ex,    % this is manual tuning
\defineframed[rhookframed][       % Analogous to the previous one


\startalignment[middle]           % Title
  \lhookframed[width=100mm,align=normal]{Class name}
  \startlinecorrection           % Seemingly, this is needed because
  \blank[3*small]                % of grid typesetting
  \rhookframed[width=30mm]{Date} % Happily, neither of "Date", "Hour"
  \hfill                         % etc. does not have descenders; if
  \rhookframed[width=30mm]{Hour} % they were present, I'd use \smash
  \rhookframed[width=30mm]{Class no}

\startcolumns[n=2] % two columns
\dorecurse{11}{\rhookframed{}} % numbers are based on my guts and
\lhookframed{E--H}             % aesthetics of this document, but
\dorecurse{11}{\rhookframed{}} % they worked so far
\lhookframed{\hfill\em Marcin Borkowski} % in case the list gets lost
                                % at my university (this happened to
                                % me once!), they'll know who's the owner

  • 1
    It may be worthwhile to create a ConTeXt (MkIV) module that allows one to use \framed[frame=off, bottomrule=lefthook]{...} to get similar results. See this gist for a proof of concept. This can be used using \useMPlibrary[hooks].
    – Aditya
    Commented Nov 19, 2011 at 20:21
  • Thanks for your comment. I read your file, and I have two questions: (1) what is the difference between \startMPinclusions and \startMPextensions? (2) What exactly is \installbottomframerenderer - I couldn't find it in the source browser?
    – mbork
    Commented Nov 19, 2011 at 21:10
  • 1
    \startMPinclusions is a user level environment. The contents of \startMPinclusions are overwritten by the next call to \startMPinclusions, unless you add [+]. In contrast, \startMPextensions always appends its contents to the existing extensions. So, the latter is safer when writing a module. (2) \install...framerenderer are defined in pack-fen.mkiv. See meta-imp-fen.mkiv for an example (I followed the same structure for the above module).
    – Aditya
    Commented Nov 19, 2011 at 21:19

You must log in to answer this question.

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