1

i want to generate the code block and i try example and it work. but when i try to select the code from the pdf, the number also get selected. how to generate code block that when select the code w/o select the number? example :

Given the file testing.md as follows:

  public void update() {
    updatedAt();
    super.update();
  }

get template from JLDiaz

% Contents of listings-setup.tex
\usepackage{xcolor}

\lstset{
    basicstyle=\ttfamily,
    numbers=left,
    numberstyle=\footnotesize,
    stepnumber=2,
    numbersep=5pt,
    backgroundcolor=\color{black!10},
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    captionpos=b,
    breaklines=true,
    breakatwhitespace=true,
    breakautoindent=true,
    linewidth=\textwidth
}

Using those settings, i.e. running pandoc with options:

 pandoc test.md --listings -H listings-setup.tex -o output.pdf

you will get

1 public void update() {
2     updatedAt();
3     super.update();
4 }

i like the line number. but, i think user or like me find it annoying when copying the code with the line number especially with long code block.

how to generate code block with line number but when selecting the code w/o selecting the line number ?

  • 2
    Welcome to TeX.SX. Please give us a complete example with which we can play around. Just a few lines of listing which can be compiled by us. Like this we will have to type everything by our own in order to reproduce your error. Thanks. – LaRiFaRi Aug 6 '14 at 7:22
  • Let's take updated JLDiaz as example tex.stackexchange.com/a/179956/60277. After you generated pdf, you open and try to select the code and it will select the code with the line number. how to make w/o select the line number? – keepscoding Aug 6 '14 at 7:51
  • You can use accsup to hide the number: tex.stackexchange.com/questions/57151/…. You will have to find out yourself how to use this in pandoc. – Ulrike Fischer Aug 6 '14 at 9:03
  • yup, precisely. i know i've to do it. But, i think out there someone must have done it before. Since this problem is quite common. if not, i will have to find time to figure it out. – keepscoding Aug 6 '14 at 9:50
  • 1
    Have you tried tex.stackexchange.com/a/57143/21891? – jubobs Aug 8 '14 at 16:39

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.