Skip to content

Copying and pasting identifiers in PDF output #21

@texdraft

Description

@texdraft

As is decently well known, plain TeX's “underscore” character is actually

{\leavevmode \kern.06em \vbox{\hrule width.3em}}

It looks nice enough, but when copying and pasting text that has an underscore, it turns into a space. The usual way to fix this is to mess with text encoding, and I figured dealing with that would not be worth the trouble. However, I recently found out about a PDF feature called ActualText that allows specifying alternative text for an element of the page. See for example this question on TeX.SE.

Not only could this be used for making underscores copy as underscores, but it could also be used for identifiers formatted as Tex, since they could render completely differently from how they appear in the C source code. Whether it would be worth doing for characters like ∧ and ¬ (to make them copy as && and !) is up for debate.

Is this capability something that belongs in CWEB, perhaps as an option (so that extra TeX would not be output if PDF is not the target)? Would it be desirable? If so, then I will implement it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions