# I want to type a document once and typeset it at multiple different levels of complexity

I think this is clearest in an example. Here's my document:

\begin{enumerate}
\item{1} The heart
\begin{enumerate]
\item{1} It pumps blood through the body.
\item{2} It has four chambers.
\item{2} The inferior and superior vena cava bring blood from the body.
\end{enumerate}
\end{enumerate}


The idea is that I could set typeset-level=1 and get a document that just says:

1. The heart

a. It pumps blood through the body.

Or I could set typeset-level={1-2} and it typesets the whole thing. I don't want to be restricted to typesetting certain "depths" of the outline, I want to be able to specify, for each entry, a "complexity level".

The goal is to make documents for my students such that a student with no background can read the level 1 doc, then the level 2 doc, etc. and the student with good background can just skip to the level 3 doc. And I think the level 1 doc should always be a subset of the level 2 doc (and 2 a subset of 3, etc.).

Thanks for any suggestions you can offer!

• Could you mock up an ideal use case? (Or is the example you give your ideal use case? I think that may be a little hard to effect.) – Sean Allred Sep 19 '13 at 1:44
• The standard way to do this in ConTeXt is to use Modes – Aditya Sep 19 '13 at 2:17
• @Aditya -- this is exactly what I was looking for. Thank you! It's the kind of thing that's rather hard to google for. – rcorty Sep 19 '13 at 2:32
• @Aditya care to mock-up an answer? :) – cmhughes Sep 19 '13 at 3:37

As I said in the comment above, in ConTeXt you can use modes for such conditional processing. I also like to use semantic markup, so if I were creating such a document, I'd do the following:

1. Create dummy environments notes and details that, by default, simply gobble their content. In ConTeXt, such environments are created using definebuffer[...].

2. If the modes notes or details are set, redefine the notes environment so that it simply typesets its content. In ConTeXt, such an environment is created using \definestartstop[...].

3. If the modes details is both set, redefine details environment so that it simply typesets its content.

Combining this logic, we get the following:

\definebuffer[notes]
\definebuffer[details]

\startmodeset
[notes,details]  {\definestartstop[notes] }
[details]        {\definestartstop[details]}
\stopmodeset


Now, lets take a test document.

\starttext

\startitemize[n]
\item The heart
\startnotes
\startitemize[a]
\item It pumps blood through the body
\startdetails
\item It has four chambers
\item The inferior and superior vena cava bring blood from the body.
\stopdetails
\stopitemize
\stopnotes
\stopitemize
\stoptext


When we compile this document using context filename, we get

When we compile this document using context --mode=notes filename, we get

When we compile this document using context --mode=details filename, we get

If you are compiling the document from an editor rather than command line, you can add

\enablemode[notes]


on the top of the file rather than passing it as a command line argument.

While I don't doubt that ConTeXt's modes are much more robust and interesting than this answer, for simple(r) applications, you could do something like this.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

\newif\ifTLone
\newif\ifTLtwo
\newif\ifTLthree

% \TLonetrue
\TLtwotrue
% \TLthreetrue

% note: \def is used here for brevity; it is a bad choice if your text
% is \long-er than a paragraph

\ifTLone
\def\tli   #1{#1}
\def\tlii  #1{}
\def\tliii #1{}
\fi

\ifTLtwo
\def\tli   #1{#1}
\def\tlii  #1{#1}
\def\tliii #1{}
\fi

\ifTLthree
\def\tli   #1{#1}
\def\tlii  #1{#1}
\def\tliii #1{#1}
\fi

\begin{document}

This is outside all levels. Hopefully most of your text fits in this
category.

\tli  {This is level one.}  \par
\tlii {This is level two.}  \par
\tliii{This is level three.}\par

\begin{itemize}
\tliii{\item TL 3: $a + b = x^2$}

\item regular%
\tliii{\footnote{A super-secret footnote for those already in the know.}}

\tlii{\item TL 2.}

\item regular
\end{itemize}

\end{document}


There are obvious limitations like jamming some verbatim text in these macros, but if you don't need to do anything nearly so fancy this might get the job done.

You could also move the \newif and \ifTL<level> declarations out of the file and call them from the command line instead, and combine with the -jobname=<filename> to create the different 'levels' of output files: assuming an original input file called myfile.tex, use:

pdflatex -jobname=TLtwo "\newif\ifTLone\newif\ifTLtwo\newif\ifTLthree\TLtwotrue\input{filename.tex}"


This should produce TLtwo.pdf with up to level 2 realized in the output.