Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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


Results

Academic

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

Other

  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.

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.

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

share|improve this question
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 Nov 11 '11 at 14:13
4  
Shouldn't it be "TeX" skills without the "La" part? –  Khaled Hosny Nov 11 '11 at 16:56
    
@KhaledHosny: Have a look at the discussion page I linked to in the comment above yours. –  doncherry Nov 11 '11 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.

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

\mypictures{img1,img2,img3,img4}

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.

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

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.

share|improve this answer
3  
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 Grill Nov 18 '11 at 17:09
    
@PeterGrill Thanks for your kind words. –  Yiannis Lazarides Nov 18 '11 at 18:01
2  
Fantastic, Yiannis! :) –  Paulo Cereda Nov 19 '11 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 Nov 19 '11 at 18:22
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 Dec 7 '11 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 :

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

    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.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{gridleno}

\@ifpackageloaded{background}{}{\RequirePackage{background}}
\@ifpackageloaded{amsthm}{}{\RequirePackage{amsthm}}
\@ifpackageloaded{thmtools}{}{\RequirePackage{thmtools}}
\@ifpackageloaded{caption}{}{\RequirePackage{caption}}
\@ifpackageloaded{environ}{}{\RequirePackage{environ}}
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}

% 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
\colorlet{summarybg}{grlngreen!60}
\colorlet{qedsym}{headtitle}
\colorlet{sechead}{headtitle}
\colorlet{subsechead}{headtitle}
\colorlet{subsubsechead}{headtitle}
\colorlet{proofhead}{headtitle}
\colorlet{thmhead}{headtitle}
\colorlet{defhead}{headtitle}
\colorlet{remhead}{headtitle}
\colorlet{captionhead}{headtitle}
\colorlet{summaryhead}{headtitle}
\colorlet{biblabel}{headtitle}

% 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.
\def\course#1{\gdef\@course{#1}}
\def\@course{}
\def\professor#1{\gdef\@professor{#1}}
\def\@professor{}
\def\courseid#1{\gdef\@courseid{#1}}
\def\@courseid{}
\def\topic#1{\gdef\@topic{#1}}
\def\@topic{}
\def\term#1{\gdef\@term{#1}}
\def\@term{}

% default values for the different names used
\newcommand\lecturenotename{Lecture Notes}
\newcommand\coursename{Course}
\newcommand\termname{Term}
\newcommand\Proofname{Proof}
\newcommand\theoremname{Theorem}
\newcommand\propositionname{Proposition}
\newcommand\corollaryname{Corollary}
\newcommand\lemmaname{Lemma}
\newcommand\definitionname{Definition}
\newcommand\examplename{Example}
\newcommand\remarkname{Remark}
\newcommand\exercisesname{Exercises}
\newcommand\summaryname{Summary}

% 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.
\SetBgContents{}
\newcommand\makeheader{
\pagestyle{plain}
\SetBgContents{%
  \vbox{%
    \setlength\hsize{\paperwidth}
    \setlength\parindent{0pt}%
    \fcolorbox{headtitle}{headbg}{%
      \parbox[t][1.5in][c]{\dimexpr\paperwidth-2\fboxsep-2\fboxrule\relax}{%
        \hspace*{15mm}%
        \parbox[c]{.35\paperwidth}{%
          \raggedright\normalfont\sffamily 
          \color{headtitle}\Huge\lecturenotename \\[6pt]
          \fontfamily{cmr}\fontsize{17pt}{20pt}\selectfont\scshape\@topic \\[6pt]
          {\normalsize\rmfamily\scshape\@professor}%
        }%
        \hfill
        \parbox[c][1.5in][c]{1mm}{%
          \color{headtitle}\rule{.1pt}{1.5in}%
        }%
        \hfill
        \parbox[c][1.5in][c]{.35\paperwidth}{
          \normalfont\sffamily\color{headtitle}%
          \vspace*{6pt}%
          \begin{tabular}{@{}l@{:\quad}p{.25\paperwidth}@{}}
            \coursename  & \@course\ \@courseid \\[1ex]
            \termname & \@term \\[1ex]
            \multicolumn{2}{@{}l@{}}{\@date}
          \end{tabular}%
         }\hspace*{15mm}%
      }%
    }%
  }%
}
\SetBgPosition{current page.north}
\SetBgAnchor{below}
\SetBgVshift{3.5pt}
\SetBgScale{1}
\SetBgColor{black}
\SetBgAngle{0}
\SetBgOpacity{1}
}

% definitions for \section, \subsection and \subsubsection
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-.999\baselineskip}%
                                   {0.001\baselineskip}%
                                   {\color{sechead}\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                   {\baselineskip}%
                                   {-.35\baselineskip}%
                                   {\color{subsechead}\bfseries\unskip}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                   {\baselineskip}%
                                   {-.35\baselineskip}%
                                   {\color{subsubsechead}\itshape\unskip}}

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

