8

In a dictionary a headword can consist of special characters like in this example : Eyja·fjalla··jök|ull. I would like to achieve that the user in PDF reader in PDF file can search for Eyjafjallajökull (the headword without the special characters).

0

2 Answers 2

11

Very naive, but easy to generalize. Final definition should have two parameters and take maximum of two lengths.

\documentclass[11pt]{article}          

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


\begin{document}

\newlength\eyja
\settowidth{\eyja}{Eyjafjallajökull}
In a dictionary a headword can consist of special characters like in this example
\makebox[\eyja]{\color{white}Eyjafjallajökull}\hspace{-\eyja}Eyja·fjalla··jök|ull. 
I would like to achieve that the user in PDF reader in PDF file can search for
Eyjafjallajökull (the headword without the special characters).


\end{document}         

Alas, I cannot add the resulting PDF here. Tested only under Acrobat Reader.

Updated: - Preview in Evince. Search in PDF

4
  • Works in Sumatrapdf.
    – azetina
    Dec 11, 2013 at 22:00
  • It works in Evince too. If I understand it correctly, I should set the width each time new headword appears, so the box corresponds to the width of the headword.
    – chejnik
    Dec 12, 2013 at 7:28
  • 2
    If you just want searchable and are okay with the headword being slightly off (in terms of the highlighted parts when you search), you can just use \rlap{\color{white}Original Word}Head-word-with-symbols instead of the \makebox incantation. This way you also don't need to measure the lengths. Dec 12, 2013 at 14:29
  • It does not work in Adobe Reader.
    – chejnik
    Dec 19, 2013 at 13:58
11

accsupp does allow for this:

enter image description here

\documentclass{article}
\usepackage{accsupp}% http://ctan.org/pkg/accsupp
\begin{document}
\BeginAccSupp{ActualText=Eyjafjallajokull}
Eyja$\cdot$fjalla$\cdot\cdot$j{\"o}k$\vert$ull
\EndAccSupp{}
\end{document}

While the selection might not be as expected, the search works (in Adobe Reader, at least).

2
  • 1
    Does not seem to work in Sumatrapdf.
    – azetina
    Dec 11, 2013 at 22:01
  • @azetina No, only Adobe Reader supports it, AFAIK.
    – egreg
    Dec 11, 2013 at 23:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .