1

In order to avoid the selection of a part of a pdf, I use this command:

\usepackage{accsupp}
\DeclareRobustCommand\squelch[1]{%
    \BeginAccSupp{method=plain,ActualText={}}#1\EndAccSupp{}}

For elements in the same page it works, but for elements that are in 2 or more pages, only those that are in the first page are unselectable.

\documentclass{article}
\usepackage{accsupp}
\DeclareRobustCommand\squelch[1]{%
    \BeginAccSupp{method=plain,ActualText={}}#1\EndAccSupp{}}

\begin{document}
    \squelch{
    \section{Sec}
    \paragraph{Par}
    \newpage
    \paragraph{par}
}
\end{document}

How can I improve the \squelch function?

  • 1
    That's not possible with pdflatex -_the accsupp must be closed on the current page. With lualatex it could be possible. – Ulrike Fischer Feb 27 at 15:09
  • Is there a way to achieve what I want using a different package? – ScTALE Feb 27 at 17:15
  • no, not with pdflatex. Be aware that your example above creates an invalid pdf, preflight complains about the unclosed operators on the two pages. – Ulrike Fischer Feb 27 at 17:18
  • You might be able to do something with the atbegshi package (named after the command AtBeginShipout), which hooks to the event that LaTeX completes the current page (i.e., 'shipout'). With this you could insert code to end the pdf marked content operator and immediately start a new one on the next page. You would also need manually implement the operator at the start and end of your to-be-squelched fragment, which could be in the middle of the page [...] – Marijn Feb 28 at 10:13
  • [...] and to keep a switch to see if you are inside a fragment or not. Basically you would be reimplementing accsupp, which would be a big task, and it might not even work in the end. You could try to file a feature request for the package to include multi-page functionality - or decide that (non-)selectability is not so important after all. – Marijn Feb 28 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.