[Tex/LaTex] Trying to create simple template for novice users

documentclass-writingtemplates

I am trying to create a simple template for students to create a one page abstract. The idea is that they just define their title, author, and abstract, and another file could actually have the main code that uses them. For example:

\title{A Very Simple \LaTeXe{} Template}
\author{author1 \and author2}
\abstract{
Long, drawn out abstract, blah, blah, blah.

}
\captionedimage {myimage.pdf}{caption text}
\captionedimage {myimage2.pdf}{caption text2}

In the second file would be the main document, including the first. Although I have never done anything like this, obviously if I want a new style the thing to do is write a new .sty and .cls file for the new style I want. Hypothetically, the main document could look like this ( I am using C preprocessor includes to illustrate what I'm going for)

#include "individualpage.tex"
\documentclass[12pt]{simpleabstract}

\begin{document}
\maketitle  %% Insert a bold title font at the top of the page

%% insert the abstract defined by the student here

%% if there is an image, insert it here

\end{document}

The first question is whether anything like this exists already, since I would rather not reinvent the wheel. I searched for templates for abstracts, but didn't even find a simple example of just a page I want, let alone a setup that would allow me to generate this page, and then alternately put many of them together. It's work, but I know I could mutate a document class to make the page look I want. However, before I try I would like to know that there isn't something that already exists to do this. Here is what I want the one page to look like:

enter image description here

The second question is how to automate taking two hundred of these and creating a single document of them. That would presumably take a different document style, one that has a title page, some introductory text, then a table of contents selected from the title of each abstract, and the abstract pages. It is primarily for this reason that I would rather not have the individual students embed the latex code that defines the document, but would rather have that in a separate file. If they embed their document style in a page, then to build the larger document I must wrap that in a larger document.

I have tried to illustrate what I want to achieve using the C++ preprocessor to hook files together, and of course one way of implementing this is to use perl or some other text processing language to process these files in some way. But perhaps in my ignorance of LaTeX, I'm not aware that some facility like that already exists, hence this question: is there some standardized way to achieve this or will it require custom programming on my part?

Best Answer

Here's the framework for an answer, based on @Ignasi's suggestion. Documentation for the combine package (http://tug.ctan.org/tex-archive/macros/latex/contrib/combine/combine.pdf) will help you play with formatting, make the toc work, even generate an index and a table of figures.

The student gets two files, preamble.tex (read only if possible) and template.tex. She fills in the template, compiles it and submits it with a new name along with her image files (you have to establish the naming conventions).

The preamble:

% preamble.tex
% provided to students, read only
\documentclass[12pt,notitlepage]{article}
\usepackage{graphicx}

\newcommand{\theschool}{to be renewed}
\newcommand{\school}[1]{%
   \renewcommand{\theschool}{#1}
}
\newcommand{\theteacher}{to be renewed}
\newcommand{\teacher}[1]{%
   \renewcommand{\theteacher}{#1}
}

% hack the \date field of \maketitle
\date{School: \theschool{} -- Teacher: \theteacher{}} 

\newcommand{\myfigure}[2]{%
\centering
\includegraphics[height=3cm]{#1}\\
Caption: #2
}
\begin{document}
\newcommand{\alldone}{\end{document}}

template.tex, saved as plato.tex:

% template for students to fill in
% 
\input{preamble}
\author{Plato}
\title{The Republic}
\school{Athens}
\teacher{Socrates}
\maketitle
\begin{abstract}
   \emph{The Republic} in one short paragraph \ldots
\end{abstract}
% first argument is image (.jpg, .png, .pdf)
% second argument is figure caption
\myfigure{therepublic}{Image from wikipedia}
\alldone

Compiles to

enter image description here

The wrapper is putittogether.tex, in the directory with student submissions and an empty preamble.tex. I compiled and tested it with a second saved template - code not included here.

% putittogether.tex
\documentclass[12pt]{combine}

% macros from the preamble seen by the students
\usepackage{graphicx}
\newcommand{\theschool}{to be renewed}
\newcommand{\school}[1]{%
   \renewcommand{\theschool}{#1}
}
\newcommand{\theteacher}{to be renewed}
\newcommand{\teacher}[1]{%
   \renewcommand{\theteacher}{#1}
}
\newcommand{\hackdate}{%
  \date{School: \theschool{} -- Teacher: \theteacher{}} 
}
\newcommand{\myfigure}[2]{%
\centering
\includegraphics[height=3cm]{#1}\\
Caption: #2
}
% The \date must be renewed between \imports
\newcommand{\goget}[1]{%
  \hackdate{}\import{#1}
}
\newcommand{\alldone}{} % do nothing

% Combine package configuration
\title{All Together Now}
\author{many authors}
\date{\today}

\begin{document}
\pagestyle{combine} % use the combine page style
\maketitle % main title
\tableofcontents % main ToC
\clearpage

% The files to glue together - all in this directory,
% along with all graphics files required.
%
% Generate this list with a script, then \include it here.

\goget{plato}
\goget{vonneumann}

\end{document}
Related Question