I'm looking for a solution that will allow me to prevent some parts of the final pdf file (header, footer) from being selected and copied. It is to allow easier quoting of longer parts of texts from documents that will be published.
Asked
Active
Viewed 2,608 times
32
-
Related: http://tex.stackexchange.com/questions/18483/is-it-possible-to-provide-alternative-text-to-use-when-copying-text-from-the-pdf – krlmlr Mar 27 '12 at 13:51
1 Answers
36
Based on this answer, you could use accsupp to define a \squelch command:
\documentclass{article}
\usepackage{accsupp}
\DeclareRobustCommand\squelch[1]{%
\BeginAccSupp{method=plain,ActualText={}}#1\EndAccSupp{}}
\begin{document}
This text is selectable \squelch{but this text isn't}.
\end{document}
The squelched text cannot be highlighted in Acrobat, and copying the whole line gives this:
This text is selectable .
It's easy to combine this with fancyhdr:
\usepackage{fancyhdr}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\squelch{\thepage}}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%
}
\pagestyle{plain}
You could also define a variant \squelchstyle for use with KOMA-Script's \addtokomafont:
\def\squelchstyle{%
\BeginAccSupp{method=plain,ActualText={}}%
\aftergroup\aftersquelchstyle}
\def\aftersquelchstyle{\EndAccSupp{}}
\addtokomafont{pagenumber}{\squelchstyle}
-
-
2Redefining
\thepageto do anything other than return a page number is a really bad idea. See the answers to this question http://tex.stackexchange.com/q/3731/627 and squelch the page numbers by defining a new page style (eg with thefancyhdrpackage). – Lev Bishop Mar 31 '12 at 18:18 -
etextools seems to cause problems with biblatex, is there another way to use something like squelchstyle? – maetra Mar 31 '12 at 19:57
-
-
Is there any way to get this working with
latex -> dvips -> ps2pdf(GhostScript)? – Markus Schmassmann May 09 '12 at 19:18 -
@MarkusSchmassmann From the
accsuppmanual: "Package optiondvipsand its aliasdvipsonewrite pdfmark specials in the output. Unhappily these pdfmark operators are ignored byghostscript(latest tested version is 8.54). Perhaps they are recognized by commercial distiller applications." I can confirm thataccsuppis compatible with Acrobat Distiller 10.1. – Chel May 10 '12 at 03:28