使用 \href 无法在 pdf 上呈现

使用 \href 无法在 pdf 上呈现

我正在尝试使用 LaTex 中的 href 包在简历中创建指向我的 GitHub 的可点击链接。我相信我使用得正确,但标签仍然无法点击。

作为背景,我正在使用 WSL 并创建 .dvi 文件,然后将其转换为 .pdf。为了让 .dvi 文件正常工作,我必须将 Yap(.dvi 查看器)的“视图”选项卡下的“渲染方法”更改为“dvips”。

代码示例:

\documentclass{article}
\usepackage[unicode]{hyperref}

\begin{document}

\title{Test}
\author{Me}

\maketitle

\href{https://github.com/stevend-15}{github.com/stevend-15}

\end{document}

然后我运行,latex test_href.tex得到以下输出:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./test_href.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/pdftexcmds/pdftexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/infwarerr/infwarerr.sty))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty)
(/usr/share/texlive/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty)
(/usr/share/texlive/texmf-dist/tex/generic/pdfescape/pdfescape.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hycolor/hycolor.sty)
(/usr/share/texlive/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty)
(/usr/share/texlive/texmf-dist/tex/latex/auxhook/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/kvoptions/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/generic/intcalc/intcalc.sty)
(/usr/share/texlive/texmf-dist/tex/generic/etexcmds/etexcmds.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty)
(/usr/share/texlive/texmf-dist/tex/generic/bitset/bitset.sty
(/usr/share/texlive/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty))
(/usr/share/texlive/texmf-dist/tex/generic/atbegshi/atbegshi.sty))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hdvips.def
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pdfmark.def
(/usr/share/texlive/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
(/usr/share/texlive/texmf-dist/tex/latex/atveryend/atveryend.sty)
(/usr/share/texlive/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty))))
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)
No file test_href.aux.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/latex/refcount/refcount.sty)
(/usr/share/texlive/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty))

Package hyperref Warning: Rerun to get /PageLabels entry.

[1] (./test_href.aux)

Package rerunfilecheck Warning: File `test_href.out' has changed.
(rerunfilecheck)                Rerun to get outlines right
(rerunfilecheck)                or use package `bookmark'.

 )
Output written on test_href.dvi (1 page, 2684 bytes).
Transcript written on test_href.log.

然后我运行dvipdfm test_href.dvi几次,输出以下内容:

test_href.dvi -> test_href.pdf
[1
xdvipdfmx:warning: Unparsed material at end of special ignored.

Current input buffer is -->! systemdict /pdfmark known{userdict /?pdfmark sys...<--

xdvipdfmx:warning: Unknown token "SDict"
xdvipdfmx:warning: Interpreting PS code failed!!! Output might be broken!!!
xdvipdfmx:warning: Interpreting special command ps: (ps:) failed.
xdvipdfmx:warning: >> at page="1" position="(72, 720)" (in PDF)
xdvipdfmx:warning: >> xxx "ps:SDict begin [/Producer (dvips + Distiller)/Title ()/Subje..."
xdvipdfmx:warning: >> Reading special command stopped around >>begin [/Producer (dvips + Distiller)/Title ()/Subject ()/Cre...<<
xdvipdfmx:warning: Unparsed material at end of special ignored.

Current input buffer is -->! /DvipsToPDF{72.27 mul Resolution div} def/PDFToD...<--

xdvipdfmx:warning: Unknown token "SDict"
xdvipdfmx:warning: Interpreting PS code failed!!! Output might be broken!!!
xdvipdfmx:warning: Interpreting special command ps: (ps:) failed.
xdvipdfmx:warning: >> at page="1" position="(72, 720)" (in PDF)
xdvipdfmx:warning: >> xxx "ps:SDict begin /product where{pop product(Distiller)search{p..."
xdvipdfmx:warning: >> Reading special command stopped around >>begin /product where{pop product(Distiller)search{pop pop po...<<
xdvipdfmx:warning: Unknown token "SDict"
xdvipdfmx:warning: Interpreting PS code failed!!! Output might be broken!!!
xdvipdfmx:warning: Interpreting special command ps: (ps:) failed.
xdvipdfmx:warning: >> at page="1" position="(132.768, 705.06)" (in PDF)
xdvipdfmx:warning: >> xxx "ps:SDict begin H.S end"
xdvipdfmx:warning: >> Reading special command stopped around >>begin H.S end<<
xdvipdfmx:warning: Unknown token "SDict"
xdvipdfmx:warning: Interpreting PS code failed!!! Output might be broken!!!
xdvipdfmx:warning: Interpreting special command ps: (ps:) failed.
xdvipdfmx:warning: >> at page="1" position="(132.768, 705.06)" (in PDF)
xdvipdfmx:warning: >> xxx "ps:SDict begin H.R end"
xdvipdfmx:warning: >> Reading special command stopped around >>begin H.R end<<
xdvipdfmx:warning: Unknown token "SDict"
xdvipdfmx:warning: Interpreting PS code failed!!! Output might be broken!!!
xdvipdfmx:warning: Interpreting special command ps: (ps:) failed.
xdvipdfmx:warning: >> at page="1" position="(132.768, 705.06)" (in PDF)
xdvipdfmx:warning: >> xxx "ps:SDict begin [/View [/XYZ H.V]/Dest (page.1) cvn /DEST pdf..."
xdvipdfmx:warning: >> Reading special command stopped around >>begin [/View [/XYZ H.V]/Dest (page.1) cvn /DEST pdfmark end<<

但一秒钟后它就停止了,并给我这个 .pdf(显示为图像):在此处输入图片描述

不幸的是,该标签不可点击。

任何帮助都将不胜感激。

谢谢

答案1

正如你在日志中看到的,hyperref 正在加载 dvips 的代码:

/usr/share/texlive/texmf-dist/tex/latex/hyperref/hdvips.def

而 (x)dvipdfmx 不喜欢这样。

传递正确的选项(dvipdfm也可以):

\documentclass{article}
\usepackage[dvipdfmx,unicode]{hyperref}

\begin{document}

\title{Test}
\author{Me}

\maketitle

\href{https://github.com/stevend-15}{github.com/stevend-15}

\end{document}

然后 hyperref 将会加载/tex/latex/hyperref/hdvipdfm.def并且链接将起作用。

相关内容