We start with a typical question written in LaTeX.
\documentclass{article} \usepackage{epsfig} \begin{document} %\begin{figure} % \begin{center} % \fbox{ % \epsfig{width=4in,file=ch1q26_h.ps}} % \end{center} %\end{figure} The Schr\"{o}dinger Equation (in dimensionless form) for the particle in a box (stretching from x=0 to x=L) is: $$ - { {h^2}\over{8 m \pi^2}} { {\partial^2 \psi}\over {\partial x^2}} = \epsilon \psi $$ and, given two eigenfunctions: $$ \psi_1 = \sqrt{{2\over L}} \sin \left ( {{1 \pi x}\over L}\right ) $$ $$ \psi_2 = \sqrt{{2\over L}} \sin \left ( {{2 \pi x}\over L}\right ) $$ if a state is prepared which is one half of $\psi_1$ and one half $\psi_2$, i.e., a linear combination with equal co\"{e}fficients, what is the expected energy ($\epsilon$) of the resultant state? \end{document}Please note that there are some commented out lines which show how one can include figures which have been saved in PostScript form. We will cover making figures later.
First we LaTeX this file, to make sure that it has no LaTeX errors. Then we LaTeX2HTML the file, which, because of the way lsh works, creates a subdirectory below where we happen to be, and fills it with files. If our original file was called qm1q05.tex, then in the qm5q01 subdirectory is a file called qm1q05.html. This is the file we are interested in. Here is the output html file created by using LaTeX2HTML on the above qm1q05.tex file:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds --> <HTML> <HEAD> <TITLE>No Title</TITLE> <META NAME="description" CONTENT="No Title"> <META NAME="keywords" CONTENT="qm1q05"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <LINK REL=STYLESHEET HREF="qm1q05.css"> </HEAD> <BODY LANG="EN"> <A NAME="tex2html1" HREF="node1.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="http://www.chem.uconn.edu/~cdavid/l2hicons/next_motif.gif"></A> <IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="http://www.chem.uconn.edu/~cdavid/l2hicons/up_motif_gr.gif"> <IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="http://www.chem.uconn.edu/~cdavid/l2hicons/previous_motif_gr.gif"> <BR> <B> Next:</B> <A NAME="tex2html2" HREF="node1.html"> About this document </A> <BR> <P> The Schrödinger Equation (in dimensionless form) for the particle in a box (stretching from x=0 to x=L) is: <P> <IMG WIDTH=309 HEIGHT=36 ALIGN=BOTTOM ALT="displaymath23" SRC="img1.gif" > <P> and, given two eigenfunctions: <P> <IMG WIDTH=325 HEIGHT=42 ALIGN=BOTTOM ALT="displaymath25" SRC="img2.gif" > <P> <P> <IMG WIDTH=325 HEIGHT=42 ALIGN=BOTTOM ALT="displaymath27" SRC="img3.gif" > <P> if a state is prepared which is one half of <IMG WIDTH=16 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline29" SRC="img4.gif" > and one half <IMG WIDTH=16 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline31" SRC="img5.gif" > , i.e., a linear combination with equal coëfficients, what is the expected energy ( <IMG WIDTH=4 HEIGHT=7 ALIGN=BOTTOM ALT="tex2html_wrap_inline33" SRC="img6.gif" > ) of the resultant state? <P> <BR> <HR> <UL> <LI> <A NAME="tex2html3" HREF="node1.html#SECTION00010000000000000000"> About this document ... </A> </UL> <BR> <HR> <P><ADDRESS> <I> <BR> Wed Jun 19 12:56:00 EDT 1996</I> </ADDRESS> </BODY> </HTML>Along with this file are a host of other files, created by LaTeX2HTML, which correspond to equations and special symbols which, being unrenderable in the various fonts available on the net, have been converted to pictures, in 'gif' format.
We now need to convert this html file into a Perl program which is interactive (the html file is read only). Here is the ultimate result:
#!/usr/local/bin/perl -- -*-perl-*- require "CleanUp.pl"; require "explain.pl"; require "count.pl"; require "reports.pl"; require "ChemSym.pl"; $title = "qm1q05"; use CGI; $query = new CGI; print $query->header; print $query->start_html($title); srand; &ChemSym; print "<h1>$title</h1>"; $scriptname = $query->script_name();#this gives the question name print "Anonymous access to the <a href=test_send_memo.pl?var=$scriptname>webmaster </a>to send a message concerning computer related errors in this question is available here.<br>"; print "<hr>"; $faculty_id = $query->param('faculty'); $student_id = $query->param('student'); print "<a href=../notation/notation.html>Click here to get an explanation of notation.</a>"; print "<hr>"; &count($scriptname); print $query->start_form; print $query->hidden('faculty',$query->param('owner')); print $query->hidden('student',$query->param('name')); $faculty_id = $query->param('faculty'); $student_id = $query->param('student'); $ans = '(5/2)*((h**2)/(8*me*l**2))'; $saved_ans = '(5/2)*((h**2)/(8*me*l**2))'; # question goes here print $query->start_form; $loc = "../qm1q05"; print <<EOF; The Schrödinger Equation (in dimensionless form) for the particle in a box (stretching from x=0 to x=L) is: <P> <IMG WIDTH=313 HEIGHT=36 ALIGN=BOTTOM ALT="displaymath23" SRC="$loc/img1.gif" > <P> and, given two eigenfunctions: <P> <IMG WIDTH=325 HEIGHT=42 ALIGN=BOTTOM ALT="displaymath25" SRC="$loc/img2.gif" > <P> <P> <IMG WIDTH=325 HEIGHT=42 ALIGN=BOTTOM ALT="displaymath27" SRC="$loc/img3.gif" > <P> if a state is prepared which is one half of <IMG WIDTH=16 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline29" SRC="$loc/img4.gif" > and one half <IMG WIDTH=16 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline31" SRC="$loc/img5.gif" > , i.e., a linear combination with equal coëfficients, what is the expected energy ( <IMG WIDTH=4 HEIGHT=7 ALIGN=BOTTOM ALT="tex2html_wrap_inline33" SRC="$loc/img6.gif" > ) of the resultant state? <P> <br>Use `me' for the mass, `l' or `L' for the length of the box, and `h' for Planck's constant. EOF print "<br> Answer is:",$query->textfield('ans','',30,40); print "<P> Query, is the above answer correct?",$query->submit; print $query->end_form; $stu_ans = $query->param('ans'); if ( $query->param('ans') ne '') { $saved_stu_ans = $stu_ans; &CleanUp($stu_ans);#this removes potential hacker imbedded illegal commands srand(); $h = rand; $me = rand; $l = rand; $stu_ans =~ s/h/$h/gi; $ans =~ s/h/$h/gi; $stu_ans =~ s/l/$l/gi; $ans =~ s/l/$l/gi; $stu_ans =~ s/me/$me/gi; $ans =~ s/me/$me/gi; print "student_answer = $saved_stu_ans"; $stu_ans = eval($stu_ans); $ans = eval($ans); #print "student_answer evaluated = $stu_ans<p>"; #print "answer evaluated = $ans <p>"; if (eval (($stu_ans - $ans)**2 - 0.1 ) ge 0.0 ) {print ", <EM> Wrong</EM>, <IMG SRC=../icons/checkno.gif\>"; &reportstudent($faculty_id,$student_id,$saved_stu_ans,$saved_ans,$scriptname); &reportfaculty($faculty_id,$student_id,$saved_stu_ans,$saved_ans,$scriptname); print "<a href=".$title."_h.pl?owner=$faculty_id&name=$student_id>Help is available for this question<br></a>"; } else {print ", <EM> Right! </EM>, <IMG SRC=../icons/check.gif\>"; &reportfaculty_right($faculty_id,$student_id,$saved_stu_ans,$saved_ans,$scriptname); }; }; print $query->end_html;There are several points to be made about this last conversion, which has been done by hand, individually for each question.