Quantcast
Viewing all articles
Browse latest Browse all 73

Is there a LaTeX trick to prevent a PDF viewer from copying the line number?

A PDF output is obtained by compiling the following code.

\documentclass{article}\usepackage{xcolor}\usepackage{listings}\lstset{    language={[LaTeX]TeX},        numbers=left,        numbersep=1em,        numberstyle=\tiny,    frame=single,    framesep=\fboxsep,    framerule=\fboxrule,    rulecolor=\color{red},    xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,    xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,    breaklines=true,    basicstyle=\small\tt,    keywordstyle=\color{blue},    commentstyle=\color[rgb]{0.13,0.54,0.13},    backgroundcolor=\color{yellow!10},    tabsize=2,    columns=flexible,    morekeywords={maketitle},}\begin{document}\begin{lstlisting}\documentclass{article}\usepackage{listings}\title{Sample Document}\author{John Smith}\date{\today}\begin{document}\maketitleHello World!% This is a comment.\end{document}\end{lstlisting}\end{document}

I attempted to copy the code only inside Acrobat Reader. Unfortunately, the line numbers also got copied as shown on the following screen shot.

Image may be NSFW.
Clik here to view.
enter image description here

The line numbers are useful, but readers want not to copy them.

Is there a LaTeX trick to prevent a PDF viewer from copying the line number?


Viewing all articles
Browse latest Browse all 73

Trending Articles