tex4ht 中 hyperref 外观控制不一致

tex4ht 中 hyperref 外观控制不一致

使用\hypersetup{}\usepackage[tex4ht]{hyperref}如下面的 MWE 所示),我尝试格式化链接的超链接(例如词汇表条目),以使它们不那么引人注目。

在两台不同的计算机上(我原以为它们有相同的MiKTeX2.9安装,并且软件包都是最新的)却产生了不同的结果......

  • 在一台电脑上,尽管citecolor设置了如下所示的选项,但我还是看到带蓝色下划线的超链接
  • 在另一台计算机上,我看到格式良好的黑色文本,没有下划线,但是当您将鼠标悬停在隐藏的超链接上时,鼠标会发生变化,从而跳转到词汇表、参考资料等。
  • Internet Explorer我已经在、opera和上测试了这台计算机特定但一致的格式外观google chrome
  • xelatex在任意一台计算机上生成 pdf 都没有问题。

由于我认为这不是一个代码问题,所以我希望能够从任何可能了解底层系统要求或任何可能干扰的专家那里获得一些建议:

  1. 我是否可能有一个已安装但未使用的与\hypersetup{}
  2. 是否存在字体库或 html dll,它们在不同的 Windows 安装中可能会有所不同,从而提供不同的指令?
  3. 我不太了解 html,所以我愿意接受建议。

平均能量损失

\documentclass{article}
\usepackage[utf8]{inputenc}
%=========================================================================================================================================
% PACKAGES REQUIRED FOR HYPERLINKS AND HYPER-REFERENCES
%=========================================================================================================================================
    \usepackage{csquotes}
    \usepackage{url}
    \usepackage[nottoc]{tocbibind}
    \usepackage{bookmark}
    %http://tex.stackexchange.com/questions/214718/override-scshape-in-fancyhdr
    %\RequirePackage[overload]{textcase} %keeps all math in the heading lowercase  
    %\RequirePackage{linegoal}

    %http://tex.stackexchange.com/questions/42927/converting-from-latex-to-html-using-htlatex
    \ifdefined\HCode
        \usepackage[tex4ht]{hyperref}
        \hypersetup{
            hypertexnames=false,
            colorlinks=true,       % false: boxed links; true: colored links
            linkcolor=black,          % color of internal links (change box color with linkbordercolor)
            citecolor=black,        % color of links to bibliography
            filecolor=black,      % color of file links
            urlcolor=black          % color of external links
        }
    \else
        \usepackage{hyperref}   %\usepackage{hyperref}
        \hypersetup{
            hypertexnames=false,
            %bookmarks=false,         % show bookmarks bar?
            unicode=true,          % non-Latin characters in Acrobat's bookmarks
            pdftoolbar=true,        % show Acrobat's toolbar?
            pdfmenubar=true,        % show Acrobat's menu?
            pdffitwindow=true,     % window fit to page when opened
            pdfstartview={FitV},    % fits the height of the page to the window:  or fits the width of the page to the window  FitH
            pdftitle={My title},    % title
            pdfauthor={Author},     % author
            pdfsubject={Subject},   % subject of the document
            pdfcreator={Creator},   % creator of the document
            pdfproducer={Producer}, % producer of the document
            pdfkeywords={keyword1} {key2} {key3}, % list of keywords
            pdfnewwindow=true,      % links in new window
            colorlinks=true,       % false: boxed links; true: colored links
            linkcolor=black,          % color of internal links (change box color with linkbordercolor)
            citecolor=black,        % color of links to bibliography
            filecolor=black,      % color of file links
            urlcolor=black          % color of external links
        }
    \fi


    \bookmarksetup{
        numbered,
        open
    }

    \usepackage[noabbrev]{cleveref}
    %\AtEndPreamble{\RequirePackage[noabbrev]{cleveref}}
    %\AtBeginDocument{\RequirePackage[noabbrev]{cleveref}}  % this package must be one of the last packages loaded - certainly put it after hyperref

%
%_________________________________________________________________________________________________________________________________________
\setlength\parindent{0pt}

