26.9 Escape String for LATEX

Produce a string with the usual LATEX special characters escaped so that they print themselves in typewriter mode.

325⟨auxiliary subroutines 301b⟩+≡   (326)  ⊲324b
sub escapeForTTLatex {
    my($s)=@_;
    $s =~ s/\\/\\adbackslash /g;
    $s =~ s/{/\\{/g;
    $s =~ s/}/\\}/g;
    $s =~ s/_/\\_/g;
    $s =~ s/\^/\\^{}/g;
    $s =~ s/~/\\~{}/g;
    $s =~ s/%/\\%/g;
    $s =~ s/#/\\#/g;
    $s =~ s/&/\\&/g;
    return $s;
}

Defines:
escapeForTTLatex, used in chunks 304, 321, and 324a.