2

My goal is to create an epub file from tex (namely, an ebook with mathematical symbols).

Below is my sample code.

\documentclass[12pt,twoside,reqno]{amsart}
\linespread{1.05}
\usepackage[colorlinks=true,citecolor=blue]{hyperref}
\usepackage{mathptmx, amsmath, amssymb, amsfonts, amsthm, mathptmx, enumerate, color}
\setlength{\textheight}{23cm}
\setlength{\textwidth}{16cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\topmargin}{0cm}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{lipsum}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[T1,T5]{fontenc} \usepackage{xcolor} \usepackage[toc,page]{appendix} \usepackage{epstopdf}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\longrightrightarrow}% {\scalebox{1.75}[1.15]{$\thinspace\rightrightarrows\thinspace$}} \newcommand{\sss}{\scriptscriptstyle}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareMathOperator{\NEP}{NEP} \newcommand\mn{\addtocounter{equation}{1}\tag{\theequation}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newtheorem{definition}{Definition}[section] \newtheorem{example}{Example}[section]

\begin{document} \setcounter{page}{1}

\vspace{1.0cm} \title[Problem]% {Problem of TeX and Epub} \author[D. Example, T. Epub]% { D. Example$^{1,}$, T. Epub$^1$} % Starting Date: from November 1, 2020 \maketitle \vspace*{-0.6cm}

\begin{center} {\footnotesize {\it $^1$Laboratory }}\end{center}

\vskip 4mm {\small\noindent {\bf Abstract.} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.

\noindent {\bf Keywords.} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.

\noindent {\bf AMS Subject Classification.} }

\renewcommand{\thefootnote}{} \footnotetext{ $^*$Corresponding author. \par E-mail addresses: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. \par Received 2021. }

\begin{example}\label{example:NEP_closedness} Let us suppose a (\NEP) for (i\in {1,2}), (\lambda,\mu \in \mathbb{R}\strut^{2,+}{*}) and ((x,y)\in \mathbb{R}\strut^{2}). A function (K{i}: \mathbb{R}\strut^{+} \longrightrightarrow \mathbb{R}) is defined as \begin{align} K_{1}(\mu) = \left{x : 0 \le x \le \mu_{1} \right},\quad % % K_{2}(\mu) = \left{y : 0 \le y \le \mu_{2} \right}. \end{align} Obviously, (K_{i}(\mu)) is nonempty and (g_{i}: \mathbb{R}\strut^{2,+}{} !\times \mathbb{R}\strut^{2} \longrightarrow \mathbb{R}) defined as \begin{align} g{1}(\lambda,x,y) = h_{1}(\lambda,y) + \left{\begin{array}{cl} x^{2} - 1 & \textrm{if} 1 \le x\ 0 & \textrm{if}0 \le x < 1\ x & \textrm{otherwise} \end{array}\right. \end{align} where (h_{i}) is a lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris., for all (i). It's clear that, for (i = 1) and any ((\lambda,y)), the function (g_{1}) is Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris in (x), so is for (g_{2}) in (y). And thus, \begin{align} T_{1}(\lambda,x,y) % &= M_{g_{1}(\lambda,\cdot,y)}^{a}(x)\backslash {0} % = \big{\hat{x}\in\mathbb{R} \mid \langle \hat{x}, u - x\rangle \le 0,~ \forall u \in L_{g_{1}(\lambda,\cdot,y)}^{a}(x) \big}\backslash {0} \end{align*}

There are sequences \((\lambda_{k},\mu_{k}) \xrightarrow{\sss k\to \infty} (\lambda,\mu)\), \((x_{k},y_{k}) \xrightarrow{\sss k\to\infty} (x,y)\), then we claim
\begin{align}
\sup\limits_{x^{*}\in T_{1}(a,v,b)}
\langle P^{2r}, \bar{x} - x\rangle
%
%
\le \liminf\limits_{\scriptscriptstyle k\to \infty}
%
\sup\limits_{x_{k}^{*}\in T_{1} (d,x^{3f},m_{d})}
\langle g_{k}^{*}, \bar{r}_{k} \! - x_{k}\rangle.
\mn \label{eq:example_01}
\end{align}

\end{example}

\vskip 6mm \noindent{\bf Acknowledgments}

\noindent Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.

\begin{thebibliography}{99}%in appearance order. \bibitem{1}Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \end{thebibliography} \end{document}

From here, I use TeXstudio to compile the pdf file. It worked. Then, I use the following commands, by copying the commands to "Configure TexStudio > Build > User command", paste there and go to "Tools > User > ...".

code1: htlatex %.tex

or

code2: htlatex %.tex 'xhtml,charset=utf-8,pmathml' ' -cunihtf -utf8 -cvalidate'

to create an HTML file. Finally, I use Epub compiler to make an epub file (in my case, it's Calibre). And it also worked. But, there are some problems that I ask for help with.

  • Q1: I don't know what is the best code to do this. Because the code1 will help to compile but it sometimes took a lot of time for a long TeX file. I just wonder whether there is any better code. The code2 seems not to work without using the code1 first (to have a .lg file), but I don't know how and why. Basically, I just use the code1 only.
  • Q2: When TexStudio generates the HTML file, there are a lot of PNG files describing the formulas. How can I generate a folder to keep all these extra files with the code?
  • Q3: The inline formula (between $...$ or \(...\)) work well. But the display formula (between \[...\] or \begin{align*}...\end{align*}, etc.) don't work as expected. How can I fix this?
  • Q4: When I use {\color{red} sample text } to make colour for text and formula, the colour only affects on formula (under PNG) but not the text in HTML. How can I handle coloured text?
Marijn
  • 37,699
Nuec Tah
  • 139
  • try to compile your file from the command line using tex4ebook: tex4ebook -f epub+dvisvgm_hashes" -m draft filename.tex "svg". tex4ebook is variant of htlatex that can produce epub file directly. – michal.h21 Feb 18 '21 at 16:53

1 Answers1

2

I find out an idea for my solution as in the following article (link).

By applying the command of that, I solved the questions Q1 and Q3.

For the question Q2, there is a way to set a folder and keep all the images and extra files with -d,--output-dir. However, the system also generates the same version of those extra files in the current folder. Thus, there is no way to re-arrange the extra files except deleting manually.

For question Q4, haven't found a solution yet.

Handling subequations with make4ht

Nuec Tah
  • 139