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

Results

Academic

Other

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 sourcemust 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.

Prizes?

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.

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.

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.

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.

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:

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

\mypics@img1@caption
\mypics@img1@longdescription
\mypics@img1@date

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

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.

Captions

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).

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.

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.

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

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.
–
Peter GrillNov 18 '11 at 17:09

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 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 ;-)).

A brief description of the package:

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

\usepackage[<options>]{grid}
\usepackage{gridleno}

Some of the features implemented by the package

Theorem-like structures:

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

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.

@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.
–
Ali MehriziNov 29 '11 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}.
–
Gonzalo MedinaNov 29 '11 at 22:28

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.

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.

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

\define[1]\hide{\removeunwantedspace}

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).

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:

\enablecomments[<identifier>]

To deactivate comments use:

\disablecomments[<identifier>]

Thus, this module can be used as follows:

\usemodule[comments]
\installcomments[C] [start=/*,stop=*/]
\starttext
Comments are /*disabled*/ right now.
\enablecomments[C]
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
\stoptext

which gives

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

%
%
AB

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

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

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

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.
–
SonyDec 21 '11 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.
–
cmhughesDec 21 '11 at 17:13

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.

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{fourier-orns} % for some nice ornaments
\usepackage{baskervald} % and nice fonts
\usepackage[scaled=0.92]{helvet}
\usepackage{graphicx} % to scale the ornaments if desired
\pagestyle{empty}
\makeatletter
% Commands for changing the spacer and left and right ornaments
\newcommand{\cspacer}[1]{%
\renewcommand{\@spacer}{\mbox{#1}}}
\newcommand{\cleft}[1]{%
\renewcommand{\@leftorn}{\mbox{#1}}}
\newcommand{\cright}[1]{%
\renewcommand{\@rightorn}{\mbox{#1}}}
% Initially, have a simple centred dot spacer and no left or right ornament
\newcommand{\@spacer}{\mbox{%
\hspace{0.3em}$\cdot$\hspace{0.3em}}}
\newcommand{\@leftorn}{}
\newcommand{\@rightorn}{}
% 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).
\newcommand{\@spacerifneeded}{\if@prevarg%
\discretionary{\@rightorn}{\@leftorn}{\@spacer}\else\@leftorn\fi}
% The "new line break" command puts in a right ornament, executes the
% usual line break code, and then sets @prevarg to false.
\newcommand{\@newlb}{\@rightorn\@oldlb\@prevargfalse}
% 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).
\newcommand{\ci}[1]{%
\@spacerifneeded\@prevargtrue%
\mbox{#1}\ignorespaces}
% 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.
\newenvironment{centrelist}[1][0em]{%
\begin{list}{}{\leftmargin=#1\rightmargin=#1}\item%
\begin{center}\newif\if@prevarg%
\let\@oldlb=\\\let\\=\@newlb%
}
{\@rightorn\end{center}\end{list}}
\makeatother
\begin{document}
% A simple shopping list (?) with indented margins.
\sffamily
\begin{centrelist}[10em]
\ci{apples}
\ci{banana bread}
\ci{celery}
\ci{doughnuts}
\ci{eggplant}
\ci{french fries}
\ci{garlic}
\ci{hummous}
\ci{ice}
\ci{jellybeans}
\end{centrelist}
% Fancier, and demonstrating the line breaking feature: the family of
% James I of England.
\vspace{24pt}
\cspacer{\hspace{0.5em}\scalebox{0.85}{\decoone}\hspace{0.5em}}
\cleft{\leafright\hspace{0.3em}}
\cright{\hspace{0.3em}\leafleft}
\renewcommand{\baselinestretch}{1.5}\rmfamily
\begin{centrelist}
\Large\itshape
\ci{James I of England}
\ci{Anne of Denmark}\\
\normalsize\upshape
\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}
\end{centrelist}
% Another fancier demonstration, this time with Christian III of Denmark.
\vspace{24pt}
\cspacer{\hspace{0.3em}\starredbullet\hspace{0.3em}}
\cleft{\decofourleft\hspace{0.6em}}
\cright{\hspace{0.6em}\decofourright}
\begin{centrelist}
\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}
\end{centrelist}
\end{document}

gives

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!)

I really like this, have you considered turning it into a CTAN package?
–
doncherryNov 25 '11 at 13:52

@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...
–
AntNov 25 '11 at 14:57

2

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.
–
doncherryNov 25 '11 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.

Background

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.

Implementation

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:

% 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:

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:

% create a command to index the current song
% according to the list of categories
\newcommand*\classify[1]{%
\myforeach{\indexsong}{#1}%
}

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

% create a new song key to print the categories
\newsongkey{cla}{\def\songclassify{}}
{\def\songclassify{ #1 \par}}
% create a new song key to print the time
\newsongkey{tin}{\def\songliturgy{}}
{\def\songliturgy{#1}}
% Renew the song prelude to print
% the categories
\renewcommand{\extendprelude}{%
\showrefs{\footnotesize\showauthors}%
{\ttfamily\songclassify}%
}

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

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
\makeatletter
\patchcmd{\@wrindex}{\thepage}{\thesongnum}{}{}%
\makeatother

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

\begin{document}
\showindex{My songs}{reltitleidx}
\begin{songs}{reltitleidx,relauthidx}
\beginsong{My cool song}[by={Some guy},sr={},cla={\classify{F,B}},cr={\settime{A,C}},tin={\drawbullets{A,C}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Another cool song}[by={Some guy},sr={},cla={\classify{B}},cr={\settime{A}},tin={\drawbullets{A}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Cool cool cool}[by={Some guy},sr={},cla={\classify{FB}},cr={\settime{D}},tin={\drawbullets{D}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Cooler song}[by={Some guy},sr={},cla={\classify{Q}},cr={\settime{A,D}},tin={\drawbullets{A,D}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Cool yeah}[by={Some guy},sr={},cla={\classify{F,FB}},cr={\settime{B,C}},tin={\drawbullets{B,C}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Coolness}[by={Some guy},sr={},cla={\classify{B,Q}},cr={\settime{C}},tin={\drawbullets{C}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Hallelujah cool!}[by={Some guy},sr={},cla={\classify{F,Q}},cr={\settime{B}},tin={\drawbullets{B}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\beginsong{Coolest song!}[by={Some guy},sr={},cla={\classify{F}},cr={\settime{A,B}},tin={\drawbullets{A,B}}]
\beginchorus
This is a cool song, I wrote it by myself! \rep{2}
\endchorus
\beginverse
Meow, said the cat! Of course you will love this song!
\endverse
\endsong
\end{songs}
\printindex[foo]
\printindex[bar]
\printindex[foobar]
\printindex[qux]
\end{document}

The output is as we expect:

And the indices are correct:

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

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 integrally by anyone*
\documentclass{article}
\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 - x-position in space
%7 - x-position in space
\newcommand{\cubedxdydz}[7]{
\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
\newcommand{\rubikcube}[4]{
\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}{%
\cubedxdydz{1}{#2}{#3}{#4}{\x}{\y}{\z}
}
}
}
}
\begin{document}
\title{Rubik's Cube}
\author{Me}
\maketitle
\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{R}{red}
\colorlet{G}{green}
\colorlet{B}{blue}
\colorlet{Y}{yellow}
\colorlet{O}{orange}
\colorlet{W}{white}
\colorlet{X}{black!50}%grey is used if the color of the face does not matter
%drawing the cube
%top face
\cubedxdydz{1}{X}{X}{X}{0}{2}{0}
\cubedxdydz{1}{X}{W}{X}{1}{2}{0}
\cubedxdydz{1}{X}{W}{X}{0}{2}{1}
\cubedxdydz{1}{X}{W}{X}{1}{2}{1}
%%right face
\cubedxdydz{1}{X}{X}{X}{2}{0}{0}
\cubedxdydz{1}{X}{X}{X}{2}{0}{1}
\cubedxdydz{1}{X}{X}{X}{2}{1}{0}
\cubedxdydz{1}{X}{X}{B}{2}{1}{1}
\cubedxdydz{1}{X}{X}{X}{2}{2}{0}
\cubedxdydz{1}{X}{W}{B}{2}{2}{1}
%front face
\cubedxdydz{1}{X}{X}{X}{0}{0}{2}
\cubedxdydz{1}{X}{X}{X}{1}{0}{2}
\cubedxdydz{1}{X}{X}{X}{2}{0}{2}
\cubedxdydz{1}{X}{X}{X}{0}{1}{2}
\cubedxdydz{1}{R}{X}{X}{1}{1}{2}
\cubedxdydz{1}{X}{X}{X}{2}{1}{2}
\cubedxdydz{1}{X}{X}{X}{0}{2}{2}
\cubedxdydz{1}{R}{W}{X}{1}{2}{2}
\cubedxdydz{1}{X}{X}{X}{2}{2}{2}
\end{tikzpicture}
\label{fig:one}
\caption{Your goal}
\end{figure}
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''}
\lipsum[2]
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[line join=round,line cap=round,scale=0.75]
\colorlet{R}{red}
\colorlet{G}{green}
\colorlet{B}{blue}
\colorlet{Y}{yellow}
\colorlet{O}{orange}
\colorlet{W}{white}
\colorlet{X}{black!50}
%top face
\cubedxdydz{1}{X}{W}{X}{0}{2}{0}
\cubedxdydz{1}{X}{W}{X}{1}{2}{0}
\cubedxdydz{1}{X}{W}{X}{0}{2}{1}
\cubedxdydz{1}{X}{W}{X}{1}{2}{1}
%%right face
\cubedxdydz{1}{X}{X}{X}{2}{0}{0}
\cubedxdydz{1}{X}{X}{X}{2}{0}{1}
\cubedxdydz{1}{X}{X}{X}{2}{1}{0}
\cubedxdydz{1}{X}{X}{B}{2}{1}{1}
\cubedxdydz{1}{X}{W}{B}{2}{2}{0}
\cubedxdydz{1}{X}{W}{B}{2}{2}{1}
%front face
\cubedxdydz{1}{X}{X}{X}{0}{0}{2}
\cubedxdydz{1}{X}{X}{X}{1}{0}{2}
\cubedxdydz{1}{X}{X}{X}{2}{0}{2}
\cubedxdydz{1}{X}{X}{X}{0}{1}{2}
\cubedxdydz{1}{R}{X}{X}{1}{1}{2}
\cubedxdydz{1}{X}{X}{X}{2}{1}{2}
\cubedxdydz{1}{R}{W}{X}{0}{2}{2}
\cubedxdydz{1}{R}{W}{X}{1}{2}{2}
\cubedxdydz{1}{R}{W}{B}{2}{2}{2}
\end{tikzpicture}
\label{fig:two}
\caption{Your new goal}
\end{figure}
\lipsum[3]
\section{Cube Solved}
Here I used loops to speed up the creation of the box, since all faces are the same color:
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[line join=round,line cap=round,scale=0.75]
\colorlet{R}{red}
\colorlet{G}{green}
\colorlet{B}{blue}
\colorlet{Y}{yellow}
\colorlet{O}{orange}
\colorlet{W}{white}
\colorlet{X}{black!50}
\rubikcube{3}{R}{G}{B}
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}[line join=round,line cap=round,scale=0.75]
\colorlet{R}{red}
\colorlet{G}{green}
\colorlet{B}{blue}
\colorlet{Y}{yellow}
\colorlet{O}{orange}
\colorlet{W}{white}
\colorlet{X}{black!50}
\rubikcube{3}{O}{W}{Y}
\end{tikzpicture}
\label{fig:three}
\caption{The solution}
\end{figure}
\lipsum[4]
And another one with cubes with another number of sides:
\begin{figure}[!htb]
\centering
\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
\colorlet{R}{red}
\colorlet{G}{green}
\colorlet{B}{blue}
\colorlet{Y}{yellow}
\colorlet{O}{orange}
\colorlet{W}{white}
\colorlet{X}{black!50}
\rubikcube{4}{R}{W}{G}
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}[line join=round,line cap=round,scale=0.75]
\colorlet{R}{red}
\colorlet{G}{green}
\colorlet{B}{blue}
\colorlet{Y}{yellow}
\colorlet{O}{orange}
\colorlet{W}{white}
\colorlet{X}{black!50}
\rubikcube{2}{B}{Y}{R}
\end{tikzpicture}
\label{fig:four}
\caption{The solution}
\end{figure}
\end{document}

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}.
–
Peter GrillNov 18 '11 at 17:06

@PeterGrill: I was copy-pasting code snippets and was oblivious to this detail in the heat of the action... :)
–
Count ZeroNov 18 '11 at 17:12

Is this a submission for academic or other? I'd say other?
–
doncherryNov 25 '11 at 14:33

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.

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).
–
Max LambertiniNov 19 '11 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
–
AdityaNov 19 '11 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;
–
Max LambertiniNov 21 '11 at 8:45

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.)

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].
–
AdityaNov 19 '11 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?
–
mborkNov 19 '11 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).
–
AdityaNov 19 '11 at 21:19