Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Writing fractions using different syntax would sometimes be useful, instead of using \frac{ab}{cd}, I would prefer to write something like \frac{ab⌂cd} where the Unicode is the }{.

n.b., I don't want to mess with the \frac definition, but rather something like \newcommand{\myfrac}[2]{#1⌂#2}

Approach-My understanding of TeX is limited, but I think I can use catcode to do this, My understanding is that:

  • \catcode `@=2 is equivalent to }
  • \catcode `@=1 is equivalent to {

However just writing

\catcode`\⌂=\active
\def ⌂{ \catcode `@=2 \catcode `@=1 }
share|improve this question
    
You can do simpler: \def\myfrac#1⌂#2{\frac{#1}{#2}}. –  Eddy_Em Jan 23 '13 at 7:05
    
@Eddy_Em: But then you would still need to introduce grouping braces like \myfrac25⌂{36} because \myfrac25⌂36 would be displayed as (25/3)6. –  canaaerus Jan 23 '13 at 7:12
1  
I add an answer, but be careful in choosing of last symbol (apostrophe in this case): it shouldn't be in argument of \myfrac. –  Eddy_Em Jan 23 '13 at 7:16
    
Maybe something like: \catcode`⌂=13 \let⌂\over $ {1⌂2} $ \bye? –  morbusg Jan 23 '13 at 8:11

1 Answer 1

up vote 7 down vote accepted

I have koi8-r locale & don't work with unicode, so instead of I'll use |:

First define a command:

\makeatletter
\def\myfrac@#1|#2'{\frac{#1}{#2}}
\def\myfrac#1{\myfrac@#1'}
\makeatother

Then use it:

example: $\myfrac{10|20}$
share|improve this answer
    
Thanks, this works perfectly! However, I am wondering if there is a way to do this along the lines I specified..it would be nice to know my way around catcode –  georg Jan 23 '13 at 7:19
    
@georgraba Catcodes have nothing to do with this: see tex.stackexchange.com/questions/16410/what-are-category-codes for a starter on them. –  Joseph Wright Jan 23 '13 at 7:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.