0

Is there a way to make symbols, written by using the function $$, in LaTeX look like something in the pdf document, but different if you copy-paste it?

Here is an example of what I would like:
Something like this in my code: For water $\rho$ is 997 $kg/m^3$
In the pdf document: For water ρ is 997 kg/m³
When you copy-paste: For water the density is 997 kilograms per cubic meter

(I asked a similar question some days ago and got some good answers. I was told to use ‘accsupp’, however, I can’t get it to work when using $$)

(added after i first asked the question:) I have been asked for an example of my problem, here it comes. My code is:

\documentclass{article} \
\usepackage{accsupp}

\newcommand\km{\BeginAccSupp{ActualText={kilometers}}km \EndAccSupp{}}
\newcommand\km{\BeginAccSupp{ActualText={density}} $\rho$ \EndAccSupp{}}

\begin{document}
\km % when you make a PDF file, and copy-paste this part it will give you 'kilometers' and not 'km'

\ $\rho$ % a bad try to do the same for '$\rho$' as for 'km'
\end{document}

Juan Castaño
  • 28,426
Kevin
  • 73
  • 4

1 Answers1

0

I have solved it, and maybe I have just been stupid not to see what to do. Here is the answer:

\documentclass{article} \
\usepackage{accsupp}

\newcommand\km{\BeginAccSupp{ActualText={kilometers}}km \EndAccSupp{}}
\newcommand\rhox{\BeginAccSupp{ActualText={density}} $\rho$ \EndAccSupp{}}

\begin{document}
\km % when you make a PDF file, and copy-paste this part it will give you 'kilometers' and not 'km'

\rhox is ... % it works now

\end{document}

Kevin
  • 73
  • 4