[prev in list] [next in list] [prev in thread] [next in thread]
List: lyx-users
Subject: Re: Automagically reduce the spacing between "++" in the word "C++"
From: Andre Poenitz <andre.poenitz () mathematik ! tu-chemnitz ! de>
Date: 2008-10-22 22:00:49
Message-ID: 20081022220048.GC5391 () tu-chemnitz ! de
[Download RAW message or body]
On Wed, Oct 22, 2008 at 05:44:58PM -0400, rgheck wrote:
> Andre Poenitz wrote:
>> On Wed, Oct 22, 2008 at 09:22:35PM +0200, Andre Poenitz wrote:
>>
>>>> I think that I remember to have read about so-called catcodes (or
>>>> whatever?) in TeX, which apparently make it possible to declare
>>>> certain characters as "active" so that further processing is
>>>> possible whenever the TeX scanner reads such character. I wonder if
>>>> it is possible this way to declare in the preamble that
>>>> "C" followed by "+", followed by "+"
>>>> is "active" and should be inherently substituted with something
>>>> like "\mbox{C+\hspace{-.5ex}+}}"
>>>>
>>> Quick shot: [...]
>>>
>>
>> Somewhat improved version:
>>
>> \def\plus{+}
>> \catcode`\+=\active
>>
>> \def\smallplusplus#1{\raisebox{0.6ex}{\tiny\plus\kern-.3ex\plus}}
>> \def+{\futurelet\nextchar\pluss}
>> \def\pluss{%
>> \ifx\nextchar+%
>> \let\next\smallplusplus%
>> \else%
>> \let\next\plus%
>> \fi%
>> \next}
>>
>> And no, I can't explain it.
>>
>>
> If you could, I'd be really worried about you. ;-)
Since I started to waste the evening with TeX, the final version:
\def\plus{+}
\def\gobble#1{}
\catcode`\+=\active
\def\checknextchar{%
\ifx\nextchar+%
\raisebox{0.6ex}{\tiny\plus\kern-.3ex\plus}%
\let\next\gobble%
\else%
\plus%
\let\next\relax%
\fi%
\next%
}
\def+{\futurelet\nextchar\checknextchar}
It starts getting readable, so I better stop now.
Incidentally, I stumbled across htlatex and start to wonder whether
this would be a good start for tex2lyx. It is able to process the
macros above...
Andre'
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic