1

I am working on creating a thesis template for myself and others in my lab to use. I have gotten stuck on creating a specialized abstract environment however. As a MWE (well minimum broken example) I have the following as a 'sample.cls' file

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sample}[2016/01/29 Sample]


\DeclareOption*{
    \ClassWarning{sample}{No options permitted}
}

\ProcessOptions\relax
\LoadClass{report}

\newenvironment{abstractpage}{
    {
    \begin{center}
        %set the default font style to bold face extended for the abstract page
        \fontseries{bx}
        \selectfont
        \Large ABSTRACT \\
        \hfill \\
        \large \@title\\
        \hfill \\
        \normalsize \@author
    \end{center}
    \vfill
    \quotation\noindent
    }
    {
    \endquotation
    \vfill
    }
}

and

\documentclass{sample}
\usepackage{lipsum}

\begin{document}
\author{Andrew}
\title{Hello World}
\begin{abstractpage}
    \lipsum[1]
\end{abstractpage}

\end{document}

as a '.tex' file. I then tried to compile the tex file using pdflatex

When I try to compile I get

runawayargument?
! file ended while scanning use of \@newenv.

and I cannot for the life of me figure out why. I've check all of the brackets and I took this idea from the default abstract class itself (according to Define abstract environment in book)

Can anyone see anything wrong with this?

  • You have a faulty definiton of the environment. Does your editor have brace-matching? Check where the environment starts, and where you closing is happening. Unrelated: If that should always be on its own page, use clearpage when starting and ending. – Johannes_B Jan 29 '16 at 21:26
  • agree with @Johannes_B, but a different bias. \newenvironment` requires two arguments beside the environment name. you have braces enclosing both of what looks like you intend to be the two required arguments, with the result that there's only one found by latex. – barbara beeton Jan 29 '16 at 21:29
4

You have some errors in your code: unmatched braces are the main one.

Secondly, \hfill\\ is a don't-do-it; after \noindent you need \ignorespaces. And finally you have a load of unprotected end-of-lines, which may be irrelevant in this particular case, but it's good habit to have the correct % everywhere.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sample}[2016/01/29 Sample]

\DeclareOption*{%
    \ClassWarning{sample}{No options permitted}%
}

\ProcessOptions\relax
\LoadClass{report}

\newenvironment{abstractpage}
 {%
  \begin{center}
  %set the default font style to bold face extended for the abstract page
  \bfseries
  {\Large \MakeUppercase{\abstractname} \\[\bigskipamount]}
  {\large \@title\\[\bigskipamount]}
  \@author
  \end{center}
  \vfill
  \quotation\noindent\ignorespaces
 }
 {%
  \endquotation
  \vfill
 }

Don't say \fontseries{bx}\selectfont; \bfseries is preferable, because it's not necessary that a font family defines the bx series.

It's also better to use \abstractname, rather than hardwiring “ABSTRACT”.

In the test document I used \lipsum[1-2] so as to show the indent in the second paragraph.

enter image description here

  • @Johannes_B Yes, I selected the wrong image! – egreg Jan 29 '16 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.