# What is the mindset to take when using ConTeXt vs LaTeX?

Having recently gotten back into writing with LaTeX, I explored XeTeX and found advances in using modern fonts, explored LuaTeX and found a next-gen development underway, and explored ConTeXt and found ... a focus on formatting?

To me, LaTeX and its variations have always been about separating the content from the formatting. This is why we use \begin{abstract} ... \end{abstract} and don't worry about how that is typeset. Every now and then we want to tweak a setting, but myself, I've found that rare.

But in reading about ConTeXt and how to use it I find articles such as this one about Document Titles that teaches how to format the title page, something that was trivial in LaTeX. This article advocates writing 60 lines of formatting code and putting it into a separate module so that you can achieve a similar effect.

I cannot help but feel that I am missing something in the philosophy behind ConTeXt. The project page doesn't make it clear other than to say that it is a "document processing system". It also says that "ConTeXt documents are written without formatting", which isn't quite true, as I'm starting to learn (e.g. see article above).

Can someone please explain the mindset one should take while using ConTeXt? Am I expected to supply extensive formatting instructions while using this typesetting system?

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Jan 14 '15 at 19:16
• You just need to supply them once. LaTeX has a default set for you, in ConTeXt (I say without knowing anything really) you don't have a default, but an astonishly robust way of setting that default. It's a “pity” you need to set that default, but once it's set (which is easier to configure than if you were using LaTeX), there's no need to look back again at it. Jan 14 '15 at 19:20
• ConTeXt is in many ways closer to plain TeX in this area: there's more of a sense that you are expected to design the document, not just supply the 'content'. That said, I'm not sure what a solid answer would look like here: the ConTeXt wiki shows how things are done, but perhaps you might want to ask on their mailing list. Jan 14 '15 at 20:23
• @JosephWright Isn't Plain TeX just too far? I mean, in my opinion it's definitely not like that. More like listings which have tons of options, and little “defaults”; it's common to see a file carrying with a \lstset{..} with more than twenty keys-values. Why is that? Becauste there are not many defaults set and one has to set them; in any case, it's not dificult to see packages which set those defaults for you (Jubobs' matlab-prettifier). Jan 14 '15 at 22:59
• @Manuel I didn't say it was the same as plain, I said it was closer. What I was trying to get at is that there is no built in concept of a 'type' of document in ConTeXt: they all start off the same. As such, there is not the idea that 'some one' should normally have provided the design and additional functionality one needs beyond the core. In the same way, most plain users expect to have to do their own design and functionality extension. Of course, the ConTeXt core is a lot bigger than plain or indeed LaTeX. Jan 15 '15 at 6:55

ConTeXt also focuses on separation of content and presentation. In all ConTeXt documents that I write, I use:

\setvariables
[
title=...,
author=...,
affiliation=...,
date=...,
]


which gives a nice document title, sets the appropriate fields of the PDF file (something that you do using hyperref package in LaTeX), and I have markings metadata:title and metadata:author that can be used in the headers and footers. Similar to LaTeX. The difference being that the macros that does this was not provided by ConTeXt but written by me.

The reason ConTeXt does not provide a default implementation for something similar to \maketitle is that it is impossible to find a solution that fits everyone. The information that goes into a title is different for books, articles, reports, etc. So, ConTeXt leaves it to the document authors to create a command for typesetting titles, as they see fit. ConTeXt provides enough high-level commands that it is relatively easy for users to create sophisticated macros.

LaTeX takes a different approach. It provides a default implementation for \maketitle. In article.cls it is defined as:

  \if@titlepage
\newcommand\maketitle{\begin{titlepage}%
\let\footnotesize\small
\let\footnoterule\relax
\let \footnote \thanks
\null\vfil
\vskip 60\p@
\begin{center}%
{\LARGE \@title \par}%
\vskip 3em%
{\large
\lineskip .75em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1.5em%
{\large \@date \par}%       % Set date in \large size.
\end{center}\par
\@thanks
\vfil\null
\end{titlepage}%
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}
\else
\newcommand\maketitle{\par
\begingroup
\renewcommand\thefootnote{\@fnsymbol\c@footnote}%
\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
\long\def\@makefntext##1{\parindent 1em\noindent
\hb@xt@1.8em{%
\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
\if@twocolumn
\ifnum \col@number=\@ne
\@maketitle
\else
\twocolumn[\@maketitle]%
\fi
\else
\newpage
\global\@topnum\z@   % Prevents figures from going at top of page.
\@maketitle
\fi
\thispagestyle{plain}\@thanks
\endgroup
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}
\def\@maketitle{%
\newpage
\null
\vskip 2em%
\begin{center}%
\let \footnote \thanks
{\LARGE \@title \par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1em%
{\large \@date}%
\end{center}%
\par
\vskip 1.5em}
\fi


Other document classes redefine it as appropriate. For example, scrartcl.cls (Koma Script) defines it as:

\newcommand*\maketitle[1][1]{%
\expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
\else
\def\and{%
\end{tabular}%
\hskip 1em \@plus.17fil%
\begin{tabular}[t]{c}%
}%
\fi
\if@titlepage
\begin{titlepage}
\setcounter{page}{%
#1%
}%
\if@titlepageiscoverpage
\edef\titlepage@restore{%
\noexpand\endgroup
\noexpand\global\noexpand\@colht\the\@colht
\noexpand\global\noexpand\@colroom\the\@colroom
\noexpand\global\vsize\the\vsize
\noexpand\global\noexpand\@titlepageiscoverpagefalse
\noexpand\let\noexpand\titlepage@restore\noexpand\relax
}%
\begingroup
\topmargin=\dimexpr \coverpagetopmargin-1in\relax
\oddsidemargin=\dimexpr \coverpageleftmargin-1in\relax
\evensidemargin=\dimexpr \coverpageleftmargin-1in\relax
\textwidth=\dimexpr
\paperwidth-\coverpageleftmargin-\coverpagerightmargin\relax
\textheight=\dimexpr
\paperheight-\coverpagetopmargin-\coverpagebottommargin\relax
\footskip=\baselineskip
\@colht=\textheight
\@colroom=\textheight
\vsize=\textheight
\columnwidth=\textwidth
\hsize=\columnwidth
\linewidth=\hsize
\else
\let\titlepage@restore\relax
\fi
\let\footnotesize\small
\let\footnoterule\relax
\let\footnote\thanks
\renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
\let\@oldmakefnmark\@makefnmark
\renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
\ifx\@extratitle\@empty \else
\noindent\@extratitle\next@tdpage
\fi
\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
\begin{minipage}[t]{\textwidth}%
\end{minipage}\par
\fi
\null\vfill
\begin{center}
\ifx\@subject\@empty \else
{\usekomafont{subject}{\@subject\par}}%
\vskip 3em
\fi
{\usekomafont{title}{\huge \@title\par}}%
\vskip 1em
{\ifx\@subtitle\@empty\else\usekomafont{subtitle}{\@subtitle\par}\fi}%
\vskip 2em
{%
\usekomafont{author}{%
\lineskip 0.75em
\begin{tabular}[t]{c}
\@author
\end{tabular}\par
}%
}%
\vskip 1.5em
{\usekomafont{date}{\@date \par}}%
\vskip \z@ \@plus3fill
{\usekomafont{publishers}{\@publishers \par}}%
\vskip 3em
\end{center}\par
\@thanks\let\@thanks\@empty
\vfill\null
\if@twoside
\@tempswatrue
\expandafter\ifnum \@nameuse{scr@v@3.12}>\scr@compatibility\relax
\else
\ifx\@uppertitleback\@empty\ifx\@lowertitleback\@empty
\@tempswafalse
\fi\fi
\fi
\if@tempswa
\next@tpage
\begin{minipage}[t]{\textwidth}
\@uppertitleback
\end{minipage}\par
\vfill
\begin{minipage}[b]{\textwidth}
\@lowertitleback
\end{minipage}\par
\@thanks\let\@thanks\@empty
\fi
\fi
\ifx\@dedication\@empty
\else
\next@tdpage\null\vfill
{\centering\usekomafont{dedication}{\@dedication \par}}%
\vskip \z@ \@plus3fill
\@thanks\let\@thanks\@empty
\cleardoubleemptypage
\fi
\ifx\titlepage@restore\relax\else\clearpage\titlepage@restore\fi
\end{titlepage}
\else
\par
\@tempcnta=%
#1%
\relax\ifnum\@tempcnta=1\else
\ClassWarning{\KOMAClassName}{%
Optional argument of \string\maketitle\space ignored
at\MessageBreak
notitlepage-mode%
}%
\fi
\begingroup
\let\titlepage@restore\relax
\renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
\let\@oldmakefnmark\@makefnmark
\renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}
\next@tdpage
\if@twocolumn
\ifnum \col@number=\@ne
\@makeextratitle
\next@tdpage
\@maketitle
\else
\ifx\@extratitle\@empty\else
\twocolumn[\@makeextratitle]\next@tdpage
\fi
\twocolumn[\@maketitle]%
\fi
\else
\@makeextratitle
\@maketitle
\fi
\thispagestyle{\titlepagestyle}\@thanks
\endgroup
\fi
\setcounter{footnote}{0}%
\expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
\let\thanks\relax
\let\maketitle\relax
\let\@maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\@subtitle\@empty
\global\let\@extratitle\@empty
\global\let\@subject\@empty
\global\let\@publishers\@empty
\global\let\@uppertitleback\@empty
\global\let\@lowertitleback\@empty
\global\let\@dedication\@empty
\global\let\author\relax
\global\let\title\relax
\global\let\extratitle\relax
\global\let\subject\relax
\global\let\publishers\relax
\global\let\uppertitleback\relax
\global\let\lowertitleback\relax
\global\let\dedication\relax
\global\let\date\relax
\fi
\global\let\and\relax
}%


Note that Koma Script has added other keywords such as dedication, publisher, which were not provided by artcle class. One might ask, why only these additional keywords? What if I need others?

Note that the macro on ConTeXt wiki for document titles is pretty similar to the LaTeX implementation. It is also configurable. For example, I can use:

\setuptitle
[
authorstyle=italic,
titlecolor=blue,
]


which will typeset the title in blue color and the author in italic font. The Koma Script classes provide additional commands (and hence additional lines of code) to provide this flexibility.

The project page doesn't make it clear other than to say that it is a "document processing system". It also says that "ConTeXt documents are written without formatting", which isn't quite true, as I'm starting to learn (e.g. see article above).

When it comes to document preparation, LaTeX and ConTeXt are quite similar; both use high-level markup and assume that a style file is available to take care of the formatting. The difference is that LaTeX assumes that the user who is preparing the document is different from the user who created the style file; so very little high-level commands are provided to tweak the default styles. ConTeXt assumes that the user who is preparing the document is the same as the user who is creating the style file; and provides high-level commands to tweak the default styles.

The other difference is that of culture. The LaTeX community releases a lot of packages; but the ConTeXt community releases relatively few packages. For example, you would not have complained if the code for document titles from the ConTeXt wiki had been released as a ConTeXt package.

• I appreciate the straight-up explanation. The point about ConTeXt assuming the same person writing content and also creating the style pretty much sums it up.
– ana
Jan 15 '15 at 3:48

Can someone please explain the mindset one should take while using ConTeXt?

"I am going to write a structured document. If I feel like styling it, or adding a new kind of semantic element, or both, that will be easy."

For example, your document may have the concept of important sections, which should be styled like normal sections, but in red.

\definehead[importantsection][section][color=red]  % styling

\importantsection{Pay Attention Now, Dougal}  % semantic/structural markup


Am I expected to supply extensive formatting instructions while using this typesetting system?

No -- just like with LaTeX, the default looks fine. But if you want to add styling, it's easy. Many users consider this a plus, which is why so many examples feature it.

Another reason that you encounter so much formatting code online is that ConTeXt has many features already built in, and it was built to allow customizing. As a result, where with LaTeX one would might reply to a question with "this package does what you want", with ConTeXt people more often say "these built-in commands do what you want"; as a result, the culture is focused on mastering ConTeXt's features more than on building packages to extend it.

ConTeXt indeed does not include an environment for abstracts by default. But is \definenarrower[abstract] plus \startabstract...\stopabstract really so different from \usepackage{amsmath} plus \begin{cases}...\end{cases}?

A last note on philosophy.

ConTeXt doesn't focus on formatting at the expense of structural markup -- it focuses on formatting structural markup, just like Plain TeX, and LaTeX. All three offer good-looking default styles; and ConTeXt makes it very easy to change that style. But in ConTeXt like in LaTeX, the core is the structural markup.

# ConTeXt is more akin to CSS

My personal (and perhaps controversial) view is that ConTeXt is more akin to CSS, which is why I prefer it over LaTeX. Only when a very specific LaTeX class is required (e.g. letter or curriculum vitæ), do I reach back to LaTeX.

Furthermore, ConTeXt comes with "batteries included," so you save yourself from the LaTeX include/package hell.

Typical ConTeXt use starts off with defining the appearance of the elements of your document, right before \starttext. In such, ConTeXt achieves a clear separation between content and style, resembling recommended CSS use. This is also how I am using ConTeXt nowadays; as a mere templating language for Pandoc, whereby the actual content is written in Markdown.

That said, many of the official examples given at ConTeXtgarden are misleading in showcasing the vast array of possibilities with inline formatting commands. This is not typical ConTeXt use and could be frowned upon pretty much as one would frown upon an HTML page using inline CSS styling as in:

 <h1 style="color:blue;margin-left:30px;">This is a heading.</h1>


Finally, unlike LaTeX, there is no need to run ConTeXt three times in order to obtain a final version with the table of contents, references and index right. ConTeXt gets it right on the first run!

• Regardless if your comparison of ConTeXt to CSS makes sense or not, I think you should rephrase your last paragraph. I don't see why you are in a position to decree what is "typical ConTeXt usage" (do you have any sort of evidence for this?) and what should or shouldn't be "frowned upon." Dec 14 '16 at 8:36
• @Thomas I changed "should" to "could". Nonetheless, I started my answer with "To me personally…" As for evidence, cfr. page 7: "Set ups are typed in the set up area just before \starttext." Here is another good book example. Dec 14 '16 at 8:48
• This does not provide an immediate answer to the question but defers the problem to another one, namely, which mindset should I take when using CSS. Also, because you (and I as well) consider inline formatting bad style I would in no way claim that it is not »the ConTeXt-way«. Dec 14 '16 at 10:54
• ConTeXt is just a tool. The objective is creating a typeset text according to the rules of typography which were developed during the last 500 years or so. What is great about ConTeXt is that writing source code of a ConTeXt document is like doing a description of a typeset work using terminology which is very close to what you can find in any book on typography. But ConTeXt is not only about automatic typesetting. The fact that you can fiddle with minute aspects of your work after you defined them in the preamble is very much part of »the ConTeXt-way«. Usually you don't have to, fortunately. Jan 10 '17 at 8:59
• Who better to respond to this question than Hans Hagen, principal developer of ConTeXt? Hans Hagen nicely explains his motivations for developing ConTeXt in this interview. Apr 23 '19 at 6:30

Two mindsets, not just one!

"I am a professional publisher, not a scientific journal editor or author of scientific articles. I can easily transform designer's concepts into typesettable templates and present authors with a simple set of rules for structuring their texts, that is easy to follow."

or

"I am a typographic artist. I have access to all typographic aspects of my work at any place. I can use programmable typographic interface to obtain results impossible to achieve in standard typesetting solutions"