Difference between revisions of "Article Abstracts"

From Wiki
Jump to navigation Jump to search
(A rough sketch; this is far from complete. I'll work on it later.)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
< [[From LaTeX to ConTeXt]] | [[Document Titles]] >
 
< [[From LaTeX to ConTeXt]] | [[Document Titles]] >
 
Note: 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!
 
 
{{Explanation}}
 
 
  
 
== LaTeX ==
 
== LaTeX ==
  
Much as with [[Document Titles]], the standard LaTeX document classes define an <code>\abstract</code> command to typeset an abstract in a way that distinguishes it from the rest of the text.
+
Much as with [[Document Titles]], the standard LaTeX article and report classes define an <code>abstract</code> 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.
  
 
<texcode>
 
<texcode>
% Note: this is the old Document Title example, as filler.
 
 
 
\documentclass{article}
 
\documentclass{article}
  \title{How to do this in Context}
 
  \author{The author}
 
  \date{July 26, 2005}
 
 
\begin{document}
 
\begin{document}
   \maketitle
+
   \begin{abstract}
 +
    This is the abstract of the paper.
 +
  \end{abstract}
 
\end{document}
 
\end{document}
 
</texcode>
 
</texcode>
Line 24: Line 16:
 
== ConTeXt: A simple solution ==
 
== ConTeXt: A simple solution ==
  
The simplest way of producing an abstract in a ConTeXt document is to specify the formatting directly.  The following version is a close approximation of the version produced by the <code>\abstract</code> command in LaTeX's startard article class.
+
The simplest way of producing an abstract in a ConTeXt document is to specify the formatting directly.  The code from LaTeX's <code>classes.dtx</code> is nearly trivial, and is quite easy to replicate in ConTeXt idioms.
  
 
<texcode>
 
<texcode>
% Again, this is filler from the Document Titles page.
+
\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
 +
</texcode>
 +
 +
<context>
 
\starttext
 
\starttext
\startalignment[center]
+
\midaligned{\bf Abstract}
  \blank[2*big]
+
\startnarrower[2*middle]
    {\tfd How to do this in Context}
+
This is the document's abstract.  It contains enough text for two lines, but no more.
  \blank[3*medium]
+
\stopnarrower
    {\tfa The author}
+
\blank[big]
  \blank[2*medium]
 
    {\tfa July 26, 2005}
 
  \blank[3*medium]
 
\stopalignment
 
  
Then, the actual text of the document starts hereWe'll put in enough text to
+
This is the main text of the document.  Like the abstract, it contains enough text
fill out the line and start to make a paragraph.
+
for two lines, to show the margins.
 
\stoptext
 
\stoptext
 +
</context>
 +
 +
In the two-column document classes, LaTeX's <code>abstract</code> environment does nothing beyond putting a <code>\section*{Abstract}</code> in front of the abstract's text.  This can be easily replicated in ConTeXt with <code>\subject{Abstract}</code>.  (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. 
 +
The low-level Context command <cmd>definestartstop</cmd> defines a pair of
 +
<cmd>start</cmd> - <cmd>stop</cmd> commands, so we can define an
 +
<code>abstract</code> environment using the following commands:
 +
 +
<texcode>
 +
\definestartstop
 +
  [abstract]
 +
  [before={\midaligned{\bf Abstract}
 +
          \startnarrower[2*middle]},
 +
  after={\stopnarrower
 +
          \blank[big]}]
 
</texcode>
 
</texcode>
  
 +
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 <cmd>if</cmd> 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.
 +
 +
<texcode>
 +
\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
 +
</texcode>
  
== ConTeXt: A more reusable solution ==
+
This, of course, produces exactly the same result as the previous illustration.
  
(The formatting can be placed in a module, etc., etc.)
+
[[Category:From LaTeX]]

Revision as of 18:35, 12 February 2006

< 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. The low-level Context command \definestartstop defines a pair of \start - \stop commands, so we can define an abstract environment using the following commands:

\definestartstop
  [abstract]
  [before={\midaligned{\bf Abstract}
           \startnarrower[2*middle]},
   after={\stopnarrower
          \blank[big]}]

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.