% \qedsymbol will be a colored solid square
\renewcommand\qedsymbol{$\color{qedsym}\blacksquare$}

% style for the proof environment
\declaretheoremstyle[
spaceabove=\baselineskip, spacebelow=\baselineskip,
headfont=\normalfont\itshape\color{proofhead},
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.5em,
numbered=no,
qed=\qedsymbol,
preheadhook={\topsep\z@\partopsep\z@\parskip\z@\itemsep\z@%
         \@outerparskip\z@\parsep\z@\@topsep\z@\@topsepadd\z@}
]{proofstyle}

% style for theorems, propositions, corollaries, lemmata
\declaretheoremstyle[
spaceabove=\baselineskip, spacebelow=\baselineskip,
headfont=\normalfont\bfseries\color{thmhead},
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont\itshape,
postheadspace=0.5em,
preheadhook={\topsep\z@\partopsep\z@\parskip\z@\itemsep\z@%
         \@outerparskip\z@\parsep\z@\@topsep\z@\@topsepadd\z@}
]{thmstyle}

% style for definitions and examples
\declaretheoremstyle[
spaceabove=\baselineskip, spacebelow=\baselineskip,
headfont=\normalfont\bfseries\color{defhead},
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.5em,
preheadhook={\topsep\z@\partopsep\z@\parskip\z@\itemsep\z@%
         \@outerparskip\z@\parsep\z@\@topsep\z@\@topsepadd\z@}
]{defistyle}

% style for remarks
\declaretheoremstyle[
spaceabove=\baselineskip, spacebelow=\baselineskip,
headfont=\normalfont\itshape\color{remtitle},
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.5em,
preheadhook={\topsep\z@\partopsep\z@\parskip\z@\itemsep\z@%
         \@outerparskip\z@\parsep\z@\@topsep\z@\@topsepadd\z@}
]{remastyle}

% predefined theorem-like structures
\declaretheorem[style=proofstyle,name=\Proofname]{Proof}

\declaretheorem[style=thmstyle,name=\theoremname]{theorem}
\declaretheorem[style=thmstyle,name=\corollaryname]{corollary}
\declaretheorem[style=thmstyle,name=\lemmaname]{lemma}
\declaretheorem[style=thmstyle,name=\propositionname]{proposition}

\declaretheorem[style=defistyle,name=\definitionname]{definition}
\declaretheorem[style=defistyle,name=\examplename]{example}

\declaretheorem[style=remastyle,name=Remark]{remark}

% enumerate-like environment designed for the exercises
% first level labels without indentation.
\def\exenumerate{%
  \ifnum \@enumdepth =\z@\addtolength\labelwidth{-5pt}\else
    \ifnum \@enumdepth =\@ne\addtolength\labelwidth{-1pt}\else
    \addtolength\labelwidth{-3pt}
  \fi\fi
  \setlength\leftmarginii{\dimexpr\labelwidth+\labelsep\relax}
  \setlength\leftmarginiii{\dimexpr\labelwidth+\labelsep\relax}
  \setlength\leftmargini{\dimexpr\labelwidth+\labelsep\relax}
  \ifnum \@enumdepth >\thr@@\@toodeep\else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\usecounter\@enumctr\def\makelabel##1{\makebox[0pt][l]{##1}}%
         \topsep\z@\partopsep\z@\parskip\z@\itemsep\z@%
         \@outerparskip\z@\parsep\z@\@topsep\z@\@topsepadd\z@}%
  \fi}
