[texhax] [solved] Re: Issue about `~' character
David Carlisle
d.p.carlisle at gmail.com
Fri Sep 30 21:01:53 CEST 2016
On 30 September 2016 at 19:31, Rodolfo Medina <rodolfo.medina at gmail.com> wrote:
> David Carlisle <d.p.carlisle at gmail.com> writes:
>
>> Your question is very unclear.
>>
>> you say you can not use \string~ as it occurs within a \write
>> but \string~ will work within a write and cause ~ to be written as itself
>> as a ~ to the file.
>
> Yes, apologises. That was because I needed to repeat `\string' more than
> once. I had tried with `\string\string~' but it didn't work either.
>
>
>
>> If you are inputting that file back to TeX then you also need to make
>> that ~ that you
>> read back in to be inert there are various ways to do that, depending
>> what you are doing
>> you could for instance do
>>
>> \write\wherever{\string\string\string~}
>>
>> which will write
>>
>> \string~
>>
>> to the file which if \input back will produce
>>
>> ~
>
>
> Fantastic, that works in my case. In this case you need three \string s. I
> couldn't imagine. I had tried with two.
don't think of it as three \string, its, just two tokens each preceded
by \string so it gets written verbatim.
You want your input file to have
\string
~
so to write that you can put \string before each token
\sting\string
\string~
so it just more or less coincidentally ends up with three adjacent \string
>
> Thanks,
>
> Rodolfo
>
latex since the start has had a macro \protect which (when needed) is
defined to be
\noexpand\protect\noexpand which would also work here (and has the
advantage that it survives any number of writing/reading cycles until
you redefine \protect to finally let ~ expand
David
More information about the texhax
mailing list