2017 Problem Authoring Workshop

HTML and images in problem files

by Gavin LaRose -
Number of replies: 2
Since I write webpages with math in them with HTML and Latex, I'd like to use that as much as I can; since these are webpages, HTML seems like a natural thing to use. So, for example, including image files in a .pg file has a specific Perl command. Can it be done using HTML instead?

Re: HTML and images in problem files

by Gavin LaRose -
The answer to this is what Davide gave in the workshop session: "no." The problem is that WeBWorK is doing a number of different things: it generates a web page for students to interact with on-line, and has the ability to generate a hardcopy as well. So anything that we're doing in the WeBWorK problem has to be able to be rendered in multiple environments, which means that straight HTML won't work correctly.

In essence, we trade the "flexibility" of straight HTML with the ability to run the problems in WeBWorK and in several formats.

Gavin
For this particular question (about images), there is also the issue of the URL for the image file. If the image is an external one (from some other website), that would make the URL easy to deal with, but would give your problem an external dependency, so it could break at any time. So we usually include the image files along with the .pg problem file. But the templates directory is not directly available to the web, so there are no URLs for the image files directly. Part of what the image() function does in WeBWorK is make the image file available in a location that is available to the web. It also handles the image properly for inclusion in the LaTeX file that is used to create the hardcopy output.