#StackBounty: #html #make4ht How to use my own HTML template with make4ht?

Bounty: 50

Here is my LaTeX file foo.tex:

documentclass{article}
usepackage{amsmath}
title{Demo}
begin{document}

begin{align}
1 + 0 & = 1, label{eq1} \
1 + 1 & = 2, label{eq2} \
e^{i pi} = -1. label{eq3}
end{align}

Equations ( eqref{eq1} ), ( eqref{eq2} ) and ( eqref{eq3} )
describe eternal truths.

The equation ( e^{i pi} = -1 ) can also be rewritten as ( e^{i pi}
+ 1 = 0 ) which is known as Euler's identity.
end{document}

I convert it to HTML like this:

$ make4ht foo mathjax
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: foo
[STATUS]  make4ht: Conversion finished

Here is the output foo.html:

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta name='generator' content='TeX4ht (https://tug.org/tex4ht/)' /> 
<meta name='viewport' content='width=device-width,initial-scale=1' /> 
<link href='foo.css' type='text/css' rel='stylesheet' /> 
<meta name='src' content='foo.tex' /> 
<script>window.MathJax = { tex: { tags: "ams", inlineMath: [ ["\(","\)"] ], displayMath: [ ['$$','$$'], ["\[","\]"] ], processEscapes: true, processEnvironments: true, packages: ['base', 'color', 'ams'] }, loader: { load: ['[tex]/color', '[tex]/ams'] } }; </script> 
 https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js  
</head><body>
<!-- l. 10 --><p class='noindent'>begin{align} 1 + 0 &amp; = 1, label{eq1} \ 1 + 1 &amp; = 2, label{eq2} \ e^{i pi } = -1. label{eq3} end{align}
</p><!-- l. 12 --><p class='noindent'>Equations ( eqref{eq1} ), ( eqref{eq2} ) and ( eqref{eq3} ) describe eternal truths.
</p><!-- l. 15 --><p class='indent'>   The equation ( e^{i pi } = -1 ) can also be rewritten as ( e^{i pi } + 1 = 0 ) which is known as Euler’s identity.
</p> 
</body> 
</html>

So far so good. However, what I want to do is to use my own HTML template that decides the header and footer. I want only the main content to be generated by make4ht.

Here is my template template.html.

<!DOCTYPE html>
<html>
<head>
  <title>Test</title> 
  <meta charset='utf-8' /> 
  <meta name='viewport' content='width=device-width,initial-scale=1' /> 
  <style>
    body {background: gray}
    main {background: white; max-width: 40em; margin: 0 auto; padding: 1em}
  </style>
  <script>window.MathJax = {tex: {tags: "ams"}}</script> 
  https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js  
</head>
<body>
<main>

<!-- HTML converted by make4ht goes here -->

</main>
</body>
</html>

Is there a way to ask make4ht use this template instead of using its own template to generate the output HTML?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.