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.

This question already has an answer here:

I would like to draw a fraction like symbol that looks similar to \frac{a}{b} BUT is angled so that the a is higher than the b and the slash is angled. Sort of like a % sign but not as drastic. Not sure if this character will come out properly: ½ but it looks similar to that.

I would like some way to control the angle of the slash and the angle of anti-diagonal(the line drawn through the center of gravities of the upper and lower numbers). The "anti-diagonal" of the % sign has a very similar angle to that of the slash and for my purposes it looks too "upright".

I would also like to "nest" the fractions so but not have the size change(or make it optional). Something like a/b/c with all the slashes and letters the same size.

frac

There are four quantities I would like to control. The slash length and angle and the anti-diagonal angle and the letter separation. I would like to use this similar to a frac.

I don't mind having less control but basically looking for something that looks visually correct.

share|improve this question

marked as duplicate by Svend Tveskæg, darthbith, ChrisS, Christian Hupfer, Papiro May 30 at 9:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Related: tex.stackexchange.com/questions/3372/… –  Torbjørn T. Nov 16 '12 at 22:40
    
@TorbjørnT. I would even go as far as saying: exact duplicate that should be merged? "I don't mind having less control but basically looking for something that looks visually correct." really minimalizes the differences. –  doncherry Nov 17 '12 at 1:59

2 Answers 2

up vote 4 down vote accepted

Here is a version using tikz:

enter image description here

Notes:

  • Currently several macros are defined to allow for tweaking:

    1. \TextScale
    2. \SlashAngle
    3. \SlashScale

Further Enhancements:

  • This has an issue that you can not nest \Sfrac.
  • Use pgfkeys to allow tweaking of the applied styles via the optional first parameter of \Sfrac which is unused as of yet.

Code:

\documentclass{article}
\usepackage{tikz}
\usepackage{calc}

\newcommand*{\TextScale}{0.75}
\newcommand*{\SlashAngle}{45}
\newcommand*{\SlashScale}{1.5}

\newlength{\NeumeratorXShift}
\newlength{\DenomiatorXShift}
\newlength{\NeumeratorYShift}
\newlength{\DenomiatorYShift}

\tikzset{Slash/.style={scale=\SlashScale, rotate=\SlashAngle}}
\tikzset{Neumerator/.style={scale=\TextScale, xshift=-\NeumeratorXShift, yshift=\NeumeratorYShift, inner sep=0, outer sep=0}}
\tikzset{Denominator/.style={scale=\TextScale, xshift=\DenomiatorXShift, yshift=-\DenomiatorYShift, inner sep=0, outer sep=0}}
\newcommand{\Sfrac}[2]{%
    \pgfmathsetlength{\NeumeratorXShift}{0.1em+0.5*\widthof{$#1$}}%
    \pgfmathsetlength{\DenomiatorXShift}{0.1em+0.5*\widthof{$#2$}}%
    \pgfmathsetlength{\NeumeratorYShift}{0.2ex+0.5*\heightof{$#1$}}%
    \pgfmathsetlength{\DenomiatorYShift}{0.2ex+0.5*\heightof{$#2$}}%
    \tikz [x=1.4ex,y=1.4ex,line width=.09ex, baseline, yshift=0.6ex] 
        \draw [Slash] (-0.5,0.0) -- (0.5,0)
        node  [Neumerator ] at (0,0) {$#1$}
        node  [Denominator] at (0,0) {$#2$};
}%

\begin{document}
    $\frac{a}{b} \quad\Sfrac{a}{b}$
\end{document}
share|improve this answer
    
I was afraid to use tik as it might be overkill but I guess it will have to do ;) –  JonSlaughter Nov 17 '12 at 0:03
    
Well I am sort of specialize in the overkill solution :-). But perhaps others will come up with an alternative way. –  Peter Grill Nov 17 '12 at 0:04

As mentioned by other users in the comments, this is partially answered by this question and the answer is to use package xfrac, and the command is \sfrac{...}{...}.

share|improve this answer

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