What is the mindset to take when using ConTeXt vs LaTeX?
ConTeXt also focuses on separation of content and presentation. In all ConTeXt documents that I write, I use:
\setvariables
[metadata]
[
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@[email protected]{%
\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@[email protected]\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
\headheight=0pt
\headsep=0pt
\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
\ifx\@titlehead\@empty \else
\begin{minipage}[t]{\textwidth}%
\usekomafont{titlehead}{\@titlehead\par}%
\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@[email protected]}>\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@[email protected]\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\@titlehead\@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\titlehead\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.
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!