Difference between revisions of "Article Abstracts"

From Wiki
Jump to navigation Jump to search
(Added the "more reusable" solution.)
m (Removed the overall todo, as I've done it.)
Line 1: Line 1:
 
< [[From LaTeX to ConTeXt]] | [[Document Titles]] >
 
< [[From LaTeX to ConTeXt]] | [[Document Titles]] >
 
{{todo|This is sort of a stub article which I sketched out to remind myself what I wanted to write later.  If anyone else wants to work on it, feel free!}}
 
  
 
== LaTeX ==
 
== LaTeX ==

Revision as of 02:11, 5 September 2005

< From LaTeX to ConTeXt | Document Titles >

LaTeX

Much as with Document Titles, the standard LaTeX article and report classes define an abstract environment to typeset an abstract in a way that distinguishes it from the rest of the text. In a single-column article, it is set somewhat narrower than the main text, with the word "Abstract" centered above it.

\documentclass{article}
\begin{document}
  \begin{abstract}
    This is the abstract of the paper.
  \end{abstract}
\end{document}

ConTeXt: A simple solution

The simplest way of producing an abstract in a ConTeXt document is to specify the formatting directly. The code from LaTeX's classes.dtx is nearly trivial, and is quite easy to replicate in ConTeXt idioms.

\starttext
\midaligned{\bf Abstract}
\startnarrower[2*middle]
This is the document's abstract.  It contains enough text for two lines, but no more.
\stopnarrower
\blank[big]

This is the main text of the document.  Like the abstract, it contains enough text
for two lines, to show the margins.
\stoptext

In the two-column document classes, LaTeX's abstract environment does nothing beyond putting a \section*{Abstract} in front of the abstract's text. This can be easily replicated in ConTeXt with \subject{Abstract}. (See Unnumbered Sections.)

ConTeXt: A more reusable solution

As with Document Titles, to replicate the spirit of the LaTeX environment, we might want to separate the document formatting commands from the actual text of the abstract. Thus, we can define an abstract environment using the following commands:

\def\startabstract{%
  \midaligned{\bf Abstract}
  \startnarrower[2*middle]}
\def\stopabstract{%
  \stopnarrower}

This code can be placed in the document header, or can be placed in a module file to be loaded in a number of documents. It could also be enhanced by \if statements to distinguish between the one-column and two-column cases, as LaTeX does. In any case, once these commands are defined, they can be used in the obvious manner.

\starttext
\startabstract
This is the document's abstract.  It contains enough text for two lines, but no more.
\stopabstract

This is the main text of the document.  Like the abstract, it contains enough text
for two lines, to show the margins.
\stoptext

This, of course, produces exactly the same result as the previous illustration.