Pandoc creates the converted document using a default template which is mostly a long LaTeX preamble. To find it, search for a file called default.latex
in the pandoc installation directory): in my Linux version, for instance, it is in /usr/share/pandoc/data/templates/default.latex
. You can open it and find which packages it contains.
There are some other control instructions in the file, apart from standard LaTeX code, but they are readable enough, e.g.,
$if(mainfont)$
\setmainfont{$mainfont$}
$endif$
In my version, the preamble includes (among others packages less relevant here) amssymb
and amsmath
, so you can use every math font and environment defined in these packages. You can check their documentation, available on http://www.ctan.org/pkg/amsmath and http://www.ctan.org/pkg/amsfonts, to find exactly what is included (in particular the amsmath guide is very helpful and well-written, when it comes to equation environments.
If you need more functions, you can add packages and change the default preamble using pandoc
command line arguments.
You can easily support custom commands with tex4ht
. Just move declaration of the commands to standalone package, for example mycommands.sty
:
\newcommand{\subchpbreak}{\fancybreak{\rotatebox[origin=c]{90}{\S}}}
and create file with same name, but .4ht
extension, mycommands.4ht
:
\NewConfigure{subchpbreak}{1}
\renewcommand\subchpbreak{\a:subchpbreak}
\Configure{subchpbreak}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class='subchpbreak'>&\#167;</div>}}
\Css{.subchpbreak{font-size:1.2em;}}
To allow configurability, we need to declare some hooks in which will be inserted html code. These hooks are inserted to redefined commands. In this case, we declared new configuration, subchpbreak
with one hook, because your command takes no arguments. For commands one parameter, you would need two hooks, to be inserted before and after the parameter, for two parameters you would need three hooks and so on.
The hook is then inserted to redefined command, the hooks are named as \a:hookname
, b:hookname
, etc. In our case we use only one hook, so it is just \a:subchpbreak
.
The hook is configured with
\Configure{subchpbreak}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class='subchpbreak'>&\#167;</div>}}
we need to use
\ifvmode\IgnorePar\fi\EndP
because <p>
elements are inserted in each paragraph, but we don't want them around our <div>
You can add stuff to the .css
file with the \Css
command.
The resulting html:
<!--l. 15--><p class="noindent" >“Alas, this is a quote,” said the idiot.
</p>
...
</p>
<div class='subchpbreak'>§</div>
<!--l. 21--><p class="indent" >
Regarding your problem with fonts, you should use \usepackage[T1]{fontenc}
for best unicode support. When you use paratype
fonts, you may see following message in the terminal output:
--- warning --- Couldn't find font `PTSerif-Regular-tlf-t1.htf'
for each font, .htf
file must exist. I recently provided a solution for Droid sans, in your case you may create following PTSerif-Regular-tlf-t1.htf
file:
.lm-ec
htfcss: PTSerif-Regular-tlf-t1 font-family: 'PT Serif', serif;
see the linked answer about Droid Sans for details. You may need to create similar files also for italic and bold fonts, if you use them.
Best Answer
Your
MWE_pandoc.tex
document, when processed with tex4ht, using(see this page for other options) gives:
which is rendered as
As a side note, I find
pandoc
more flexible to use, so if I were you, I would watch this topic on github, to see if a reliable interfaceamsmath
/pandoc
sees the day. But that's probably just a matter of personal taste…