Document ClassesCreate Book from a Collection of Articles

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Margret Cuen
Posts: 1
Joined: Sat Feb 26, 2011 10:11 pm

Create Book from a Collection of Articles

Post by Margret Cuen »

Hello everyone,

I have been looking for a way to produce books with a collection of articles of different authors. The combine class somewhat satisfies that need. I also found a somewhat simpler solution online (or see the code below) that redefines some commands. However, I can't get it to work, LaTeX throws "command already defined" errors, e.g. for title.

Anyone around here that spots the error and can make this work? It seems rather trivial, but I'm too fresh to LaTeX to make it work myself.

This is very simple to use. It creates a new environment papers that can be used to enter the individual papers. I have assumed that each paper is included as an individual document; this means, that each paper can have its own preamble, and each paper can be edited individually. To include the papers in the main document, use it like this.

Code: Select all

\begin{papers}
\include{paper1}
\include{paper2}
\end{papers}
Where each of the papers is of the form:

Code: Select all

\documentclass[
% class options
]{article}  % or whatever
\usepackage{necessary}
\usepackage{cool}

\begin{document}
\title{A paper of the best practices}
\author{Johnny B. Good}
\maketitle
\section{Introduction}
In this paper \ldots
\end{document}
Note that the preamble of the included documents should be kept as simple as possible, as for example redefinitions of commands are not ignored and so on. If the included documents need any special packages, they have to be included in the preamble of the main document.

The code below redefines some preamble commands and the document environment to be ignored, and the \maketitle command so that the titles of the paper are printed and added to the table of contents and to the marks for headers. How they are used is a matter of your page style.

Code: Select all

% This code includes small pieces from combine.cls and some other sources.
% No guarantees of any kind given. Use at your own discretion.
% Feel free to modify and distribute in any way you see fit.

\long\def\symbolfootnote[#1]#2{\begingroup%
\def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup}

\makeatletter
\newenvironment{papers}{\renewcommand{\documentclass}[2][]{}%
\newcommand{\@@title}{}%
\newcommand{\@@subtitle}{}%

\renewcommand{\usepackage}[2][]{}%
\renewenvironment{document}{\begingroup}{\endgroup}%

\newcommand{\title}[1]{\renewcommand{\@title}{##1}\begingroup%
\renewcommand{\thanks}[1]{}\protected@xdef\@@title{##1}
  \endgroup}
\renewcommand{\subtitle}[1]{\renewcommand{\@@subtitle}{##1}}%
\newcommand{\author}[1]{\renewcommand{\@author}{##1}}
\newcommand{\thanks}[1]{\symbolfootnote[1]{##1}}
\newcommand{\maketitle}{
  \thispagestyle{empty}
  \vspace*{5\baselineskip}
  \begin{center}\sf
    \LARGE\@title%
    \ifthenelse{\equal{\@@subtitle}{}}{%emtpy subtitle
}{%not empty subtitle

\bigskip
\Large\@@subtitle
}

\bigskip
    \large\@author%
\end{center}%
\markboth{\@@title}{\@author}%
\addcontentsline{toc}{chapter}{\MakeUppercase{\@author}\\\@@title}%
\setcounter{footnote}{0}\noindent%
\ignorespacesafterend}
}{
}
Thanks, Margret.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

kiprono2005
Posts: 1
Joined: Thu Nov 07, 2013 4:23 pm

Re: Create Book from a Collection of Articles

Post by kiprono2005 »

Dear Margret,

Did you find a solution to your post? I am in the same situation. Or how else can I combine standalone documents to form a thesis?

Regards

Kiprono
rohitvk
Posts: 1
Joined: Sun Feb 23, 2014 5:50 pm

Re: Create Book from a Collection of Articles

Post by rohitvk »

Hello All:

I have been using LaTeX for a long time now. But I am facing the same problem.

I am creating a government document report in which various chapters have been contributed by various authors. I would like to have the author name printed below the chapter titles. Using \paragraph{authorname} or \textbf{authorname} does injustice to the elegance of the layout.

Any solutions anyone

TIA

rohitvk
Post Reply