0

I am trying to export a TeX file to HTML. However, I am encountering problems because the resulting HTML file is just plain text without any structure or format, so it is unusable. I am using MiKTeX distribution and TeXMaker.

My code looks as follows (taken from http://www.xm1math.net/doculatex/epub.html)

\documentclass[10pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage[french]{babel}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\section{Une section}
\subsection{Une sous-section}
\lipsum[1]
\subsection{Une deuxieme sous-section}
\lipsum[2]
\end{document}

I then use "Tools">"Export via TeX4ht">"as HTML" to produce the HTML document. This goes well but when I open the HTML in any browser, it is only plain, unformatted text:

Table des matières 1 Une section 1 1.1 Une sous-section . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Une deuxieme sous-section . . . . . . . . . . . . . . . . . . . . . . 1 1 Une section 1.1 Une sous-section Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vesti- bulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et ne- tus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tel- lus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum. 1.2 Une deuxieme sous-section Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris. 1

Any ideas what is exactly going wrong here?

strpeter
  • 5,215
deca
  • 101
  • Does it work when you try on the command line? E.g., "C:\Program Files (x86)\MiKTeX 2.9\scripts\tex4ht\htlatex.bat" test.tex as in http://tex.stackexchange.com/questions/197913 ? – Marijn Mar 27 '17 at 09:43
  • how does the source code of the HTML page look like? does it contain tags, or is it just a plain text as well? – michal.h21 Mar 27 '17 at 09:52
  • @Marijn - Thanks for your reply. I now tried this. I encountered the following issues: The location you mentioned does not exist. I can only find C:\Program Files\MiKTeX 2.9\miktex\bin\x64\htlatex.exe. If I then run the code on this location, I get the message I can't find the file test.tex. – deca Mar 27 '17 at 11:40
  • @michal.h21 - Thanks for your reply. I opened the file in a text editor, and there are no tags whatsoever - only plain text. – deca Mar 27 '17 at 11:42
  • The test.tex was just an example - a bit more info: navigate to the folder where your actual file is stored (tutorial: http://www.digitalcitizen.life/command-prompt-how-use-basic-commands) and then type the command with your filename instead of test.tex. If possible, give your file a name without spaces. – Marijn Mar 27 '17 at 12:24
  • It seems like if TeXMaker didn't load tex4ht package, so no HTML tags were inserted. Could you try to put \usepackage{tex4ht} to your document preamble and compile it again? – michal.h21 Mar 27 '17 at 13:10
  • @Marijn Thanks for clarifying. I actually renamed my .tex file to test.tex, so this should be OK. I will however put the path before the file name. – deca Mar 27 '17 at 13:27
  • @michal.h21 Thanks - this indeed worked. I am just surprised that in the sample, which should show how to use the HTML export (http://www.xm1math.net/doculatex/epub.html) the package was not included in the code either. – deca Mar 27 '17 at 13:28
  • @Martin it seems to be a bug in TeXMaker, it normally doesn't need to be loaded explicitly. I think it would be best for you to compile your document from the command line using htlatex or make4ht, as @Marijin suggests – michal.h21 Mar 27 '17 at 17:20

0 Answers0