Automatic document update

A related problem might be separating the formatting and content of the syllabus, which could make it easier to generate as many of these syllabi as needed. It would definitely make any scripting much more robust, since you'd be generating only a simple .sty file instead of modifying a full .tex document. Sample result (close to what you had posted):

enter image description here

built from a customized document class, a course-specific style file, and an instructor-specific style file. In theory, this could be used to generate syllabi for an entire department with appropriate scripting. The class file also replaces some of the repeated formatting commands you had (\noindent and other things for paragraphs) with default section formatting and similar items.

.tex file for a specific syllabus:

\documentclass{pp-syllabus}
\usepackage{csci3030-a} % for course-specific information
\usepackage{pp} % for instructor-specific information
% Items specific to this particular course and section, for this term
\newcommand{\courseterm}{Spring 2011}
\newcommand{\coursetime}{MW 4:00 PM--5:15 PM}
\newcommand{\courseroom}{Allgood Hall E364}
\begin{document}
\courseheader{}
\section*{Office Hours} \instructorhours{}.
\section*{Text(s)} \coursetexts{}
\end{document}

Course style file (csci3010-a.sty):

% Items common to a course or section, things that don't change on a
% semester-by-semester basis. Use as little formatting as possible,
% since this file might be used in several different styles of
% syllabi.
\newcommand{\coursename}{CSC 3030}
\newcommand{\sectionname}{A}
\newcommand{\coursetitle}{Mathematical Structures for Computer Science}
\newcommand{\coursedescription}{
The course prepares Computer Science majors for advanced study by
emphasizing components of Discrete Mathematics related to Computer
Science. The topics include sets, functions and relations, logic,
Boolean algebra, graph theory, proof techniques, and matrices. Examples
will emphasize Computer Science applications.
}
\newcommand{\coursecredit}{3}
\newcommand{\coursetexts}{
\textit{A Short Course in Discrete Mathematics} and
\textit{Mathematics for Algorithm and Systems Analysis},
by Edward A. Bender \& S. Gill Williamson, Dover Publications 2005.
}

Instructor style file (pp.sty):

% Items specific to a particular instructor
\newcommand{\instructor}{Dr. Predrag Puno\v sevac}
\newcommand{\instructoroffice}{Allgood Hall N334}
\newcommand{\instructorphone}{(706) 667-4481}
\newcommand{\instructoremail}{\href{mailto:[email protected]}{[email protected]}}
\newcommand{\instructorhours}{MW 2:30 PM--4:00 PM, T 3:30 PM--4:30 PM, or by appointment}

Class file (pp-syllabus.cls):

% Items common to a particular visual style of syllabus -- in theory, can be
% used for all syllabi in a particular department.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{pp-syllabus}[2012/01/19 v0.1 Modified article class for syllabi]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
\RequirePackage{enumitem}
\setlist{noitemsep}
\RequirePackage{multicol}
% Two-column lists (itemize, description, etc.)
\SetEnumitemKey{twocol}{
itemsep=1\itemsep,
parsep=1\parsep,
before=\raggedcolumns\begin{multicols}{2},
after=\end{multicols}}

\RequirePackage{amsmath}
\RequirePackage{booktabs}
\RequirePackage{multirow}

\RequirePackage[margin=1in]{geometry}

\RequirePackage{titlesec}
% titlesec documentation, section 3.1
\titleformat{\section}[runin]{\normalfont\bfseries}{}{.5em}{}[:]

\RequirePackage{hyperref}

\newcommand{\courseheader}{
\begin{center}
{\Large \textbf{Syllabus for \coursename{} {\tiny Section \sectionname{}}}}

{\large \textbf{\coursetitle{}}}
\end{center}

\begin{description}[twocol,leftmargin=1.1in,style=nextline]
\item[Term:] \courseterm{}
\item[Time:] \coursetime{}
\item[Room:] \courseroom{}
\item[Credit Hours:] \coursecredit{}
\item[Instructor:] \instructor{}
\item[Office:] \instructoroffice{}
\item[Phone:] \instructorphone{}
\item[E-mail:] \instructoremail{}
\end{description}
}

In ConTeXt, the standard way to specify such information is to use \setvariables and then access them using \getvariables. For example, for my course notes I often use

\setvariables
    [course]
    [title={Name of the Course}, 
     number={Course Number},
     term={Winter 2012},
     location={Room No...},
     time={Tuesdays and Thursdays, ...},
    ]

