4

Japanese html using htlatex [TexLive 2014 on Ubuntu 14.04]: Using pdflatex/xelatex I can generated pdf document from the latex source but I have problem generating html document.

Note: I have separate preamble for html and pdf document and html preamble is matching with sample tex.

sample.tex:

\documentclass{article}
\usepackage{import}
%\nonstopmode
\usepackage{makeidx}
\usepackage{appendix}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{enumerate}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{hyperref}
%
%\usepackage{xeCJK}
%\usepackage[TS1,T1]{fontenc}
%\usepackage{xunicode}
%\setCJKmainfont{AozoraMinchoRegular}
%\defaultfontfeatures{Mapping=tex-text} % To support LaTeX quoting style
%\defaultfontfeatures{Ligatures=TeX}
\pagenumbering{roman}
\providecommand{\tabularnewline}{\\}
\newcommand{\documentname}{マニュアル}
\title{TestHTML}
\date{\mydate{\today}}
\begin{document}
\clearpage

% -------- sections ----------------
\pagenumbering{arabic}
\setcounter{page}{1}

% end preamble
% Chapters
\documentname この章では、コマンドラインインターフェースで使用可能な機能について解説します。ユーザが使用できるオプションについて知り>たい場合は本章>を参照してください。
This section is in english.
\end{document}

config.cfg:

\Preamble{html}
%\Configure{charset}{UTF-8}
%\Configure{charset}{iso-2022-jp}
\Configure{charset}{euc-jp}
\begin{document}
\Css{
body {
  background: url(doc_preamble_html.jpg) no-repeat center center fixed;
  background-repeat:no-repeat;
  font-family:"ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro",Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
  background-attachment:fixed;
  background-position:top;
}
}
\EndPreamble

Makefile:

% !TEX program = htlatex
docs:
    mk4ht htlatex sample.tex "config.cfg, ,"fn-in",frames," "" ""
    mk4ht htlatex sample.tex "config.cfg, ,"fn-in",frames," "" ""
clean:
    -rm *.pdf *.4ct *.4tc *.aux *.css *.dvi *.html *.idv *.lg *.log *.tmp *.xref *.png *.idx *.acn *.scn *.glo *.ist *.out *.toc *.log

please help me drafting a preamble that can help me generating Japanese html document using htlatex.

  • I can not find a clean and working solution over internet. – Neeraj Oct 28 '15 at 10:04
2

You can use one of helpers4ht packages, alternative4ht. It isn't on CTAN yet, but installation is easy.

This method is described in a tutorial, your document needs only small changes:

\documentclass{article}
\usepackage{import}
\usepackage{alternative4ht}
%\nonstopmode
\usepackage{makeidx}
\usepackage{appendix}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{enumerate}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{hyperref}
%
\altusepackage{fontspec}
\altusepackage{xeCJK}
%\usepackage[TS1,T1]{fontenc}
\altusepackage{xunicode}
\setCJKmainfont{AozoraMinchoRegular}
\defaultfontfeatures{Mapping=tex-text} % To support LaTeX quoting style
\defaultfontfeatures{Ligatures=TeX}
\pagenumbering{roman}
\providecommand{\tabularnewline}{\\}
\newcommand{\documentname}{マニュアル}
\title{TestHTML}
\date{\mydate{\today}}
\begin{document}
\clearpage

% -------- sections ----------------
\pagenumbering{arabic}
\setcounter{page}{1}

% end preamble
% Chapters
\documentname この章では、コマンドラインインターフェースで使用可能な機能について解説します。ユーザが使用できるオプションについて知り>たい場合は本章>を参照してください。
This section is in english.
\end{document}

important lines are

\usepackage{alternative4ht}
...
\altusepackage{fontspec}
\altusepackage{xeCJK}
%\usepackage[TS1,T1]{fontenc}
\altusepackage{xunicode}

this will load special version of these packages, which doesn't fail under tex4ht. The config.cfg can look like:

\Preamble{html}
\begin{document}
\Css{
body {
  background: url(doc_preamble_html.jpg) no-repeat center center fixed;
  background-repeat:no-repeat;
  font-family:"ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro",Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
  background-attachment:fixed;
  background-position:top;
}
}
\EndPreamble

The file needs to be compiled with lualatex as compiler, which can be done using:

make4ht -ulc config sample.tex

make4ht is alternative build system for tex4ht, it has much more features than htlatex.

The result:

enter image description here

  • Thanks for the reply but I am getting the Error message: (/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht ! String contains an invalid utf-8 sequence. l.20360 { �}{ą} ? – Neeraj Nov 2 '15 at 10:30
  • @Neeraj you need to update your TeX distro, this error was fixed recently. Btw, it doesn't affect the output, it just stop the compilation, so it can be ignored, if you can'z update – michal.h21 Nov 2 '15 at 10:34
  • Update: updating tex distro to TeX Live 2015 resolved the error, and even with the error output was correct. Thanks Michal... – Neeraj Nov 2 '15 at 17:00

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.