使用 pdftex 編譯時,是否可以在 plainTeX 檔案中定義可點擊鏈接?據我所知,plainTeX 不支持此功能。
uj5u.com熱心網友回復:
TeX要在從( ) 檔案生成的 pdf 檔案中創建可點擊鏈接,plainTex您可以使用以下代碼:
\newif\ifpdfmode
\ifx\pdfoutput\undefined
\else
\ifnum\pdfoutput>0 \pdfmodetrue\fi
\fi
\def\url#1{%
% turn off the special meaning of ~ inside \url{}.
\begingroup\catcode`\~=12\catcode`\_=12\relax
\ifpdfmode
\pdfstartlink user{
/Subtype /Link
% w/o this you get an ugly box around the URL.
/Border [ 0 0 0 ] % radius, radius, line thickness
/A <<
/Type /Action
/S /URI
/URI (https://#1)
>>
}%
{\tt#1}%
\pdfendlink{}%
\else
%{\tt https\negthinspace:\negthinspace/\negthinspace/#1}%
{\tt#1}%
\fi
\endgroup}
您可以將其保存在一個名為lib/url.sty. 請注意,您需要注入一些 pdf 代碼,因為 TeX 本身不支持鏈接(即使您使用編譯器編譯檔案pdftex)。
url完成后,只需在代碼中使用宏即可TeX:
\input lib/url.sty
My preferred site is \url{stackoverflow.com}!
另請注意,此宏也適用于檔案未使用pdftex. 在這種情況下,條件ifpdfmode將設定為,并在輸出中插入false使用該字體格式化的純文本。\tt
您可以在這里找到一個“實時”示例:https ://github.com/madrisan/cv
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/438115.html
下一篇:如何調整陣列FPDF中的多單元格
