从 pdf 复制 ccaron 时出现 Times 字体问题

从 pdf 复制 ccaron 时出现 Times 字体问题

pdflatex 生成的 pdf 存在问题

\documentclass{article}
\renewcommand{\rmdefault}{ptm}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\input glyphtounicode
\pdfgentounicode=1

\begin{document}
\v{c}\char"A3
\end{document}

当我使用 Acrobat Reader 从 pdf 复制 čč 时,我得到的是 ˇcˇc。但是当我不选择时间时,即编译

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\input glyphtounicode
\pdfgentounicode=1

\begin{document}
\v{c}\char"A3
\end{document}

pdflatex 将使用 cm-super 包中的默认字体 SFRM1000,当我从 pdf 复制 čč 时,我得到 čč (这正是我所期望的)。

您知道如何解决这个问题或者为什么会发生这种情况吗?

附言:我也提交了此文件https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/4502一段时间前,但我还没有收到任何回复。

答案1

在这里,我使用包在字体中accsupp排版,但用 Unicode 替代PDF 中的可复制替换文本。我将其放在宏中。\v{c}ptm010D\vc

以下是 MWE:

\documentclass{article}
\renewcommand{\rmdefault}{ptm}
\usepackage{accsupp}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\input glyphtounicode
\pdfgentounicode=1
\newcommand\vc{%
  \BeginAccSupp{method=hex,unicode,ActualText=010D}%
    \v{c}%
  \EndAccSupp{}%
}
\begin{document}
\v{c} and \char"A3 \ are not copyable, but
\vc{} is copyable.

{\sffamily \v{c} and \char"A3 \ are sans, and so is
\vc.}

\end{document}

在此处输入图片描述

复制/粘贴该文档后,结果如下:

ˇc and ˇc are not copyable, but č is copyable.
č and č are sans, and so is č.

然而,正如 Ulrike 所指出的,“这种方法会影响字距调整和连字”,因为插入了 pdfliterals。此外,这种方法的成功取决于特定查看器是否支持“actualtext”。就我而言,我使用 Adob​​e 进行查看和复制/粘贴,它确实支持该功能。

如果需要对多个卡龙字符使用此技术,我建议使用这样的技术,其中重新定义为使用为所有需要的卡龙字符创建的支持宏。在这里,我使用 č 和 ě 演示了这一点,为此创建了\v支持宏\vc和:\ve

\documentclass{article}
\renewcommand{\rmdefault}{ptm}
\usepackage{accsupp}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\input glyphtounicode
\pdfgentounicode=1
\let\svv\v
\newcommand\vc{%
  \BeginAccSupp{method=hex,unicode,ActualText=010D}%
    \svv{c}%
  \EndAccSupp{}%
}
\newcommand\ve{%
  \BeginAccSupp{method=hex,unicode,ActualText=011B}%
    \svv{e}%
  \EndAccSupp{}%
}
\renewcommand\v[1]{\ifcsname v#1\endcsname
  \csname v#1\endcsname\else\svv{#1}\fi}
\begin{document}
\v{c} is now copyable.

So is \v{e} but not \v{a}.
\end{document}

在此处输入图片描述

复制/粘贴结果:

č is now copyable.
So is ě but not ˇa.

相关内容