## WeBWorK Main Forum

### Is there a way for Webwork to transfer html to the Hardcopy Generator?

by Geoff Cox -
Number of replies: 4

I was wondering if it is possible for the Hardcopy Generator to display html in the PDFs? My guess is that it isn't but I just wanted to make sure.

For example, when I place an html table in a Webwork problem, it looks great in the browser. However, when I try to generate a hardcopy PDF for printing, I get inverted question and exclamation marks (e.g. ¡).

I've attached a photo of what I am taking about. The image on the left is a webwork problem as seen from a browser and the image on the right is the same problem from a generated PDF

Thanks!
In reply to Geoff Cox

### Re: Is there a way for Webwork to transfer html to the Hardcopy Generator?

by Michael Gage -
It's hard to translate HTML into TeX. :-)   What you can do however is to describe the table using macros and variables that will produce either HTML (when displayed on a screen) or TeX (when displayed in hardcopy).  This is why we use $PAR for example. That variable becomes \par for TeX but &lt p &gt for HTML. Here is a description of two ways for creating tables that work well in both HTML and in hardcopy. http://webwork.maa.org/wiki/Tables -- Mike In reply to Michael Gage ### Re: Is there a way for Webwork to transfer html to the Hardcopy Generator? by Geoff Cox - Thanks for the reply Mike. That is what I figured. I am aware of the alternative ways of creating tables, but I find that their options for customization are a bit limited compared to the <table> tag. I guess I'll have to decide what's more important: having a perfectly customized interface or the ability to print hardcopies. In reply to Geoff Cox ### Re: Is there a way for Webwork to transfer html to the Hardcopy Generator? by Michael Gage - It might not be hard to increase the customizability of the table macros. Think about what you need or would like and submit an "enhancement" bug report. Or make a fix yourself and submit that for inclusion in the github.com/openwebwork/pg repository. The main challenge is to make it generally useful and not just a one special case modification. The customizability that is already there is because someone had a use for it. -- Mike In reply to Michael Gage ### Re: Is there a way for Webwork to transfer html to the Hardcopy Generator? by Paul Pearson - Hi, There are two ways to create tables using existing WebWork code: basic tables (that load with PGstandard.pl) and slightly more advanced tables (provided by the unionTables.pl macro): https://github.com/openwebwork/pg/blob/master/macros/unionTables.pl Example 3 on this page http://webwork.maa.org/wiki/Tables uses the unionTables.pl macro, as do several examples on http://webwork.maa.org/wiki/GraphsInTables I strongly encourage you to use one of the two existing ways to make tables in WebWork. If neither of the two ways to create tables in WebWork meets your needs, you could define a display mode dependent variable that contains the table as follows. $a = random(2,9,1);

if ($displayMode eq 'TeX') {$mytable = "$\begin{array}{r} a \end{array}$";
} else { # html mode
$mytable = "<center><table><tr><td>$a </td></tr></table></center>";
}

BEGIN_TEXT
\$mytable
END_TEXT


Best regards,

Paul Pearson