%=========================================================================================================================================
% PACKAGES REQUIRED FOR GLOSSARIES
%=========================================================================================================================================

% Glossaries must be loaded before amsmath as per details in the following forum answer
% http://tex.stackexchange.com/questions/85696/what-causes-this-strange-interaction-between--and-amsmath
\usepackage[nogroupskip,toc,acronym]{glossaries} % must come after href   
\usepackage{scrwfile}%http://www.dickimaw-books.com/cgi-bin/faq.cgi?action=view&categorylabel=glossaries#glsnewwriteexceeded

\makeglossaries

\newglossaryentry{ICPMS}{ type={acronym}, sort={inductively coupled plasma-mass spectrometry},  name={ICPMS}, short={ICPMS}, long={inductively coupled plasma-mass spectrometry}, first={inductively coupled plasma-mass spectrometry (ICPMS)}, description={inductively coupled plasma mass spectrometry} }

\begin{document}

    \begin{itemize}
        \item \gls{ICPMS}
        \item this term is fully expanded and summarized on first use which displays \gls{ICPMS}
        \item I expected these hyperlinks to be invisible - not blue with underlines...
    \end{itemize}

\end{document} 

答案1

所有计算机上的结果应该相同。glossaries软件包确实有自己的配置,并且在使用 编译时根本tex4ht不使用。但即使由 生成的链接似乎也不支持颜色,您可以使用简单示例进行测试:hyperreftex4hthyperref

\href{http://tex.stackexchange.com}{TeX.sx}
\url{http://tex.stackexchange.com}

结果是:

<a 
href="http://tex.stackexchange.com" >TeX.sx</a> <a 
href="http://tex.stackexchange.com" class="url" ><span 
class="cmtt-10">http://tex.stackexchange.com</span></a>

so\href命令生成普通<a>元素,\url生成<a>带有url类的元素和<span>带有字体格式的元素。css文件中没有color属性,因此从技术上讲不可能\hypersetup使用 中的任何颜色声明。此外,无论您使用\usepackage{hyperref}和,都会产生完全相同的输出\usepackage[tex4ht]{hyperref}

%     \ifdefined\HCode
%         \usepackage[tex4ht]{hyperref}
%         \hypersetup{
%             hypertexnames=false,
%             colorlinks=true,       % false: boxed links; true: colored links
%             linkcolor=black,          % color of internal links (change box color with linkbordercolor)
%             citecolor=black,        % color of links to bibliography
%             filecolor=black,      % color of file links
%             urlcolor=black          % color of external links
%         }
%     \else
        \usepackage{hyperref}   %\usepackage{hyperref}
        \hypersetup{
            hypertexnames=false,
            %bookmarks=false,         % show bookmarks bar?
            unicode=true,          % non-Latin characters in Acrobat's bookmarks
            pdftoolbar=true,        % show Acrobat's toolbar?
            pdfmenubar=true,        % show Acrobat's menu?
            pdffitwindow=true,     % window fit to page when opened
            pdfstartview={FitV},    % fits the height of the page to the window:  or fits the width of the page to the window  FitH
            pdftitle={My title},    % title
            pdfauthor={Author},     % author
            pdfsubject={Subject},   % subject of the document
            pdfcreator={Creator},   % creator of the document
            pdfproducer={Producer}, % producer of the document
            pdfkeywords={keyword1} {key2} {key3}, % list of keywords
            pdfnewwindow=true,      % links in new window
            colorlinks=true,       % false: boxed links; true: colored links
            linkcolor=black,          % color of internal links (change box color with linkbordercolor)
            citecolor=black,        % color of links to bibliography
            filecolor=black,      % color of file links
            urlcolor=black          % color of external links
        }
%    \fi

所以你可以删除所有\ifdefined\HCode ... \else ... \fi内容。相反,在你的文件中添加一些\Css命令:.cfg

\Css{a{color:black;}}
\Css{a:visited{color:black;}}
\Css{a:hover{color:\#888;}}

在此处输入图片描述

相关内容