Solutions in html export of exams using the education package

I wanted to leave a comment on the education packages intended to create exams. This package adds the ability to add solutions, which can be hidden prior to exporting. This allows to create versions with and without solutions.

This works well for pdfs, but whan such a file is exported to html the solutions are still present in the html code. They are made invisible with ‘style=“display: none”’, but a clever student may still be able to find them. Beware!


You can add a macro to your file to avoid that the solutions appear in the html export. I leave you as exercise do to it :slight_smile: look at the Help pages for conversion for some hints. I can help if you want.

1 Like

Thanks very much for the hint! I figured it out :slightly_smiling_face:
I put


into a package “no-solutions-in-html.ts” and added it to the document.

Now I’m trying to get this to load for every new document. The documentation says to add

(when (buffer-newly-created? (current-buffer))
(set-style-list (append (get-style-list) '("no-solutions-in-html")))
(buffer-pretend-saved (current-buffer)))

to my-init-buffer.scm, but this doesn’t add the package to a new document. If I evaluate the (set-style-list …) command in a document, the package is added. Has anything changed to buffer initialisation since the documentation was written?

My guess is that because the system’s init-buffer.scm is run before the user’s my-init-buffer.scm and because the system file manipulates the buffer, buffer-newly-created? in my-init-buffer.scm evaluates to false and the code in it is not run.

Once you are done, if you have the time and patience to write it up as a blog post, this could be an excellent contribution. A possible idea for the post is “functionality of a standard package” -> “further wish” -> “personal customization”.

1 Like

If you need the command on a per-file basis you can also put it in the preamble of the document.
Moreover if you want really this to be permanent I think you can modify the exam style adding the new definitions and then put a copy in the appropriate .TeXmacs sub directory, so that TeXmacs will load your custom exam file instead of the standard one.

1 Like

I have discovered another trick to load a style file for every new document from the TeXmacs Scheme developer guide: use (not (buffer-has-name? (current-buffer))

The snippet in my-init-buffer.scm then becomes

(if (not (buffer-has-name? (current-buffer)))
  (set-style-list (append (get-style-list) '("no-solutions-in-html")))
  (buffer-pretend-saved (current-buffer))))

This seems to work.

1 Like