[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:       Daniel Lohmann <daniel.lohmann () informatik ! uni-erlangen ! de>
Date:       2008-10-23 2:05:21
Message-ID: 5EEDC87C-D027-4999-B678-52CFC9B8A4A7 () informatik ! uni-erlangen ! de
[Download RAW message or body]


On 23.10.2008, at 00:00, Andre Poenitz wrote:
> 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.

Andre', thanks a lot!

*That* is quite impressive -- and actually readable. I think I even  
understand it!

I applied it immediately to my thesis document -- and had to learn  
quickly that my clever-to-be idea wasn't actually that clever.  
Apparently, I use "C++" in quite some label texts. Well, that would be  
easy to fix, wouldn't it? However, not so easy to fix would be the  
listings package. You cannot  imagine how many times the string "C++"  
is used internally when you apply lstlisting to typeset C++ listings...

Turning characters into active characters is a really good way to shot  
oneself into the knee :-)

I nevertheless kept this code as a comment in my preamble, just to  
keep the reference. It really is the most readable application of  
catcodes I have ever seen and I have learned a lot from it!

Daniel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic