12

I appear to have htlatex and htxelatex already installed on my computer. However when I try to run them, it comes up with the message, 'I can't write on file 'texput.log''

I am trying to convert a LaTeX file to HTML.

This is on Windows, with MiKTeX.

  • What OS and TeX distributon are you using? How are you invoking htlatex (from an editor? from the command line?) – Alan Munn Dec 27 '11 at 18:25
  • I am using Miktex 2.9 I don't know what an OS distribution is. I am clicking on the start button in the bottom left hand corner and typing in htlatex into the Search programmes and files box. When htlatex comes up I click on it and another box with a black background appears with a lot of text concluding with the statement 'I can't write on file 'texput.log'' – XYZ Dec 27 '11 at 18:39
  • TeX4ht is also included in the TeXLive a standard distribution of TeX and friends for Unix and Unix like systems. It looks like you are using Windows operating system as MiKTeX is the standard distribution of TeX and friends for Windows(even though I believe it can be installed on Linux). It appears at least on the first glance that there is some kind permission problem but I do not know anything about Windows. – Predrag Punosevac Dec 27 '11 at 21:45
  • perhaps you don't have "write permission" for the directory/folder you are working in; I would check the Properties tab to begin with. BTW, OS = Operating System. – prettygully Dec 27 '11 at 21:48
  • 1
    I'll assume that you are working on Windows, for your comments. I think that you have to invoke htlatex from the command line (the black background window). So, in order to use it you have to open a command window, by typing cmd in the same search bar. And then you can type htlatex C:\path\to\your\file\name.tex. That will create the HTML for you. – adn Dec 28 '11 at 2:54
12

This may help you. I made a batch script that I use when working with htlatex. You can copy and paste it into a file, and save it with .bat extension, e.g., html.bat.

  1. You need to open a command prompt, you can type in the search bar cmd, or press WndLogo + R and write cmd to execute the command prompt. The command prompt is an application in which you can run different commands. In the top of the window you will see the current directory. For example, C:\Windows\system32\cmd.exe. You can check this tutorial for more information.
  2. Then you just need to move to the directory in which you have your file, using cd path. For example, if you have your LaTeX documents in a folder in the C drive called My Latex, you can move to that folder using cd "C:\My Latex". Note that you have to surround the path with quotes due to the spaces on it.
  3. You can execute the script using html.bat file.tex. That will create a html directory in which you can find your file. (This assumes you have your file in the same directory as your .tex file. However, you can place the script in a folder and add that folder to your environment variables. Then you will be able to call it from anywhere.)
    • If you don't want to use the script you can simple execute htlatex file.tex html "" -dSomeDir "--interaction=nonstopmode". The html option sets the type of output, -dSomeDir sets the output directory to SomeDir (although it is not mandatory, it is a good idea as htlatex produces several files), and the nonstopmode tells the compiler not to stop if it can avoided.

The script looks like this:

@echo off
if [%1]==[] goto usage
set name=%~n1
if exist .\html goto exists
mkdir html
goto process
:exists
echo y | del .\html\*
:process

htlatex %name%.tex html "" -dhtml "--interaction=nonstopmode"

:clean
del %name%.4tc > nul
del %name%.4ct > nul
del %name%.tmp > nul
del %name%.xref > nul
del %name%.idv > nul
del %name%.lg > nul
del %name%.html > nul
del %name%.css > nul
goto end

:usage

echo Usage: %0 file.tex
echo *** Caution *** If there is a html directory it will be deleted.
echo. 
:end
  • 1
    It'd be nice if someone could provide a mac-equivalent for this script. That'd be a Unix Shell script. – Far Zin Mar 24 '14 at 9:30
  • I followed your method but I am not getting the references in the output html file. However, it is working fine when I run Latex (using texworks) to compile into pdf. I used the cmd without the batch/script file. also, the non stop interaction is not working, I manually have to hit enter several times for it to proceed – Jack Nov 23 '20 at 11:25
3

You have to open a command line window. I do not have an access to a Windows computer at the moment, so I do not know if there is a better way to do it, but I seem to remember that if you click on Start, then navigate to the Programs menu (the way to do it seems to depend on your Windows version), then under Accessories there is something like "DOS Prompt" or "Command Prompt". When the command prompt window opens, you have to change to the directory (or folder) that contains your file (cd "\Documents And Something\XYZ's Documents\whatever\folder\it\is\in"), and run htlatex myfile.tex. That will work if htlatex is in your PATH. If it is not, you have to type the full path to htlatex instead, something like

"C:\the\full path\to\htlatex.exe" myfile.tex

Hopefully someone with better knowledge of Windows will be able to edit this or provide a better answer.

1
  1. Given below are 3 bat files, 3 cfg files and one tco file.
  2. Copy *.bat files to C:\Program Files\MiKTeX 2.9\scripts\tex4ht\ folder.
  3. Copy *.cfg files to C:\Program Files\MiKTeX 2.9\tex\latex\base\cfg\ folder.
  4. Note that you may have to create tex4ht and cfg folders.
  5. Use MiKTeX Settings(Admin) and Refresh FNDB
  6. Go to TeXnicCenter -> Build -> Define Output Profiles -> Import tex4ht.tco
  7. Three (3) new output profiles will be created in TeXnicCenter
  8. LaTeX=>HTML2 and LaTeX=>MathJax profiles create *.html output files: LaTeX=>MathML profile creates *.xml output file.
  9. Kindly improve the above by incorporating the code for pstricks and tikz.

latex2html.bat

REM @echo off
REM - windows batch file for converting latex to html
cd "%1"
htlatex %2 "html,mathml-"
@echo "Process Ended"

latex2mathjax.bat

REM @echo off
REM - windows batch file for converting latex to html using MathJax
cd "%1"
htlatex %2 "ht5mathjax,charset=utf-8,NoFonts" " -cunihtf -utf8"
@echo "Process Ended"

latex2mathml.bat

REM @echo off
REM - windows batch file for converting latex to xml
cd "%1"
mk4ht mzlatex %2 "html,pmathml,charset=utf-8,NoFonts" " -cunihtf -utf8"
@echo "Process Ended"

ht5mathjax.cfg

\Preamble{xhtml,mathml}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
         rel="stylesheet" type="text/css"
         href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\Configure{@HEAD}{\HCode{<script type="text/javascript"\Hnewline
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
\Configure{@HEAD}{\HCode{<style type="text/css">\Hnewline
  .MathJax_MathML {text-indent: 0;}\Hnewline
</style>\Hnewline}}
\begin{document}
\EndPreamble

% From Michal Hoftich <michal.h21@gmail.com> on 2 Aug 2012
% by email with cc to tex4ht@tug.org
% Hoftich suggests the name mathjax.cfg
% His suggested command line:
%   htlatex 1109.1881v2.tex "ht5mathjax, charset=utf-8,NoFonts" " -cunihtf -utf8"
%   to produce html file
% Mods by William F. Hammond
% mk4ht mzlatex $1 "ht5mathjax"

html.cfg

Preamble{xhtml}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
         rel="stylesheet" type="text/css"
         href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\begin{document}
\EndPreamble

xhtml.cfg

\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
         rel="stylesheet" type="text/css"
         href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\begin{document}
\EndPreamble

tex4ht.tco

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<txcop:outputProfiles version="2" xmlns:txcop="http://schemas.ToolsCenter.org/TeXnicCenter/OutputProfiles.xsd">
    <outputProfileList>
        <outputProfile name="LaTeX=&gt;MathJax" stopOnLatexError="false">
            <texCommand execute="false" path="" arguments=""/>
            <bibTexCommand execute="false" path="" arguments=""/>
            <makeIndexCommand execute="false" path="" arguments=""/>
            <preProcessors/>
            <postProcessors>
                <processor name="latex2mathjax" path="latex2mathjax.bat" arguments="&quot;%dm&quot; %nm" inputFile="" outputFile=""/>
            </postProcessors>
            <viewer path="firefox.exe" closeBeforeCompilation="false">
                <viewProjectCommand type="commandLine">
                    <commandLineCommand path="firefox.exe" arguments="%bm.html"/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewProjectCommand>
                <viewCurrentFileCommand type="commandLine">
                    <commandLineCommand path="firefox.exe" arguments=""/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewCurrentFileCommand>
                <viewCloseCommand type="commandLine">
                    <commandLineCommand path="" arguments=""/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewCloseCommand>
            </viewer>
        </outputProfile>
        <outputProfile name="LaTeX=&gt;HTML2" stopOnLatexError="false">
            <texCommand execute="false" path="" arguments=""/>
            <bibTexCommand execute="false" path="" arguments=""/>
            <makeIndexCommand execute="false" path="" arguments=""/>
            <preProcessors/>
            <postProcessors>
                <processor name="latex2html batch file" path="latex2html.bat" arguments="&quot;%dm&quot; %nm" inputFile="" outputFile=""/>
            </postProcessors>
            <viewer path="firefox.exe&quot;" closeBeforeCompilation="false">
                <viewProjectCommand type="commandLine">
                    <commandLineCommand path="firefox.exe&quot;" arguments="%bm.html"/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewProjectCommand>
                <viewCurrentFileCommand type="commandLine">
                    <commandLineCommand path="firefox.exe&quot;" arguments=""/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewCurrentFileCommand>
                <viewCloseCommand type="commandLine">
                    <commandLineCommand path="" arguments=""/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewCloseCommand>
            </viewer>
        </outputProfile>
        <outputProfile name="LaTeX =&gt; MathML" stopOnLatexError="false">
            <texCommand execute="false" path="htlatex.exe " arguments="%bm.tex &quot;html,mathplayer&quot;"/>
            <bibTexCommand execute="false" path="" arguments=""/>
            <makeIndexCommand execute="false" path="" arguments=""/>
            <preProcessors/>
            <postProcessors>
                <processor name="latex2mathml" path="latex2mathml.bat" arguments="&quot;%dm&quot; %nm" inputFile="" outputFile=""/>
            </postProcessors>
            <viewer path="firefox.exe" closeBeforeCompilation="false">
                <viewProjectCommand type="commandLine">
                    <commandLineCommand path="firefox.exe" arguments="%bm.xml"/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewProjectCommand>
                <viewCurrentFileCommand type="commandLine">
                    <commandLineCommand path="firefox.exe" arguments=""/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewCurrentFileCommand>
                <viewCloseCommand type="commandLine">
                    <commandLineCommand path="" arguments=""/>
                    <ddeCommand path="" server="" topic="System" command=""/>
                </viewCloseCommand>
            </viewer>
        </outputProfile>
    </outputProfileList>
</txcop:outputProfiles>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.