TransWikia.com

How to print spaces and tabs as spaces and tabs in 'lstlisting's?

TeX - LaTeX Asked on November 18, 2021

Consider the following:


begin{lstlisting}
int main(void)
{
  printf("hello world");
  return 0;
}
end{lstlisting}

enter image description here

[Note: the text is not actually rendered blue, I just tried to select it in the PDF — end note]


Does anyone know how to keep the tabs & whitespaces as tabs & whitespaces ? So that when trying to select the listing in the PDF, it selects the tabs and spaces and I can copy paste it without having to re-tab and re-space everything in my editor ?

Also not replace the spaces and tabs with that weird looking underscore spaces and tab pretender character. Just replace it with actual space and tab or even just space would be fine?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP