1

I included a MWE (a main file and three articles) that uses the combine class with book option. There are two problems. The formatting process creates the LaTeX Error: Environment abstract undefined, and formatting stops at the first \begin{abstract} command in first input file. Press “r” to continue the formatting process. The resulting PDF is almost correct except for the section numbering (0.1, 0.2 … instead of 1, 2 …) in the input article documents. The article documents include the command \setcounter{section}{0} in the preamble. The file formats if I replace book with report, but the section-numbering problem persists. The main document is an accurate example of what I need (A book with parts, several chapters with no input files, and several chapters with input files.) All input files use the article document class. I use MiKTeX 2.9 on Windows 7.

\documentclass[book]{combine}
\usepackage[english]{babel}
\usepackage{blindtext}
\title{The collection}
\author{A. N. Editor}
\begin{document}
\maketitle
\tableofcontents
\part{First part}
\blindtext[1]
\chapter{First chapter}
\section{Introduction}
\blindtext[1]
\chapter{Second chapter}
\section{Introduction}
\ldots
\begin{papers}
    \coltoctitle{First article}
    \coltocauthor{Author of first article}
    \import{inputDoc1}
    \coltoctitle{Second article}
    \coltocauthor{Author of second article}
    \import{inputDoc2}
\end{papers}
\chapter{Third chapter}
\section{Introduction}
\ldots
\begin{papers}
    \coltoctitle{Third article}
    \coltocauthor{Author of third article}
    \import{inputDoc3}    
\end{papers}
\chapter{Chapter 4}
\section{Final introduction}
\end{document} 
%first article
\documentclass[]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\title{First article}
\author{Author of first article}
\maketitle
\begin{abstract}
    \blindtext[2]
\end{abstract}
\section{first section}
\blindtext[3]
\end{document}
%second article
\documentclass[]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\setcounter{section}{0}
\begin{document}
\title{Second article}
\author{Author of second article}
\maketitle
\begin{abstract}
    \blindtext[1]
\end{abstract}
\section{first section}
\blindtext[1]
\end{document}
%third article
\documentclass[]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\setcounter{section}{0}
\begin{document}
\title{Document 1a}
\author{Author of document 1a}
\maketitle
\begin{abstract}
    \blindtext[3]
\end{abstract}
\section{first section}
\blindtext[1]
\section{second section}
\blindtext[1]
\end{document}
  • Please, see How to construct a collection of articles with LaTeX available at pastcounts.wordpress.com/2010/12/20/… – user13907 Apr 28 '13 at 0:25
  • You need to define the environment abstract and additionally define acknowledgments. See here tex.stackexchange.com/questions/51483/… – cacamailg Apr 28 '13 at 0:51
  • Papiro: I read article on pastcounts a few days ago, but I was not able to get the code given there to work with the sample I posted on this forum. I am sure the fault is mine. Thanks for your response. – Tom Price Apr 28 '13 at 2:14
  • cacamailg: I defined an abstract environment but I do not understand why combine does not format input articles as articles. (As I recall, the abstract environment works if I use the report option.) I also do not understand why I need to reset the section counter every time I input an article. The section numbering problem also persists. Thank you for your advice. – Tom Price Apr 28 '13 at 2:20
  • @TomPrice BTW, there is another approach: tex.stackexchange.com/questions/54737/… – user13907 Apr 28 '13 at 10:58
3
+50

Since you only import articles, and the article document class doesn't define the \chapter the result is that you will have a value of 0 for the chapters of each imported article. As @Papiro pointed, you can avoid the display of chapter counter with \renewcommand*\thesection{\arabic{section}}. However, with that, you lose the format \thechapter.\thesection for the sections in the main document, which in my case would be fine.

Below I present other solution that keeps the format \thechapter.\thesection (without the need to add to add \makeatletter \@ifclassloaded{combine}{\renewcommand*\thesection{\arabic{savechapter}.\arabic{section}}}{}\makeatother at each input articles).

\documentclass[book]{combine}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{filecontents}
\usepackage{etoolbox}
\newcounter{savechapter}
\AtBeginEnvironment{papers}{\setcounter{savechapter}{\value{chapter}}}
\makeatletter
\let\oldimport\import
\renewcommand*{\import}{\renewcommand*\thesection{\arabic{savechapter}.\arabic{section}}\oldimport}
\makeatother

% The input articles
\begin{filecontents*}{inputDoc1.tex}
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\title{First article}
\author{Author of first article}
\maketitle
\begin{abstract}
\blindtext[2]
\end{abstract}
\section{first section}
\blindtext[3]
\section{Second section}
\end{document}
\end{filecontents*}

\begin{filecontents*}{inputDoc2.tex}
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\title{Second article}
\author{Author of second article}
\maketitle
\begin{abstract}
\blindtext[1]
\end{abstract}
\section{first section}
\blindtext[1]
\end{document}
\end{filecontents*}

\begin{filecontents*}{inputDoc3.tex}
\makeatother
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\setcounter{section}{1}
\begin{document}
\title{Document 1a}
\author{Author of document 1a}
\maketitle
\begin{abstract}
\blindtext[3]
\end{abstract}
\section{first section}
\blindtext[1]
\section{second section}
\blindtext[1]
\end{document}
\end{filecontents*}

% Define abstract to be used in book class (or use report)
% http://tex.stackexchange.com/questions/51483/how-to-write-abstract-and-acknowledgement-in-book-format
\makeatletter
\if@titlepage
  \newenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}
\else
  \newenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        \end{center}%
        \quotation
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi
\makeatother


% The main document
\begin{document}
\title{The collection}
\author{A. N. Editor}
\date{\today}
\maketitle

\begin{abstract}
\blindtext[1]
\end{abstract}

\tableofcontents

\part{First part}
\blindtext[1]

\chapter{First chapter}
\section{Introduction}
\blindtext[1]

\chapter{Second chapter}
\section{Introduction}
\ldots
\begin{papers}
    \coltoctitle{First article}
    \coltocauthor{Author of first article}
    \import{inputDoc1}
    \coltoctitle{Second article}
    \coltocauthor{Author of second article}
    \import{inputDoc2}
\end{papers}

\chapter{Third chapter}
\section{Introduction}
\ldots
\begin{papers}
    \coltoctitle{Third article}
    \coltocauthor{Author of third article}
    \import{inputDoc3}    
\end{papers}

\chapter{Chapter 4}
\section{Final introduction}

\end{document}
  • cacamailg: Thanks for your post. Two problems remain with the section numbering. The first section of an article is not numbered 1., and so on. Sections in the chapters no longer have the chapter number (3.4) for example. The combine package is supposed to typeset abstracts in articles without defining an abstract environment in the main document. However, your fix works well. – Tom Price Apr 29 '13 at 0:21
  • If you like my answer, please upvote it. – cacamailg Apr 29 '13 at 2:08
  • Your code is close to a solution. However, when I add the code \makeatletter \@ifclassloaded{combine}{\renewcommand*\thesection{\arabic{savechapter}.\arabic{section}}}{}\makeatother I get the error Missing number, treated as zero... when the formatting process encounters the first section of an article. – Tom Price Apr 29 '13 at 10:45
  • @TomPrice I updated my solution. The code works fine in my computer. I use the latest TeXLive 2012. Try to remove all *.aux *.log *.toc (etc.) files. – cacamailg Apr 29 '13 at 12:18
  • Your updated solution almost worked. The section numbers in the articles did not begin with "1" and they included the chapter number, for example, "2.3". I changed the additional preamble code to \usepackage{etoolbox} \newcounter{savechapter} \AtBeginEnvironment{papers}{\setcounter{savechapter}{\value{chapter}}} \makeatletter \let\oldimport\import \renewcommand*{\import}{\setcounter{section}{0}\renewcommand*\thesection{\arabic{section}} \oldimport} \makeatother which seems to work. Do you see any problem with this? I appreciate your help. Are you on LinkedIn? – Tom Price Apr 29 '13 at 12:53

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.