Header Files and Snippets

From WeBWorK_wiki
Jump to navigation Jump to search

WeBWorK uses several header files and other snippets in certain situations.

Header files

There are two PG header files, the set header and the hardcopy header. The set header is displayed on the homework set screen to the right of the problem list. The hardcopy header is included in hardcopy output at the start of the problem set.

See Site Info, Login Info, Course Info for information on customizable files which are used to display information for the whole WeBWorK site, on a course login page and on a course front page.


In current versions of WeBWorK the same file is used for both headers, webwork2/conf/snippets/setHeader.pg. This file is designed so that is renders in both HTML-based display modes (when used onscreen) and TeX mode (when used in hardcopy).

Either header file can be overridden on a per-homework set basis. To do so, go to the Hmwk Set Editor and click the number of problems to the right of the homework set name.

These two configuration variables control the site-wide defaults:

hardcopy header
Variable: $webworkFiles{hardcopySnippets}{setHeader}
Default file: conf/snippets/setHeader.pg
set header
Variable: $webworkFiles{screenSnippets}{setHeader}
Default file: conf/snippets/setHeader.pg

You can change the values of these variables in global.conf or override them in course.conf for a particular course.

For more information of header files, see Header Files More Information.

Hardcopy snippets

The information below pertains to WeBWorK 2.17 and some earlier versions. For 2.18 (and beyond), see Hardcopy Themes.

Hardcopy generation also uses the following snippets, small TeX files which are included in the TeX file between dynamically-generated content. One snippet, the setFooter, is a PG file. These are set in global.conf and can be customized there or overridden in an individual course's course.conf file.

preamble
The preamble is the first thing in the TeX file.
Variable: $webworkFiles{hardcopySnippets}{preamble}
Default file: conf/snippets/hardcopyPreamble.tex
problemDivider
The problem divider goes between problems.
Variable: $webworkFiles{hardcopySnippets}{problemDivider}
Default file: conf/snippets/hardcopyProblemDivider.tex
setFooter
The set footer goes after each set. Is is a PG file.
Variable: $webworkFiles{hardcopySnippets}{setFooter}
Default file: conf/snippets/hardcopySetFooter.pg
setDivider
The set divider goes between sets (in multiset output).
Variable: $webworkFiles{hardcopySnippets}{setDivider}
Default file: $webworkDirs{conf}/snippets/hardcopySetDivider.tex
userDivider
The user divider does between users (in multiuser output).
Variable: $webworkFiles{hardcopySnippets}{userDivider}
Default file: conf/snippets/hardcopyUserDivider.tex
postamble
The postamble is the last thing in the TeX file.
Variable: $webworkFiles{hardcopySnippets}{postamble}
Default file: conf/snippets/hardcopyPostamble.tex

Snippets for the "images" display mode

The "images" display mode uses dvipng to generate images of mathematics. We use LaTeX to generate the DVI file that dvipng converts. There are two constants in lib/WeBWorK/Constants.pm that define the header and footer of the TeX file.

The TexPreamble goes at the beginning:

$WeBWorK::PG::ImageGenerator::TexPreamble = <<'EOF';
\documentclass[12pt]{article}
\nonstopmode
\usepackage{amsmath,amsfonts,amssymb}
\def\gt{>}
\def\lt{<}
\usepackage[active,textmath,displaymath]{preview}
\begin{document}
EOF

and the TexPostamble goes at the end:

$WeBWorK::PG::ImageGenerator::TexPostamble = <<'EOF';
\end{document}
EOF

If you change either of these values, you must restart Apache for changes to take effect. Use apachectl graceful or apache2ctl graceful. You cannot customize these settings on a per-course basis.