[Tex/LaTex] Difference between using `\abstract` and the `abstract` environment

abstract

So I've seen there's an \abstract{...} command (through TeXlipse's suggestions), however most examples I find online use an environment structure like this:

\begin{abstract}
something like \lipsum or \blindtext
\end{abstract}

Since I would assume \abstract{...} functions like \section{...}, that got me wondering. Is there any difference between these two options? In particular, is there any advantage or disadvantage of using one over the other?

Best Answer

Simplifying, \begin{foo} does four things:

  1. check that the environment foo (more exactly the macro \foo) exists;
  2. open a group (\begingroup);
  3. set the name of the current environment (\@currenvir) to foo;
  4. execute \foo (actually \csname foo\endcsname).

Similarly, \end{foo} does

  1. execute \endfoo (more exactly \csname endfoo\endcsname);
  2. check that the environment being closed is the same one which was opened before (by comparing foo with the previously saved \@currenvir);
  3. close the group (\endgroup).

The standard classes, the KoMa classes, and memoir all define abstract as environment. In this case, just calling \abstract{...} (I tested only with article) gives no errors but the result will be puzzling: with the article class the font size and the margins are reduced, and without \end{abstract} this extends to the following text. This happens because the steps 1 to 3 are skipped, in particular \begingroup; and since there is no \end{abstract} the group (which was never opened) won't be closed, and whatever font and/or margin and/or whatever changes \abstract does won't be limited to the abstract.

There are classes (mostly journals, I guess; I can mention webofc.cls and PoS.cls, because I had to use them) which define \abstract as a macro taking one argument. Writing

\begin{abstract}
Some text.
\end{abstract}

will often also produce no errors, but again the result won't be the intended output: only the letter S will be taken as argument of \abstract (whatever it does), the rest ("ome text.") will be typeset somehow, and \end{abstract} will probably raise no error, because even if \endabstract hasn't been defined, the construction \csname...\endcsname will expand to \relax.

So back to your question:

In particular, is there any advantage or disadvantage of using one over the other?

The bottom line is: it has nothing to do with advantage or disadvantage: You must use \begin{abstract}...\end{abstract} if the class defines the abstract as environment, and \abstract{...} if the class defines the abstract as macro.