6

I am recreating a 1960s manual in LaTeX. Some of my included images have part numbers that I would like to search for within the document without explicitly printing the text below the figure.

I have read Hide text from displaying but retain it selectable and searchable and like the "text rendering mode 3" method, however I do not want blank spaces existing around the image.

How does one hide searchable text behind an image/figure?

Sabrina
  • 61

3 Answers3

3

If you know the height of the text you can just print it, then enter some negative vertical space, then include the image, which will then be printed on top of the text. In the following MWE the vertical space is 1em, which is approximately the size of an uppercase M in the current font (i.e., the height of one line).

Code:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Part 1

\vspace{-1Em}
\includegraphics{example-image}

\vspace{5cm}
\begin{figure}
Part 2

\vspace{-1em}
\includegraphics{example-image-b}
\caption{Image with hidden text}
\end{figure}
\end{document}

Result, with search and highlight in the pdf viewer:

enter image description here

For a bit more sophisticated implementation of this method see https://tex.stackexchange.com/a/75104/ at the bottom of the answer or https://tex.stackexchange.com/a/75113/ from the same question.

Marijn
  • 37,699
3

Use an InfoDot.

Here is one actual size, with a paragraph of text, marked with an arrow.

infodot

At the arrowtip, above the black dot.

Zooming in (almost 9000%):

zoom

Zooming in more:

zoom some more

Image with two InfoDots, 100% magnification.

duckdot

Code

\documentclass{article}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{lipsum}
\setmainfont{Noto Serif}
\newfontface\ftsmall[Scale=0.005,Colour=blue]{Noto Serif}

\newcommand\infodota[1]{%
.\kern-1.6pt%
\begin{minipage}{0.0025\linewidth}
\baselineskip0.04pt
{\ftsmall{\tiny #1}}%
\end{minipage}}

\begin{document}
$\to$\infodota{\lipsum[5]}
\includegraphics{example-image-duck}\infodota{The quick brown fox jumps over the  lazy dog.}
\end{document}

The text is findable, and copyable.

The black dot is not really needed; it's just a visual marker to help locate the text when zooming in.

Technically, the text is not hidden (the ninja text is in plain sight), and it's definitely not behind a picture, so not an answer to the question as asked.

(Z-1000 thinking - Source idea: Appearance of \tiny or \scriptsize Fontsize in LaTeX (horizontal stretch) , based on: How to get an even smaller font?)

Cicada
  • 10,129
2

With the help of the accsupp package you can achieve the following:

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{accsupp}

\begin{document}
\lipsum[1-2]

\begin{figure}
\centering
\BeginAccSupp{ActualText=Hidden description}\includegraphics{example-image}\EndAccSupp{}%
\caption{My caption text}
\label{fig:test}
\end{figure}
\end{document}
leandriis
  • 62,593