[NTG-context] Subject: Leading spaces verbatim

Kalouguine Andre andre.kalouguine at ens-lyon.fr
Sat Jan 28 03:01:24 CET 2023

Good day to everyone, 

I'm trying to make a verbatim block of text with copiable leading spaces
so that students can just copy my Python code snippets into their IDE. I
believe the question has been asked before (though I confess I can't
find the right search terms to find the answer again). I get that PDFs
are not the optimal way to give code to students (which is why for
longer snippets, I just give them the files or I attach them into the
PDF), but for short snippets it would be so much simpler... 

I recently stumbled onto this article:
wherein the author replaces the TeX glue with spaces and kerning. I was
wondering whether the same idea could be applied within the typing
environment but making a primitive verbatim environment using \obeylines
and \obeyspaces did not result in copiable spaces. 

Unfortunately, whilst I have some concepts of how luatex works on the
input file, the step wherein a pdf is formed is fairly misterious to me,
meaning I can't really understand the Lua code from said article

Hence, my three questions: 

 - Is it even realistic to make such a typing environment?
 - What would be the best path to do so?
 - Can someone recommend some reading material specifically about this
kind of typographical adjustments using LuaTex? Stuff like adjusting the
glyphs's position, replacing characters with combined characters etc...
Sorry if that's a bit vague, as you can see from the rest of the
message, I never really went too deep into the later stages of the TeX

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20230128/e0658704/attachment.htm>

More information about the ntg-context mailing list