\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
\newenvironment{grmnpage}[1]
  {\noindent%
    \begin{minipage}[t]{#1}}
  {\par\xdef\tpd{\the\prevdepth}
    \end{minipage}}

% 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)  
\NewEnviron{grcmpage}[2]
  {\noindent\setlength\fboxsep{0pt}%
    \colorbox{#2}{%
    \begin{grmnpage}{#1}
      \BODY\par\xdef\tpd{\the\prevdepth}
    \end{grmnpage}%
  }%
}
\AtEndEnvironment{grcmpage}{\par\prevdepth\tpd}

% environment for a summary
\newenvironment{summary}
  {\grcmpage{\linewidth}{summarybg}
   \hfil{\color{summaryhead}\bfseries\summaryname}\hfil\par%
     \parshape 1 10pt \dimexpr\linewidth-20pt\relax\itshape}
  {\par\endgrcmpage\par\prevdepth\tpd}

% 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
\newenvironment{exercises}
  {\section*{\Hrulefill\quad%
    {\bfseries\exercisesname}\quad\Hrulefill}%
  \let\enumerate\exenumerate\let\endenumerate\endexenumerate}
  {}

% caption label will receive a color
\captionsetup{labelfont={color=captionhead}}

% \refname will produce "Suggested Reading" and \@biblabel will
% produce a bullet
\AtBeginDocument{\renewcommand\refname{Suggested Readings}}
\renewcommand\@biblabel[1]{{\color{biblabel}$\bullet$}}
\endinput
%%
%% End of file `gridleno.sty'.
share|improve this answer
1  
Awesome code, Gonzalo! Congrats! :) –  Paulo Cereda Nov 19 '11 at 9:04
    
@PauloCereda Thank you! –  Gonzalo Medina Nov 19 '11 at 22:16
    
@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 Mehrizi Nov 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 Medina Nov 29 '11 at 22:28
1  
That's a very good template! –  user10130 Dec 19 '11 at 22:16

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

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

\documentclass[10pt,a4paper]{article}

% Specifying input encoding
\usepackage[utf8]{inputenc}

% Using the TikZ library for drawing Tux, and clipping
\usepackage{tikz}

% Loaded for unnumbered captions
\usepackage{caption}

% For inserting lorem ipsum text
\usepackage{lipsum}

% Setting baselines smaller
\setlength{\baselineskip}{6pt}

\begin{document}

%\lipsum[1]

\begin{figure}[h!]
\centering
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt,scale=0.25]
    \begin{scope}[shift={(-249.6684,-294.38903)}]
    %\begin{scope}[cm={{0.55569,0.0,0.0,0.55569,(249.6684,292.4824)}}]
        \begin{scope}

            % 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]}};
        \end{scope}
    \end{scope}
\end{tikzpicture}

\caption*{TypoTux}
\end{figure}

%\lipsum[2]

\end{document}

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.

share|improve this answer

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

\documentclass{caesar_book}

% auto adjust the marginals
\usepackage{marginfix}
% -- provide more floats
\usepackage{morefloats}

% -- graphics --
\usepackage{graphicx}

% -- language: German --
\usepackage{csquotes}
\usepackage[ngerman]{babel}

% -- biblatex --
\usepackage[backend = biber, style = cleopatra,language=american]{biblatex}
\addbibresource{manuell.bib}
\AtEveryCitekey{\clearfield{url}}
\AtEveryCitekey{\clearlist{language}}
% fix export function of papers
\DeclareBibliographyAlias{letter}{article}

%%
%% -- start --
%%
\begin{document}
\chapter{Einführung}
\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.
%
\section{Meissner-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.
%
\section{Flussquantisierung}
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.
%
\end{document}

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

share|improve this answer
    
What are the reasons for using the microtype beta version? –  Federico Poloni Nov 19 '11 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 Nov 20 '11 at 14:11

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

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

%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)}

\startluacode
     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))
                    else
                        return empty_line
                    end
                elseif find(s,start) then
                    if find(s, stop) then
                        return currentfilter(strip_inline(s))
                    else
                        insideComment = true 
                        cleaned_line = strip_from_start(s)
                        return empty_line
                    end
                else
                    return s
                end
             end
             sequencers.appendaction(textlineactions,"after",format("thirddata.comments.filters.%s",name))
             comments.disable(name)
         end
     end

     function comments.enable(name)
        sequencers.enableaction(textlineactions,format("thirddata.comments.filters.%s",name))                                                                                       
     end
     function comments.disable(name)
        sequencers.disableaction(textlineactions,format("thirddata.comments.filters.%s",name))
     end

\stopluacode

\unprotect

\unexpanded\def\installcomments{\dodoubleargument\doinstallcomments}

% 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.
\def\doinstallcomments[#name][#settings]%
    {\ctxlua{thirddata.comments.install(\!!bs#name\!!es,\!!bs\detokenize{#settings}\!!es)}}

\unexpanded\def\enablecomments[#name]%
   {\ctxlua{thirddata.comments.enable (\!!bs#name\!!es)}}

\unexpanded\def\disablecomments[#name]%
   {\ctxlua{thirddata.comments.disable(\!!bs#name\!!es)}}

\protect

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

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

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

share|improve this answer
    
Fantastic code, Aditya! You've got a fan. :) –  Paulo Cereda Nov 22 '11 at 8:59
    
Thanks @PauloCereda. –  Aditya Nov 22 '11 at 18:40

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.

\documentclass[10pt,twoside]{report}
\usepackage{etex}
\reserveinserts{28}
\usepackage[left=6cm,right=1cm,showframe=false,                 % page settings (showframe is useful!)
    textheight=27cm,
    top=1.5cm,bottom=1.5cm,asymmetric=true,bindingoffset=1cm]{geometry}               
\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[nosolutionfiles]{answers}
\usepackage{framed}                             % needed for putting boxes round theorems, examples 
\usepackage[explicit]{titlesec}
\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
\usepackage[pdf]{pstricks}
\usepackage{pstricks-add}
% 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
\hypersetup{colorlinks=true,
linkcolor=blue%,breaklinks=true
}

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

% custom ps options
\newpsobject{pccpsplot}{psplot}{linecolor=blue,plotstyle=curve,%
                                linewidth=1pt,arrows=<->}
\newpsobject{pccgridline}{psline}{linecolor=black!20,linestyle=dashed}
\newpsobject{pccpsframe}{psframe}{linecolor=gray,linewidth=0pt}
\newpsobject{pccpsSolDot}{psdots}{linecolor=blue,dotsize=0.25}
\newpsobject{pccpsHolDot}{psdots}{linecolor=blue,dotsize=0.25,dotstyle=o}
\newpsobject{pccasymptote}{psline}{linestyle=dotted,linecolor=red}

% grid stuff
\newcommand{\drawXgrid}[3]{%
                       \multido{\nx=#1+#2}{#3}%
                       {%
                        \pccgridline(\nx,\ymin)(\nx,\ymax)
                       }%
}
\newcommand{\drawYgrid}[3]{%
                       \multido{\ny=#1+#2}{#3}%
                       {%
                        \pccgridline(\xmin,\ny)(\xmax,\ny)
                       }%
}


% set figure width

\newlength{\figurewidth}
% 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)
\makeatletter
\newcommand{\setwindow}[6][5]{\def\xmin{#2}%
                           \def\ymin{#3}%
                           \def\xmax{#4}%
                           \def\ymax{#5}%
                           % set up xunit
                           \pstFPsub\viewingwidth{#4}{#2}%
                           \pstFPdiv\result{\strip@pt#6}{\viewingwidth}%
                           \psset{xunit=\result pt}
                           % set up yunit
                           \pstFPsub\viewingheight{#5}{#3}%
                           \pstFPdiv\result{\strip@pt#6}{\viewingheight}%
                           % set up aspect ratio
                           \pstFPmul\result{\result}{#1}%
                           \psset{yunit=\result pt}%
                           }
\makeatother

% caption settings
\captionsetup[table]{skip=0pt}
\captionsetup[subfigure]{labelformat=parens,labelsep=colon,labelfont=normal}
\captionsetup[subtable]{labelformat=parens,labelsep=colon,labelfont=normal}

% enumerate settings
\setlist{itemsep=0.05em,topsep=0.01em}

% paragraph settings
\setlength{\parskip}{3.0mm}
\setlength{\parindent}{0.0mm}

% use left margin
\reversemarginpar
\setlength{\marginparwidth}{5cm}

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

%   BEGIN CLEVEREF

% standard environments
\crefname{table}{Table}{Tables}
\Crefname{table}{Table}{Tables}
\crefname{figure}{Figure}{Figures}
\Crefname{figure}{Figure}{Figures}
\crefname{section}{Section}{Sections}
\Crefname{section}{Section}{Sections}
\crefname{equation}{Equation}{Equations}
\Crefname{equation}{Equation}{Equations}
% custom environments
\crefname{problem}{Problem}{Problems}
\Crefname{problem}{Problem}{Problems}
\crefname{pccdefinition}{Definition}{Definitions}
\Crefname{pccdefinition}{Definition}{Definitions}
\crefname{pccexample}{Example}{Examples}
\Crefname{pccexample}{Example}{Examples}
\crefname{enumi}{Problem}{Problems}
\Crefname{enumi}{Problem}{Problems}
% conjunction between range; e.g Figures 1.2-1.3
\newcommand{\crefrangeconjunction}{|}

%   BEGIN MARGIN ENVIRONMENTS (shamelessly copied from tufte documentclass)
\makeatletter
% Margin float environment
\newsavebox{\@tufte@margin@floatbox}
\newenvironment{@tufte@margin@float}[2][-1.2ex]%
  {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
  \begin{lrbox}{\@tufte@margin@floatbox}%
  \begin{minipage}{\marginparwidth}%
    \def\@captype{#2}%
    \hbox{}\vspace*{#1}%
    \noindent%
  }
  {\end{minipage}%
  \end{lrbox}%
  \marginpar{\usebox{\@tufte@margin@floatbox}}%
  }

% Margin figure environment
\newenvironment{marginfigure}[1][-1.2ex]%
  {\begin{@tufte@margin@float}[#1]{figure}%
   \capstart\endgraf}% <-- Hyperlink jumps to start of 'marginfigure'
  {\end{@tufte@margin@float}}

% Margin table environment
\newenvironment{margintable}[1][-1.2ex]%
  {\begin{@tufte@margin@float}[#1]{table}%
   \capstart\endgraf}% <-- Hyperlink jumps to start of 'margintable'
  {\end{@tufte@margin@float}}

\makeatother
%   END MARGIN ENVIRONMENTS

%   BEGIN SOLUTIONS TO PROBLEMS
% open the answer files (short, long, and hints)
\Opensolutionfile{shortsolutions}
\Newassociation{shortsolution}{shortSoln}{shortsolutions}

% put titles in the solution files
\begin{Filesave}{shortsolutions}
% SHORT SOLUTIONS FILE
% 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}{}
\section*{Answers}
\setcounter{chapter}{0}

\end{Filesave}
%   END SOLUTIONS TO PROBLEMS

%   BEGIN CUSTOM THEOREMS (for problems, subproblems)
% set up showoddsolns and showEVEN
\newboolean{showoddsolns}
\setboolean{showoddsolns}{true}
\newboolean{showevensolns}
\setboolean{showevensolns}{true}

% this boolean is used in the problem and subproblem definition (don't change!)
\newboolean{showSolution}
\setboolean{showSolution}{true}

% 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.
\newcounter{problem}
\newcommand{\specialsymbol}{$\bigstar$ }
\newlength{\specialsymbollength}
\settowidth{\specialsymbollength}{\specialsymbol}
\newenvironmentx{problem}[2][1={},2={},usedefault]{%
    \refstepcounter{problem}%
    \Writetofile{shortsolutions}{\protect\hypertarget{soln:\theproblem:\thechapter}{}}%
    \needspace{\baselineskip}%
    \ifthenelse{\isodd{\theproblem}}% 
        {%
            \ifthenelse{\boolean{showoddsolns}}%
            {}% true (by default)
            {\setboolean{showSolution}{false}}%
        }%
        {%
            \ifthenelse{\boolean{showevensolns}}%
            {}% true (by default)
            {\setboolean{showSolution}{false}}%
        }%
    \ifthenelse{\equal{#2}{}}%
    {%  NOT special problem
        % if no second argument (special or not)
        \ifthenelse{\equal{#1}{}}%
        {% Problem withOUT description
            \ifthenelse{\boolean{showSolution}}%
            {%
                {\hypertarget{prob:\theproblem:\thechapter}{}%
                 {{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem}}}\newline}%
            }%
            {%
                 {\bfseries Problem \theproblem}\newline%
            }%
        }%
        {% Problem with description
            \ifthenelse{\boolean{showSolution}}%
            {%
                {\hypertarget{prob:\theproblem:\thechapter}{}%
                 {{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem} \,(#1)}}\newline}%
            }%
            {%
                 {\bfseries Problem \theproblem\, (#1) }\newline%
            }%
        }%
    }%
    {%  special problem
        \ifthenelse{\equal{#2}{special}}%
        {%
            % write problem number to specialfile
            \addcontentsline{prb}{}{\theproblem}%
            \ifthenelse{\equal{#1}{}}%
            {%  special problem with no description
                \ifthenelse{\boolean{showSolution}}%
                {% 
                    {\hypertarget{prob:\theproblem:\thechapter}{}%
                     {\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
                \ifthenelse{\boolean{showSolution}}%
                {% with links
                    {\hypertarget{prob:\theproblem:\thechapter}{}%
                     {\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
\newcounter{subproblem}[problem]
\newboolean{specialproblemYesNo}
\setboolean{specialproblemYesNo}{false}
\newenvironment{subproblem}[1][]{%
    \refstepcounter{subproblem}%
        \ifthenelse{\isodd{\theproblem}}% 
        {%
            \ifthenelse{\boolean{showoddsolns}}%
            {}% true (by default)
            {\setboolean{showSolution}{false}}%
        }%
        {%
            \ifthenelse{\boolean{showevensolns}}%
            {}% true (by default)
            {\setboolean{showSolution}{false}}%
        }%
        \ifthenelse{\equal{#1}{special}}%
        {%
            \setboolean{specialproblemYesNo}{true}%
        }%
        {%
            \setboolean{specialproblemYesNo}{false}%
        }%
        \ifthenelse{\boolean{specialproblemYesNo}}%
        {% special problem
            \addcontentsline{prb}{}{\theproblem.\thesubproblem}%
            \ifthenelse{\boolean{showSolution}}%
            {%  hyperlink to solution
                \hypertarget{prob:{\theproblem.\thesubproblem}:\thechapter}{}%
                \hypersetup{linkcolor=black}%
                \begin{enumerate}[label=\llap{$\bigstar$ }\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem,leftmargin=*]
                \item%
            }%
            {%  no hyperlink
                \begin{enumerate}[label=\llap{$\bigstar$ }\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem,leftmargin=*]
                \item%
            }%
        }%
        {% NOT special problem
            \ifthenelse{\boolean{showSolution}}%
            {%  hyperlink to solution
                \hypertarget{prob:{\theproblem.\thesubproblem}:\thechapter}{}%
                \hypersetup{linkcolor=black}%
                \begin{enumerate}[label=\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem,leftmargin=*]
                \item%
            }%
            {%  no hyperlink
                \begin{enumerate}[label=\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem,leftmargin=*]
                \item%
            }%
        }%
        }{\end{enumerate}}


% definition
\theoremstyle{break}
\theoremsymbol{}
\theoremseparator{}
\theoremprework{\FloatBarrier}
\def\theoremframecommand{%
      \psshadowbox[fillstyle=solid,fillcolor=yellow,linecolor=black]}
\newshadedtheorem{pccdefinition}{Definition}%[chapter]
%   END CUSTOM THEOREMS (for examples, problems)

%   BEGIN special PROBLEMS
\newcounter{probSectCounter}
\setcounter{probSectCounter}{-1}
\newcounter{probCounter}
\setcounter{probCounter}{0}%
\newcounter{echo}
\newread\File

% redefine the \section command to increment probSectCounter
% note that this could also be done for \subsection if desired
\let\oldsection\section
\renewcommand\section{%
            \stepcounter{probSectCounter}%
            %\addcontentsline{prb}{heading\theprobSectCounter}%
            \addcontentsline{prb}{}{heading\theprobSectCounter}%
            \oldsection}

\makeatletter

% need a command to bring the \contentsline
% into the problemlist environment
\let\pcc@contentslist\contentsline%
\newenvironment{problemlist}%
{%
    % 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!
    \let\contentsline\pcc@contentslist%
    \let\Contentsline\contentsline%
    \renewcommand\contentsline[4]{%
    \StrCount{##2}{heading}[\heading]%
    \ifthenelse{\heading>0}%
    {%
        \StrCount{##2}{heading\theprobSectCounter}[\heading]%
        \ifthenelse{\heading>0}%
        {%
            \setcounter{echo}{1}%
            \setcounter{probCounter}{0}%
        }%
        {%
            \setcounter{echo}{0}%
        }%
    }%
    {%
        \ifthenelse{\equal{\theecho}{1}}%
        {%
            \stepcounter{probCounter}%
            \ifthenelse{\equal{\theprobCounter}{1}}%
            {%
                % 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}%
            }%
        }%
        {}%
    }%
    }%
}%
{}

\def\listspecialproblems{%
% open the appropriate file do everything in a 
% new environment so that we can renew the 
% \contentsline command locally 
\begin{problemlist}
\par%
\openin\File=\jobname.prb%
\loop\unless\ifeof\File%
\read\File to\fileline%
\fileline%
\repeat%
\closein\File%
\end{problemlist}
}%

% enable the \jobname.prb file
% (hacked from the ntheorem package)
\def\prb@enablelistofproblems{%
\begingroup%
\makeatletter%
\if@filesw%
\expandafter\newwrite\csname tf@prb\endcsname%
\immediate\openout \csname tf@prb\endcsname \jobname.prb\relax%
\fi%
\@nobreakfalse%
\endgroup}%

% enable the \jobname.prb<counter> files at the end
% of the document
\AtEndDocument{\prb@enablelistofproblems}

\makeatother

%   END special PROBLEMS

%   BEGIN TABLE STYLES
\renewcommand{\heavyrulewidth}{0.2em}
\renewcommand{\lightrulewidth}{0.1em}
\renewcommand{\cmidrulewidth}{0.1em}
% horizontal lines
\renewcommand{\aboverulesep}{0cm} 
\renewcommand{\belowrulesep}{0cm} 
\newcommand*\heading[1]{\hfill{#1}\hfill}
\newcommand*\beforeheading{\toprule}
\newcommand*\afterheading{\midrule}
%\newcommand*\normalline{\hline}
\newcommand*\normalline{}
\newcommand*\lastline{\bottomrule}
%   END TABLE STYLES

%   BEGIN CUSTOMIZE SECTIONS
% custom chapter
\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\bf}
{\titlerule[1pt]%
\vspace{1pt}%
\titlerule
\LARGE\MakeUppercase{#1} \psshadowbox{\Huge\thechapter}}
{1pc}
{\titlerule
\Huge}

% write to the solutions files to step the chapter counter
\let\oldchapter\chapter
\renewcommand{\chapter}{\Writetofile{shortsolutions}{\protect\stepcounter{chapter}}%
\oldchapter}

% 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{\chapter}{0pt}{*4}{-0.1cm}
\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}

%   END CUSTOMIZE SECTIONS

%====================================
%   BEGIN DOCUMENT
%====================================
\begin{document}

\renewcommand{\labelenumi}{(\alph{enumi})}

% needed for the mini-tableofcontents
\dominitoc
\faketableofcontents

\fancyhf{} % delete current header and footer
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO,RE]{\tiny\leftmark}

\pagestyle{fancy}
\include{polynomialfunctions}

%=======================
%   BEGIN SOLUTIONS
%=======================

% change to one-sided mode
% change the pagestyle to plain
% change the page geometry using \newgeometry
\setboolean{@twoside}{false} 
\pagestyle{plain}
\newgeometry{left=1cm,right=1cm,showframe=true,
    textheight=27cm,
    top=1.5cm,bottom=1.5cm,bindingoffset=1cm}

% close the solutions files
\Closesolutionfile{shortsolutions}

% 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
\newboolean{oddproblemnumber}
\renewenvironment{shortSoln}[1]{%
    \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 '.'
    \StrCount{#1}{.}[\numberofdecimals]
    %
    % find the problem number by splitting the string
    \ifthenelse{\numberofdecimals=0}%
    {%
        % problems, such as 4, 5, 6, ...
        \def\problemnumber{#1}%
    }%
    {}%
    \ifthenelse{\numberofdecimals=1}%
    {%
        % problems, such as 4.3, 1.2, 10.5
        \StrBefore{#1}{.}[\problemnumber]%
    }%
    {}%
    \ifthenelse{\numberofdecimals=2}%
    {%
        % subproblems such as 1.3.1, 1.2.4, 7.5.6
        \StrBehind{#1}{.}[\newbit]%
        \StrBefore{\newbit}{.}[\problemnumber]%
     }%
    {}%
     %
     % determine if the problem number is odd or even
     % and depending on our choices above, display or not
     \ifthenelse{\isodd{\problemnumber}}%
     {%
         % set a boolean that says the problem number is odd (used later)
         \setboolean{oddproblemnumber}{true}%
         % display or not 
         \ifthenelse{\boolean{showoddsolns}}%
         {%
            % if we want to show the odd problems
            {\bfseries \hypertarget{soln:#1:\thechapter}{}\hyperlink{prob:#1:\thechapter}{#1}.}%
         }%
         {%
            % otherwise don't show them!
            \expandafter\comment%          
         }%
     }%
     {%
         % even numbered problem, set the boolean (used later)
         \setboolean{oddproblemnumber}{false}%
         \ifthenelse{\boolean{showevensolns}}%
         {%
            % if we want to show the even problems
            {\itshape \hypertarget{soln:#1:\thechapter}{}\hyperlink{prob:#1:\thechapter}{#1}.}%
         }%
         {%
            % otherwise don't show them!
            \expandafter\comment%          
         }%
     }%
}%
{%
    % after the environment finishes
    \ifthenelse{\boolean{oddproblemnumber}}%
    {%
        % odd numbered problems 
         \ifthenelse{\boolean{showoddsolns}}%
         {%
            % if we want to show the odd problems
            % then the environment is finished
         }%
         {%
            % otherwise we need to finish the comment
            \expandafter\endcomment%
         }%
    }%
    {%
        % even numbered problems
         \ifthenelse{\boolean{showevensolns}}%
         {%
            % if we want to show the even problems
            % then the environment is finished
         }%
         {%
            % otherwise we need to finish the comment
            \expandafter\endcomment%
         }%
    }%
}


\clearpage

% set solution figure width
\newlength{\solutionfigurewidth}
\setlength{\solutionfigurewidth}{3cm}

% input the SHORT solutions file
\IfFileExists{shortsolutions.tex}{\input{shortsolutions.tex}}{}

%=======================
%   END SOLUTIONS
%=======================

\end{document}
share|improve this answer
    
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 Dec 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. –  cmhughes Dec 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

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

share|improve this answer
    
I really like this, have you considered turning it into a CTAN package? –  doncherry Nov 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... –  Ant Nov 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. –  doncherry Nov 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:

% the document class, no big deal
\documentclass[a4paper,oneside,11pt]{book}

% the usual packages
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}

% index features
\usepackage{imakeidx}

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
\usepackage{idxlayout}

% drawing stuff
\usepackage{tikz}

% swiss army knife
\usepackage{etoolbox}

% for string comparison
\usepackage{xstring}

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
\newcommand*\drawtype[1]{%
  \begin{tikzpicture}
    \node[draw,circle,inner sep=1pt, minimum height=0.5cm, minimum width=0.5cm] {\scriptsize #1};
  \end{tikzpicture}%
}

The songs package, of course:

% songs
\usepackage[lyric]{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
\DeclareRobustCommand*\drawbullets[1]{%
  {\footnotesize%
  \IfSubStr{#1}{A}{$\bullet$}{$\circ$}%
  \IfSubStr{#1}{B}{$\bullet$}{$\circ$}%
  \IfSubStr{#1}{C}{$\bullet$}{$\circ$}%
  \IfSubStr{#1}{D}{$\bullet$}{$\circ$}}~%
}

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
\newcommand*\timebox[1]{%
  \begin{tikzpicture}
    \node[draw,inner sep=1pt, minimum height=0.3cm, minimum width=0.3cm] {\tt\raisebox{0pt}[\height][0pt]{#1}};
  \end{tikzpicture}%
}

% print a timebox and add a space
\newcommand*\indextime[1]{%
  \timebox{#1}~%
}

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
\DeclareListParser*{\myforeach}{,}

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

% create a command that will print a
% timebox for every letter found
\newcommand*\settime[1]{%
  \myforeach{\indextime}{#1}%
}

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
\newcommand*\indexsong[1]{%
  \IfEq{#1}{F}{%
    \resettitles%
    \index[foo]{\songtitle@\songliturgy \songtitle}
    \drawtype{F}~%
  }{%
    \IfEq{#1}{B}{%
      \resettitles%
      \index[bar]{\songtitle@\songliturgy \songtitle}
      \drawtype{B}~%
    }{%
      \IfEq{#1}{FB}{%
        \resettitles%
        \index[foobar]{\songtitle@\songliturgy \songtitle}
        \drawtype{FB}~%
      }{%
        \IfEq{#1}{Q}{%
          \resettitles%
          \index[qux]{\songtitle@\songliturgy \songtitle}
          \drawtype{Q}~%
        }{%
          \textbf{Error!}%
        }%
      }%
    }%
  }%
}%

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

% create both song and author indices
\newindex{reltitleidx}{cbreltitle}
\newauthorindex{relauthidx}{cbrelauth}

% bold chorus font
\renewcommand{\chorusfont}{\bfseries}

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:

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

share|improve this answer

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}

And the output:

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

share|improve this answer
    
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 Grill Nov 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 Zero Nov 18 '11 at 17:12
    
Is this a submission for academic or other? I'd say other? –  doncherry Nov 25 '11 at 14:33
    
That's right: I forgot to mention: it's OTHER. –  Count Zero Nov 25 '11 at 15:36

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:

\begin{tikzpicture}[scale=2]
\calligraphy[
  copperplate,
  heavy line width=8pt,
  light line width=4pt,
  weight=heavy,
  annotate,
  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)
;
\end{tikzpicture}
share|improve this answer
    
Is this a submission for academic or other? I'd say other since the "crucial part" is about calligraphy? –  doncherry Nov 25 '11 at 14:34
1  
Sounds fine to me. I should have specified, sorry. –  Loop Space Nov 25 '11 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.
share|improve this answer
    
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 Nov 19 '11 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). –  Max Lambertini Nov 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 –  Aditya Nov 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 Lambertini Nov 21 '11 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
             width=180mm,
             height=260mm,
             backspace=15mm,
             topspace=17mm,
             grid=yes,
            ]
\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)
  enddef;
\stopMPinclusions

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

\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;
\stopuniqueMPgraphic

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

\defineframed[lhookframed][       % New framed-like command
  location=low,     % this is equivalent to \inframed
  background=lhook, % background picture
  frame=off,        % no frame
  width=85mm,
  strut=no,
  boffset=0.5ex,    % this is manual tuning
  loffset=0.33em,
  align=flushleft]
\defineframed[rhookframed][       % Analogous to the previous one
  location=low,
  background=rhook,
  frame=off,
  width=85mm,
  strut=no,
  boffset=0.5ex,
  align=flushleft]

\starttext

\startalignment[middle]           % Title
  \tfb
  \leavevmode
  \lhookframed[width=100mm,align=normal]{Class name}
  \startlinecorrection           % Seemingly, this is needed because
  \blank[3*small]                % of grid typesetting
  \leavevmode
  \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
  \hfill
  \rhookframed[width=30mm]{Room}
  \hfill
  \rhookframed[width=30mm]{Class no}
  \stoplinecorrection
\stopalignment

\startcolumns[n=2] % two columns
\lhookframed{A--D}
\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{I--K}
\dorecurse{12}{\rhookframed{}}
\lhookframed{L--O}
\dorecurse{10}{\rhookframed{}}
\lhookframed{P--T}
\dorecurse{13}{\rhookframed{}}
\lhookframed{U--Z}
\dorecurse{10}{\rhookframed{}}
\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
\stopcolumns

\stoptext
share|improve this answer
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 Nov 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? –  mbork Nov 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). –  Aditya Nov 19 '11 at 21:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.