and then use \getvariable{course}{title} etc at appropriate places to retrieve the values.

You can use LuaTeX to get this information automatically from your universities webpage, parse it, and write the set variables command to TeX. Since I don't know the format in which the information is stored on your univ's webpage, I can't offer a complete solution. In ConTeXt, you can simply use

\input <url of page>

to include a file on the internet in your document. ConTeXt takes care of downloading and caching the file. (For an interesting usage, see this example) You can wrap this around a lpeg parser to parse the results.


News: The further development of Syllabus-Generator is moved to GitHub. If you would like a write access please send me an e-mail.

After contemplating to start learning ConTeXt in part due to this beautiful answer by Aditya I decided against it due to several reasons.

So going back to my original answer and phenomenal answer I got from Mike Renfro I decided to realize his idea of automatically generating Syllabi for all courses taught by our department in a particular semester. I am reporting here on the progress I made so far. Lets look at for example Syllabus for Math 1111 section c3 which I taught this Spring.

enter image description here enter image description here

From the original source file I was able to separate several style files and reproduce the original document using those custom style files:

instructor.sty with instructor specific information.

% Items specific to a particular instructor
\newcommand{\instructor}{Dr. Predrag Puno\v sevac}
\newcommand{\instructoroffice}{Allgood Hall N334}
\newcommand{\instructorphone}{(706) 667-4481}
\newcommand{\instructoremail}{\href{mailto:[email protected]}{\url{[email protected]
du}}}
\newcommand{\instructorofficehours}{MW 2:30 PM--4:00 PM, T 3:30 PM--4:30
PM, or by appointment}

As you can see the only information which requires term update is the office hours info.

math1111.sty with course specific info which do not change on semester-by-semester basis and its is common to all sections

