我正在编写一本双语词典(德语-法语),其中包含数千个条目(词条)。每个条目的结构如下:
\hypertarget{headword}{}
\index{headword}
{\de{german}}{\fr{french}}
cf. \hyperlink{link_1}{hword_1} /
\hyperlink{link_2}{hword_2} / … /
\hyperlink{link_n}{hword_n}
[more examples etc. concerning <headword>...
see picture below: headword "Probe"]
指向link_i
字典中的另一个词条。
现在,在生成的 PDF 中使用全文搜索查找包含词条的段落,我得到了每一个实例文件中的词条。
如何实现找到仅限条目在 PDF 文件中使用文本搜索来找到词头(例如下面的“Probe”)?
梅威瑟:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\begin{document}
TEXT, with some instances of
Experiment, Probe % these instances should NOT be found by textsearch in PDF
%--- HEADWORD "Experiment", this should be found by textsearch in PDF
\hypertarget{Experiment}{}
\index{Experiment}
\begin{tabular}{p{60mm}p{60mm}}
das Experiment, e & l’expérience, expérimentation \\
cf. die \hyperlink{Probe}{Probe}
\end{tabular}
\newpage
TEXT ...
%--- HEADWORD "Probe", this should be found by textsearch in PDF
\hypertarget{Probe}{}
\index{Probe}
\begin{tabular}{p{60mm}p{60mm}}
die Probe, n & l’entraînement, la répétiton \\
cf. das \hyperlink{Experiment}{Experiment}
\end{tabular}
TEXT ...
\end{document}
答案1
PDF viewer依赖解决方案
我一直在使用accsupp
为此目的。所提出的解决方案适用于Adobe Reader、文档查看器(表明),奥克拉尔和pdf,但它不适用于福昕阅读器和PDF.js。
\documentclass[a4paper]{article}
\pagestyle{empty}
%\usepackage{luatextra}
\usepackage{accsupp}
\usepackage[colorlinks]{hyperref}
\begin{document}
\def\hideme#1{%
\BeginAccSupp{unicode,ActualText={}}%
#1%
\EndAccSupp{}%
}
\hideme{Experiment}\par
\hideme{Experiment} to hide.\par
Term\par
\hideme{Term} to hide.\par
TEXT, with some instances of
\hideme{Experiment}, \hideme{Probe}%
% these instances should NOT be found by textsearch in PDF
\bigskip\par
%--- HEADWORD "Experiment", this should be found by textsearch in PDF
\hypertarget{Experiment}{}
\index{Experiment}
\begin{tabular}{p{60mm}p{60mm}}
das Experiment, e & l’expérience, expérimentation \\
cf. die \hyperlink{Probe}{\hideme{Probe}}
\end{tabular}
%\newpage
\bigskip
TEXT ...
%--- HEADWORD "Probe", this should be found by textsearch in PDF
\hypertarget{Probe}{}
\index{Probe}
\begin{tabular}{p{60mm}p{60mm}}
die Probe, n & l’entraînement, la répétiton \\
cf. das \hyperlink{Experiment}{\hideme{Experiment}}
\end{tabular}
TEXT ...
\end{document}