3

I would like to have my "Problem Description" to have the same look/layout as abstract. Any way I can "clone" the the abstract command?

preamble:

\documentclass[pdftex,10pt,b5paper,twoside]{report}
\usepackage[lmargin=25mm,rmargin=25mm,tmargin=27mm,bmargin=30mm]{geometry}
2
  • 1
    don't use explicitly the pdftex option; the packages needing it are usually able to provide it implicitly.
    – egreg
    Commented Jun 14, 2011 at 12:48
  • @egreg Ok, uni. template..
    – latexmp
    Commented Jun 14, 2011 at 12:56

2 Answers 2

6
\newenvironment{problemdesc}
  {\renewcommand{\abstractname}{Problem Description}%
   \begin{abstract}}
  {\end{abstract}}

In this way you can also use the normal abstract environment.

If many kinds of this generalized abstract environment are needed, one can do the following

\newenvironment{genabstract}[1][]
  {\ifx\relax\detokenize{#1}\relax
     % no optional argument
   \else
     % provide the desired title
     \renewcommand{\abstractname}{#1}%
   \fi
   \begin{abstract}}
  {\end{abstract}}

The calls can then be

\begin{genabstract}
<regular abstract>
\end{genabstract}

\begin{genabstract}[Problem Description]
<problem description>
\end{genabstract}

Don't feed \abstractname as the optional argument, as this would cause infinite recursion (it would be possible to avoid this, but it seems overkill).

5
  • Even better would be to put \renewvommand{\abstractname}{Abstract} in the endcode I think? Or is there reason this would not work?
    – romeovs
    Commented Jun 14, 2011 at 13:21
  • 1
    @romeovs: every environment forms a group, so that \renewcommand would have no effect, because the "end part" is evaluated before the group ends.
    – egreg
    Commented Jun 14, 2011 at 13:27
  • hmm, okay don't know about groups. Just seemed logical to change it back. You mean that it will only be changed inside the group then?
    – romeovs
    Commented Jun 14, 2011 at 14:01
  • 2
    @romeovs: the redefinition of \abstractname in the "begin part" will be undone anyway when the environment ends, because it's made inside a group.
    – egreg
    Commented Jun 14, 2011 at 14:04
  • okay, all I needed to know!
    – romeovs
    Commented Jun 14, 2011 at 15:09
2
\documentclass[english]{report}
\usepackage{babel,blindtext}
\begin{document}

{\renewcommand\abstractname{Problem Description}%
\begin{abstract}
\blindtext
\end{abstract}%
}

\begin{abstract}
\blindtext
\end{abstract}%

\blindtext
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .