Monday, February 29, 2016

Hardcopy Themes

Are you tired of the standard "two column" hardcopy format that has been used by WeBWorK since the project was started?  Well starting in version 2.12 there is the option to choose a "hardcopy theme".  Currently there is are two themes, a one column mode and a two column mode.  However, the system is build so that you could add your very own.

Choosing a hardcopy theme is simplicity itself.  When generating a hardcopy simply choose "One Column" or "Two Columns" for the Hardcopy Theme option.

You will get either this:

or this: 

You can also set the default theme on the Course Configuration page.  In particular the theme chosen on the Course Configuration page is the only theme that students are allowed to use.

Unless you are willing to get your hands dirty, then that is the extent of the feature.  However, there is also the possibility of adding new Hardcopy themes to the mix.  To create a new theme you need to add a folder to the webwork2/conf/snippets/hardcopyThemes folder.  This new folder should contain the following files:

  • hardcopyPreamble.tex - This tex file contains the LaTeX code that will be at the beginning of the hardcopy.  This is where all of the preamble code goes, including packages, macros, page formatting, etc...
  • hardcopyPostamble.tex -  This tex file contains the LaTeX code that will be at the end of the hardcopy.  It ends the document.  
  • hardcopyProblemDivider.tex - This tex file contains the LaTeX code that will be inserted between each problem.  
  • hardcopySetDivider.tex - This tex file contains the LaTeX code that will be inserted between each set. 
  • hardcopyUserDivider.tex - This tex file contains the LaTeX code that will be inserted between each user.  
  • hardcopySetHeader.pg - Normally this pg file would be rendered and placed at the top of each set.  However, most sets now have their own Hardcopy Header file specified on the Set Detail page which takes precedence over this one.  
  • hardcopySetFooter.pg -  This pg file is rendered and the resulting tex code is put at the bottom of each set.  
The changes you make to these files, in particular the hardcopyPreamble.tex file, will control what the resulting hardcopy looks like.  You could put more space between problems by adding a vspace to the problem divider.  You can add university specific detailing to the footers.  You could change the font or margins.  Once you have gotten the hardcopy format you desire its time to add it to WeBWorK.  In order to do that you should add overiddes to the following variables in localOverrides.conf.
# Available Hardcopy themes (located in snippets)
$hardcopyThemes = [qw(oneColumn twoColumn)];
# Hardcopy theme names (pretty names for themes)
$hardcopyThemeNames = {oneColumn => 'One Column',
      twoColumn => 'Two Columns'};
# Default Hardcopy them
$hardcopyTheme = "twoColumn";
The theme name (e.g. oneColumn, twoColumn) should be the name of the folder you made in hardcopyThemes.   The pretty theme name (e.g. One Column, Two Columns) is the name that is actually displayed to users.  Once you add your theme to $hardcopyThemes and $hardcopyThemeNames you are done.  The theme will automatically appear on the Hardcopy page and the Course Configuration page as an option.  If you make a particularly good theme, please consider contributing it to the main repository so other people can use it.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.