% Items common to a course, things that don't change on a
% semester-by-semester basis. Use as little formatting as possible,
% since this file might be used in several different styles of syllabi.
\newcommand{\coursenumber}{MATH 1111}
\newcommand{\coursetitle}{College Algebra}
\newcommand{\coursecredit}{3}
\newcommand{\coursedescription}{
A symbolically intensive functional approach to algebra that
incorporates the use of appropriate technology. Emphasis will be placed
on the study of functions and their graphs, inequalities, and linear,
quadratic, piece-wise defined, rational, polynomial, exponential, and
logarithmic functions. Appropriate applications will be included.
}
\newcommand{\coursetexts}{
 \begingroup
  \renewcommand
  \section[5]
  {\par\vspace{-0.1cm}}
  \bibliographystyle{amsplain}
  \bibliography{math1111}
  \nocite{*}
\endgroup
}
\newcommand{\courseprerequisites}{
Placement or the successful completion of MATH 0099.
}
\newcommand{\coursedisclaimer}{
Credit will not be given for both MATH 1101 and MATH 1111.
}
\newcommand{\courseoutline}{
We will be covering Sections: R.2, R.4, R.5, R.7, R.8, 1.1-1.7, 2.1-2.3,
2.5, 3.1, 3.2, 3.4, 4.1, 4.3, 4.5, 5.4, 6.1-6.7, and 8.1.
}
\newcommand{\courseexams}{
There will be three 50 points in-class exams. The exams are scheduled
for \examone, \examtwo, and \examthree.
}
\newcommand{\coursehomework}{
will be submitted through a LMS called MyMathLab. MyMathLab is Learning
Management System (LMS) that can be accessed at
\href{http://www.coursecompass.com/}{\url{http://www.coursecompass.com}}.
To register for MyMathLab, you will need a Course ID (\courseid) and an
access code. Access code can be purchased on-line at
\href{http://www.coursecompass.com/}
{\url{http://www.coursecompass.com/}} or through the Augusta State
University Bookstore. Deadlines and point values for each assignment
will be posted in your class account when you login. A final
homework/quizzes score based on 50 possible points will be assigned.
}
\newcommand{\coursefinalexam}{
The final exam is a \underline{\bf comprehensive common departmental}
exam worth 110 points. It is scheduled for \finalinfo.  Room assignments
for the final examination will be announced later during the semester.
The University's final exam regulations will be strictly followed.
}
\newcommand{\coursegrades}{
The total number of points available in the course is 320. In order to
receive a passing grade in MATH 1111, you must satisfy both of the
following conditions:
        \begin{enumerate}
        \item You must have a total number of points of at least 192.
        \item You must respond correctly to at least nine out of the 30
        final exam items. Nine correct problems on the final exam
        correspond to 40 points for the final exam.
        \end{enumerate}
If you \underline{\bf do score at least 40 points} on the final exam,
the letter grades for the course will be no lower than those set forth
in the following table

\begin{center}
\begin{tabular}{|l| l| l|}
\hline
288-320 & 90\% to 100\% & A\\
\hline
256-287 & 80\% to 89.7\% & B\\
\hline
224-255 & 70\% to 79.7\% & C\\
\hline
192-223 & 60\% to 69.7\% & D\\
\hline
\ \ \ 0-191 & \ \ \ \ \ \ \ $<$ 60\% & F\\
\hline
\end{tabular}
\end{center}
}

math1111.bib file which contains textbook info

@book{0321716817,
    Author = {Michael Sullivan},
    Title = {College Algebra (9th Edition)},
    Publisher = {Addison Wesley},
    Year = {2011},
    ISBN = {0321716817},
}

spring2012.sty file which contains term specific info common to all courses that we teach and which needs to be updated once every semester

% Term specific information for all courses
\newcommand{\catalog}{
\href{http://www.aug.edu/faculty_secretary/catalog/2011/ASU_catalog_2011
-2012_web_version.pdf}
}
\newcommand{\catalogpage}{46}
\newcommand{\term}{Spring 2012}
\newcommand{\adddropinfo}{
January 13.
}
\newcommand{\withdrawinfo}{
March 7.
}

and finally section specific file math1111c3.sty which needs to be updated not only on the term basis but also per section basis.

% Term specific information for a section
\newcommand{\sectionnumber}{C3}
\newcommand{\sectiontime}{MWF 11:00 AM - 11:50 AM}
\newcommand{\sectionroom}{University Hall 330}
\newcommand{\coursecalendar}{\input{cal-math1111-spring2012-MWF.tex}}
\newcommand{\examone}{February 6}
\newcommand{\examtwo}{March 5}
\newcommand{\examthree}{April 18}
\newcommand{\courseid}{\textbf{punosevac03397}}
\newcommand{\finalinfo}{Wednesday, May $9^{th}$ from 3:30 PM - 5:30 PM\@ }

I also separated cal-math1111-spring2012-MWF.tex with a fancy day by day course calendar which I need to rewrite. That file needs is term dependent but semi-section independent. It could be used by all sections which meet Monday, Wednesday and Friday.

\begin{center}
\begin{small}
\begin{tabular}{||l|l|l|l|l||l|l|l|l|l||}
\hline
\multicolumn{5}{||c||}{January}&\multicolumn{5}{c||}{February}\\
\hline
\begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}\\
\hline
\tiny{2}& \tiny{3} & \tiny{4} & \tiny{5} & \tiny{6} & \tiny{} & \tiny{} & \tiny{
1}  & \tiny{2} & \tiny{3} \\
        &          &          &        &          & &          &\tiny{1.3} &
      & \tiny{ Review}      \\
        &          &             &        &          & &          &           &
         &          \\
\hline
\tiny{9}&\tiny{10} & \tiny{11} & \tiny{12} & \tiny{13} & \tiny{6} & \tiny{7} &     tiny{8}  & \tiny{9} & \tiny{10} \\
        &            &\tiny{Intro} &       & \tiny{R.2, R.4}   & \tiny{\bf Exam
1}     &     & \tiny{1.4} &         & \tiny{ 1.5}        \\
        &            & \tiny{R.2}     &          &          & &
    &          &          &          \\
\hline
\tiny{16} & \tiny{17} & \tiny{18} & \tiny{19} & \tiny{20} & \tiny{13} & \tiny{14
} & \tiny{15}  & \tiny{16} & \tiny{17}  \\
\tiny{MLK} &        &\tiny{R.4, R.5}  &       &  \tiny{R.5} & \tiny{1.6} &
  & \tiny{1.7}   &         &\tiny{ 2.1}            \\
\tiny{Day} &                       &          &            &       & &
    &          &           &       \\
\hline
\tiny{23} & \tiny{24} & \tiny{25} & \tiny{26} & \tiny{27} & \tiny{20} & \tiny{21
} & \tiny{22}  & \tiny{23} & \tiny{24} \\
\tiny{R.7} &       &\tiny{R.8} &           &\tiny{ 1.1}  & \tiny{2.2} &       &    tiny{2.3}       &        & \tiny{ 2.5}      \\
        &                     &          &            &       & &
     &          &             &      \\
\hline
\tiny{30} & \tiny{31} & \tiny{} & \tiny{} & \tiny{} & \tiny{27} & \tiny{28} & \t
iny{29}  & \tiny{} & \tiny{} \\
\tiny{1.2} &           &       &         &       & \tiny{3.1}   &          &\tin
y{3.2} &         & \tiny{ Review}    \\
        &          &          &        &     & &          &          &
&          \\
\hline
\multicolumn{5}{||c||}{March}&\multicolumn{5}{c||}{April}\\
\hline
\begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Mon\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Tue\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Wed\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Thu\end{center}}\end{minipage}&
\begin{minipage}{1cm}{\begin{center}Fri\end{center}}\end{minipage}\\
\hline
\tiny{} & \tiny{} & \tiny{} & \tiny{1} & \tiny{2} & \tiny{2} & \tiny{3}  & \tiny
{4} & \tiny{5} & \tiny{6} \\
        &          &          &        &            & \tiny{No} & \tiny{No}&\tin
y{No}  &\tiny{No} & \tiny{No}\\
        &          &          &         &            & \tiny{Classes}& \tiny{Cla
sses}& \tiny{Classes}& \tiny{Classes}&\tiny{Classes}\\
\hline
\tiny{5} & \tiny{6}& \tiny{7} & \tiny{8} & \tiny{9} & \tiny{9} & \tiny{10}  & \t
iny{11} & \tiny{12} & \tiny{13} \\
\tiny{\bf Exam 2}&          &\tiny{3.4} &          &\tiny{ 4.1}    &  \tiny{6.6}
   &          &\tiny{6.6}  &      &\tiny{6.7}  \\
        &              & \tiny{Midterm}    &            &       & &
 &          &            &       \\
\hline
\tiny{12}  & \tiny{13} &\tiny{14} & \tiny{15} & \tiny{16} & \tiny{16} & \tiny{17
}  & \tiny{18} & \tiny{19} & \tiny{20} \\
\tiny{4.3}&            & \tiny{ 4.5}&     &     \tiny{5.4}      & \tiny{Review}
&      & \tiny{\bf Exam 3} &       &\tiny{8.1} \\
        &              &          &            &       & &              &
   &            &       \\
\hline
\tiny{19} & \tiny{20} & \tiny{21} & \tiny{22} & \tiny{23} & \tiny{23} & \tiny{24
} & \tiny{25} & \tiny{26} & \tiny{27} \\
\tiny{6.1}& &\tiny{ 6.2}&          &\tiny{6.3}           & \tiny{8.1}&     & \ti
ny{Review}     &      & \tiny{Review}    \\
        &       &       &        &       & &       &       &     &\\
\hline
\tiny{26}  & \tiny{27}& \tiny{28} & \tiny{29} & \tiny{30} & \tiny{30} & \tiny{\b
f May 1}  & \tiny{\bf May 2} & \tiny{} & \tiny{} \\
\tiny{6.4}&           &\tiny{6.4}&          &\tiny{6.5} &  \tiny{Review}&
 &\tiny{Review}&        &      \\
          &          &          &        &        &              &          &
          &        &          \\
\hline
\end{tabular}
\end{small}
\end{center}

My first shoot in creating syllabus.cls file. I am still fighting two column header and hyperref colors.

% Items common to a particular visual style of syllabus -- in theory,
% can be used for all syllabi in a particular department.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{syllabus}[2012/01/19 v0.1 Modified article class for
syllabi]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}

\RequirePackage{enumitem}
\setlist{noitemsep}

\RequirePackage{multicol}
% Two-column lists (itemize, description, etc.)
%\SetEnumitemKey{twocol}{itemsep=1\itemsep,parsep=1\parsep, before=\raggedcolumn
s\begin{multicols}{2}, after=\end{multicols}}

\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{booktabs}
\RequirePackage{multirow}
\RequirePackage[margin=1in]{geometry}

\RequirePackage{titlesec}
% titlesec documentation, section 3.1
\titleformat{\section}[runin]{\normalfont\bfseries}{}{.5em}{}[:]

\RequirePackage{hyperref}
\RequirePackage{url}
\RequirePackage{color}

\newcommand{\courseheader}{
\begin{center}
{\Large \textbf{Syllabus for \coursenumber{}  {\tiny Section
\sectionnumber{}}}}

\vspace{0.2cm}

{\large \textbf{\coursetitle{}}}
\end{center}

\medskip

\hrule
\vspace{0.2cm}
%\begin{description}[twocol,leftmargin=1.1in,style=nextline]
%\item[Term:] \courseterm{}
%\item[Time:] \coursetime{}
%\item[Room:] \courseroom{}
%\item[Credit Hours:] \coursecredit{}
%\item[Instructor:] \instructor{}
%\item[Office:] \instructoroffice{}
%\item[Phone:] \instructorphone{}
%\item[E-mail:] \instructoremail{}
%\end{description}

\vspace{0.2cm}
\hrule

\vspace{0.4cm}
}
\newcommand{\coursecontent}{
\begin{description}[leftmargin=0in]
    \item[\textbf{Office Hour:}] \instructorofficehours{}
    \vspace{-0.1cm}
    \item\let\thefootnote\relax\footnotetext{\tiny \textbf {This course syllabus
         provides a general plan for the course; deviations may be necessary.
         \coursedisclaimer{}}}
    \item[\textbf{Text(s):}] \coursetexts{}
    \vspace{0.2cm}
    \item[\textbf{Description:}]\coursedescription{}
    \vspace{0.2cm}
    \item[\textbf{Prerequisite(s):}]\courseprerequisites{}
    \vspace{0.2cm}
    \item[\textbf{Course Outline:}]\courseoutline{}
\end{description}

\coursecalendar{}    


\newpage
\begin{description}[leftmargin=0in]
    \item[\textbf{Attendance:}] Students are expected to attend class
        daily and arrive in a timely fashion. Attendance will be taken. Up to 10
        points towards your final grade will be awarded based on your attendance
        records.
    \vspace{0.2cm}
    \item[\textbf{Policy on Academic Honesty:}] All students are
        expected to abide by the Augusta State University policy on academic
        honesty page \catalogpage{} of \catalog{\it Augusta State University
        Catalog}\/.
    \vspace{0.2cm}
    \item[\textbf{Homework/Quizzes:}]\coursehomework{}
    \vspace{0.2cm}
    \item[\textbf{In-Class Exams:}]\courseexams{}
    \vspace{0.2cm}
    \item[\textbf{Make-Up Policy:}] There will be no makeups on
        homework/quizzes, and in-class work. To allow for excused absences, I
        will drop your five lowest homework/quizzes scores. Makeups on an exam
        will be given at the discretion of the instructor. A legitimate and
        verifiable excuse is required. If the excuse is approved, the makeup
        will be given within one week of the missed test.
     \vspace{0.2cm}
     \item[\textbf{Final Exam:}]\coursefinalexam{}
    \vspace{0.2cm}
    \item[\textbf{Grades:}]\coursegrades{}
    \vspace{0.2cm}
    \item[\textbf{Important Deadlines:}]
        Registration and add/drop ends \adddropinfo{.} The last day to withdraw
        from the course is \withdrawinfo{.}
    \vspace{0.2cm}
    \item[\textbf{Student Disabilities Policy:}]  If you have now or
        develop during this semester a physical or learning disability and you
        want your professor to make reasonable accommodations for that, you must
        contact the Office of Disability Services at (706) 737-1471. Once the
        Office of Disability Services  has received appropriate documentation,
        they will inform your instructors.
    \vspace{0.2cm}
    \item[\textbf{Academic Assistance at ASU:}]
        \begin{enumerate}
        \item Math Assistance Center (MAC), Allgood Hall N337.
        \end{enumerate}
\end{description}
}

At this point math1111c3.tex is just a tiny wrapper which looks like

\documentclass{syllabus}
\usepackage{instructor}
\usepackage{spring2012}
\usepackage{math1111}
\usepackage{math1111c3}
\begin{document}
\courseheader{}
\coursecontent{}
\end{document}

It is pretty clear that most info in that file is common to all courses and sections we teach and it doesn't change at all from semester to semester so it needs to be rewritten as a .cls file. math1111c3.tex is then essentially only a wrapper for all of above.

There are two other things on my to do list:

  1. One is to write a script mostly likely combination of sh, sed, and awk which will pull the info directly from my university web server and update essentially only math1111c3.sty file.

  2. Write awk script which will update cal-math1111-spring2012-MWF.tex automatically. Unfortunately I have to rewrite firstly cal-math1111-spring2012-MWF.tex in much more clever way to be able to write AWK script. Right now it is just hand hucked.

Tags:

Python

Scripts