
我有以下 MWE:
\documentclass{book}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
Lorem ipsum dolor sit amet, \(k_\delta=\frac{3 \mathit{EJ}}{l^3}\) consectetur:
\begin{equation*}k_\delta=\frac{3 \mathit{EJ}}{l^3}\end{equation*}
\begin{centering}
\includegraphics[width=0.5\textwidth]{myimage.eps}
\end{centering}
\end{document}
可以很好地編譯html
(在htlatex example.tex "myconfig, xhtml, charset=utf-8" " -cunihtf -utf8"
Ubuntu TeXLive 下),myconfig.cfg
\Preamble{xhtml}
\Configure{graphics*}
{jpg}
{\Picture[pict]{\csname Gin@base\endcsname .jpg
\space width="\expandafter\the\csname Gin@req@width\endcsname"}}
\Configure{graphics*}
{png}
{\Picture[pict]{\csname Gin@base\endcsname .png
\space width="\expandafter\the\csname Gin@req@width\endcsname"}}
\begin{document}
\EndPreamble
尋找解決方法未解決的問題由於輸出中圖像尺寸較小html
,我編寫了一個 Python 腳本來解析所有圖像的源代碼和html
雙倍圖像,但遇到了一個新問題,即「雙倍」圖像品質差。所以我嘗試將,部分中的密度從 110x110 增加到 220x220 :width
height
eps
tex4ht.env
<convert>
Gconvert -trim +repage -density 220x220 -transparent '#FFFFFF' zz%%4.ps %%3
這實際上提高了圖像的分辨率eps
,因此現在我可以html
使用 Python 腳本將原始程式碼中的圖像大小加倍,但也增加了尺寸數學公式圖像(其大小不受我的 Python 腳本影響,因為它們既不保存width
也不包含height
屬性)。
有沒有辦法eps
在不影響數學影像大小的情況下提高影像解析度?
html
以下是數學公式大小加倍的輸出螢幕截圖:
答案1
看來我自己找到解決方法了。我將更改回滾到tex4ht.env
,以便呈現為圖像的數學公式現在是安全的,並且我將以下部分添加到上述序言中myconfig.cfg
:
\Configure{graphics*}
{eps}
{\Needs{"convert -density 110x110 \csname Gin@base\endcsname.eps \csname Gin@base\endcsname.png"}
\Picture[pict]{\csname Gin@base\endcsname.png}}
這種方式eps
圖像以不同的方式管理(dvi
程式碼被繞過,如上所述這裡),因此現在它們在來源width
中缺少屬性;html
然而,這種缺乏完全沒問題,因為現在eps
圖像在html
輸出中看起來更大,它們的大小令人滿意,並且不需要透過我的後製 Python 腳本「外部」放大。
這是解決方案後原始範例的螢幕截圖:
跟進
我實際上發現,雖然上述解決方案能夠放大eps
圖像,但它們的大小與 LaTeX 來源中指定的大小無關,並且與jpg
和png
圖像不一致,後者在輸出中保留了width
和。如果您正在尋找height
html
持續的解,eps
的部分myconfig.cfg
應該是
\Configure{graphics*}
{eps}
{\Needs{"convert -density 110x110 \csname Gin@base\endcsname.eps \csname Gin@base\endcsname.png"}
\Picture[pict]{\csname Gin@base\endcsname.png
\space width="\expandafter\the\csname Gin@req@width\endcsname"}}
這種方式width
和輸出height
中的屬性html
也保留在圖像中,並且它們的大小與圖像eps
一致,正如我在jpg
png
問題我之前有引用過。