4

I would like to create an acknowledgments environment that's simply the duplicate of the abstract environment, with two exceptions:

  1. It should print Acknowledgments as its heading, not Abstract.

  2. The acknowledgments environment should end with \clearpage.

The answer to Duplicating Environments shows me how to duplicate an environment, but what do I need to do to accomplish the two points above?

\documentclass{article}
\usepackage{filecontents,lipsum}
\begin{filecontents}{mystyle.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mystyle}
\let\acknowledgments\abstract
\let\endacknowledgments\endabstract
\endinput
\end{filecontents}
\usepackage{mystyle}

\begin{document}
\begin{abstract}
\lipsum[1]
\end{abstract}
\begin{acknowledgments}
\lipsum[1]
\end{acknowledgments}
\end{document}
8

It seems easier to define the acknowledgments environment as an "abstract wrapper" using the following:

enter image description here

\documentclass{article}
\usepackage{filecontents,lipsum}
\begin{filecontents*}{mystyle.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mystyle}
\newenvironment{acknowledgments}
  {\renewcommand{\abstractname}{Acknowledgments}% Abstract > Acknowledgements
   \begin{abstract}}
  {\end{abstract}
   \clearpage}
\endinput
\end{filecontents*}
\usepackage{mystyle}

\begin{document}
\begin{acknowledgments}
\lipsum[1]
\end{acknowledgments}
\begin{abstract}
\lipsum[1]
\end{abstract}
\end{document}

The name redefinition to Acknowledgments is temporary within the environment group.

| improve this answer | |
  • why appears warning message: Overwriting file './mystyle.sty'.? and how it could be solved? – juanuni Jun 25 '18 at 17:54
  • @juanuni: When you load the filecontents package it allows one to overwrite mystyle.sty with every compilation if you use \begin{filecontents*}{mystyle.sty} ... \end{filecontents*}. Without the filecontents package, the file won't be overwritten if it's already in the working folder. – Werner Jun 25 '18 at 18:10

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.