tex4ht,html 輸出:增加 eps 影像解析度而不影響數學影像大小

tex4ht,html 輸出:增加 eps 影像解析度而不影響數學影像大小

我有以下 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 :widthheightepstex4ht.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 來源中指定的大小無關,並且與jpgpng圖像不一致,後者在輸出中保留了width 和。如果您正在尋找heighthtml持續的解,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一致,正如我在jpgpng問題我之前有引用過。

相關內容