Hot answers tagged

24

You have to do two things: you can disable generation of css and ugly elements like <span class="cmti-10x-x-109">Emphasized text</span> with some command line options: htlatex filename "xhtml,NoFonts,-css" You will then have to provide configurations for em and textit, as they are by default dealt only by css. This should be done with ...


12

For pdf output you can use the minted package. This produces a nicely formatted and coloured PDF file for you. As described in the minted package documentation, you have to install Pygments and run (pdf)latex with the -shell-escape option. To use this approach to produce html you also need to pass the -shell-scape option to htlatex. You can do this using ...


10

Nasser Abbasi's web is created with tex4ht. Some pages are really large. I've created some documents with responsive design Claudio Rodriguez has some documents with extensive JavaScript use (Github with supporting files) Phillip Lord has some document with JavaScript syntax highlighting


9

Colors are supported by tex4ht but there are two points: \color command isn't supported: The \Verb!\color{red}! instruction might be problematic since it does not on its own determine the extent of the text to be colored. As a result, its effect can cross logical boundaries. That is against the philosophy of markup languages in general and of XML ...


9

You need to declare extensions which should LaTeX try when including graphics. You can use \DeclareGraphicsExtensions in the custom config file: \Preamble{xhtml} \DeclareGraphicsExtensions{.jpg,.png,.gif,.svg} \begin{document} \EndPreamble save this as myconfig.cfg and compile with make4ht -c myconfig.cfg filename.tex LaTeX now should try each to include ...


9

tex4ht works best when your macros are saved in a .sty file and tex4ht configurations for these macros are saved in file named as the .sty file, only with .4ht suffix. In your situation, you may put your macro \myfunction to mystyle.sty: \newcommand{\myfunction}[2]{The title is: #1 an the body is \textit{#2} } now what to put to mystyle.4ht? You need to ...


8

I think the problem is that both memoir and tex4ht redefines lot of standard macros. tex4ht tries hard to translate LaTeX tables to their html counterparts. In order to do that, it inserts some configurable hooks to standard macros. But it seems that memoir also changes standard table macros, in some way which is incompatible with tex4ht This problem can be ...


8

Following code will help you to grab the width and height dimensions of the graphic provided with your \includegraphics command: \makeatletter \Configure{graphics} {\bgroup \Configure{IMG} {\HCode{<img src="}} {\HCode{" alt="}} {" } {\HCode{" }} {}% \Picture+[PIC]{}} ...


8

It is perhaps possible to hook somewhere in the listings commands so that they write sensible class instructions. But on the other side listings is very complicated and this could easily break. Imho a more simple approach is with fonts: if every style is connected to a different font then tex4ht surrounds the chars with classes which you can set throught css....


8

It is known problem that tex4ht pgfsysdriver does have some problems with text nodes. In such cases, it is better to use tikz externalization. There are some problems you need to solve: dependendency environment doesn't support externalization. You can replace it with tikzpicture in your case there are several ways to convert externalized pictures to svg, ...


8

** another edit ** I've found that link to tex4ht-4ht.tex file was pointing to quite old revision, so provided patch may fail on this file. Please download this version edit: original patch was already applied to tex4ht sources in the source repository. as Ulrike pointed out, scrartcl still doesn't work. so I made new version: --- tex4ht-4ht.tex (...


8

You haven't provided full mwe, so I expanded your sample to illustrate the problem: \documentclass{article} \begin{document} \begin{figure} \begin{minipage}{0.6\textwidth} \makebox[0.4\columnwidth][l]{line1} \par \makebox[0.4\columnwidth][l]{line2} \par \makebox[0.4\columnwidth][l]{line3} \end{minipage} \...


8

The issue is that there are no support font files for EB Garamond or other fonts you tested. tex4ht needs supporting htf files for 8-bit fonts. They contain mappings from the font characters to Unicode, which is necessary especially for stuff like ligatures or accented letters. Creation of the htf files is not easy, the majority of htf files has been ...


7

You might make use of the following code to suppress character level <span> node creation: \Configure{htf}{4}{+}{}{}{}{}{}{}{} so that you will get: <span class="cmcsc-10">sufficient</span> which is the default behavior when character level <span> node is suppressed.


7

Try this config file: \Preamble{xhtml} \Configure{@HEAD}{\HCode{<link href="basic.css" rel="stylesheet" type="text/css" />\Hnewline}} \DeclareGraphicsRule{.png}{bmp}{.xbb}{} \ConfigureEnv{figure} {\ifvmode\IgnorePar\fi\EndP\HCode{<div class="figure"\Hnewline>}% \bgroup \Configure{float}{\ShowPar}{}{}% } {\egroup \ifvmode\...


7

It is possible to postprocess the html files using make4ht filters. We can find corresponding id attributes for labels in the aux file: \newlabel{invisible_figure}{{\rEfLiNK{x5-40011}{\csname :autoref\endcsname{figure}1}}{\rEfLiNK{x5-40011}{\csname :autoref\endcsname{figure}9}}{\rEfLiNK{x5-40011}{\csname :autoref\endcsname{figure}My invisible figure}}{...


7

Edit: The current version of make4ht now contains an extension for mathjax-node-page. It can be requested using make4ht -f html5+mathjaxnode filename.tex Here is a sample document. There is a command line application provided by mathjax-node-page, mjpage, which can process the HTML page and replace the LaTeX or MathML code with plain HTML or SVG code, ...


6

Finally I got the answer: The -shell-escape option should be passed as the fifth argument to htlatex. htlatex <filename> <cfg> <ht-font-dir-for-tex4ht> <option-to-t4ht-program> <tex-command-line-option> So an example would be: htlatex test.tex config.cfg "xhtml,charset=utf-8" -utf8 -shell-escape htlatex test.tex config.cfg ""...


6

Run 'htlatex file' which will give you file.idx among other files. Given below are the commands to process the index file: tex '\def\filename{{file}{idx}{4dx}{ind}} \input idxmake.4ht' makeindex -o file.ind file.4dx Run 'htlatex file' again, now you will get file.html with hyperlinked index.


6

\RequirePackage{ifpdf} \documentclass{\ifpdf scrartcl\else article\fi} \begin{document} hello \end{document} Or, may be (I don't know) it's better not to risk anything \RequirePackage{ifpdf} \ifpdf \documentclass{scrartcl} \else \documentclass{article} \fi \begin{document} hello \end{document}


6

You've identified code for float configuration correctly. It doesn't work in the config file because of \:xhtml command. Macros with : in name work only in .4ht files, because they have different \catcode here. If you want to use it outside 4ht files, you need to set \catcode of : character to category 11, so it can be used in command names. \Preamble{html}...


6

First option in htlatex's second parameter must be either name of custom config file, html or xhtml. Default is html, which is used if you omit the parameter. Correct option for inline footnotes is fn-in. So your command line call should be: htlatex main.tex "xhtml,fn-in"


6

I think your example is unnecessarily complicated, this should work as well: \documentclass{report} \usepackage{hyperref} \usepackage{cleveref} \begin{document} \section{foo}\label{foo} \cref{sec:bar,sec:baz} - this won't compile but the problem is deeper rooted because cref alone doesn't work. %\protect\cref{foo} \Cref{sec:baz} ...


6

You can use \Configure{IMG}: \Preamble{xhtml} \begin{document} \Configure{IMG}{\HCode{<img class="my-class" src="}}{\HCode{" alt="}}{}{\HCode{"}}{\HCode{ />}} \EndPreamble This produces <p class="noindent" ><img class="my-class" src="./src/images/screenshot--superman.png" alt="PIC" /> </p> if you want to preserve the image ...


6

As the error message correctly shows, \columncolor is not defined by the colortbl package. It is just used as a placeholder in a modified array preamble parser so that the colour specification can be extracted and re-inserted where needed. Depending on the actual use case you can parameterise the colour used by defining a columntype or by defining a colour ...


6

Your main issue is that you can't include the TeX file in the compilation. I can't reproduce this issue, I guess that it is some issue with spaces in your file path. Anyway, once you manage to actually compile your document, you will face some issues. There are some minor issues with biblatex package and big issue with xeCJK package, which causes tex4ht ...


5

This simple example runs without errors: \documentclass{article} \makeatletter \@ifpackageloaded{tex4ht}{ \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} }{ \usepackage{fontspec} } \makeatother \usepackage[]{lettrine} \begin{document} \lettrine{É}{lisée} avait vu le pouvoir de Dieu sur la vie d'Élie. avait vu le pouvoir de Dieu sur la vie d'Élie. avait ...


5

This code relates to project which OP mentioned in the comments. I would convert files with macro definitions to sty files. So rename files macros.tex, layout.tex, etc. to macros.sty etc. In your main file, call them then with \usepackage. Thanks of that, you can then provide configuration files for tex4ht. You should rewrite some macros, to be easier for ...


5

You may try experimental fontspec support for tex4ht. There is also some documentation. I just added support for bengali language. With some modifications to your source file: \documentclass[dvipdfmx]{article} \usepackage{fontspec} \usepackage[pass,paperwidth=4in,paperheight=4in]{geometry} % %\font\serif="FreeSerif:script=beng" %\font\serifbb="...


5

htlatex loads package tex4ht via the hook \@documentclasshook that is called at the end of the document class. Thus you can test for this package after \documentclass: \documentclass[...]{...} \makeatletter \newif\ifhtlatex \@ifpackageloaded{tex4ht}{\htlatextrue}{\htlatexfalse} \makeatother Before \documentclass the macro \HCode could be checked that is ...


Only top voted, non community-wiki answers of a minimum length are eligible