I'm trying to develop a command to typeset slanted fractions. I know about nicefrac
and xfrac
packages, have tried both, and disliked both. At the moment, in text mode I use \nicefrac
with a bit of raising and lowering, because my aim is to get the numerator with the top line aligned with the top of the slash, and the denominator with the baseline aligned with the bottom of the slash. I've come up with this:
\documentclass[a4paper]{report}
\usepackage{amsmath,amsfonts,amssymb}
\newcommand{\Z}{\mathbb{Z}}
\usepackage{xparse}
\global\newcount\qwerty
\newcommand{\e}[1][2]{\ifnum#1>0
\qwerty=0
\loop\!\advance\qwerty by 1\ifnum\qwerty<#1\repeat
\else
\qwerty=0
\loop\,\advance\qwerty by 1\ifnum\qwerty<-#1\repeat
\fi}
\NewDocumentCommand{\xof}{mmO{7.8}O{-9.3}O{1}O{1}}
{\raisebox{#3pt}{$#1\e[#5]$}\bigg/\raisebox{#4pt}{$\e[#6]#2$}}
\usepackage{graphicx}
\newcommand{\scb}{\scalebox}
\usepackage{xfrac,nicefrac}
\begin{document}
\[\xof{\Z}{n\Z}\]
\[\xof{A}{I}[7.8][-9.3][1][2]\]
\[\xof{\scb{0.7}[0.7]{\(\xof{A}{I}\)\hspace{1pt}}}{\scb{0.7}[0.7]{\hspace{0.5pt}\(\xof{J}{I}\)}}[10][-7.5]\cong\xof{A}{\hspace{-1.2pt}J}.\]
\end{document}
All of that looks fine to my eyes. Parameters 1 and 2 are numerator and denominator, parameters 3 and 4 are the raising amount for the numerator and the lowering amount for the denominator respectively, both in pt
, and the other two are numbers which get turned into as many \!
s (i.e. 2->!!) for kerning between the numerator, the denominator and the slash. The point is having to manually regulate those parameters every time is rather annoying. So is there a way to get the alignment as described at the top done automatically?
PS I know you will tell me I shouldn't have a string of \!
s. I've already been told so about one of \,
s. It's just that sometimes it's handy to have discrete spacing. In any case I think I will abandon this in favor of parameters to pass to \hspace
.
Update:
I didn't know about the \thinskip
, but I will certainly redefine the command adding its use, because it joins a continuous range of spaces and my eye's accustomedness to quantities of \!
. As for the other comments, the point in this is not to have fractions, but rather quotients sets, which I regard as something rather different and write in a completely different way. As such, my aim is definitely not to save vertical space. That might be useful for inline fractions, but for that I have a totally different command which sort of adjusts \nicefrac
. Well, here it is:
\newcommand{\of}[2]{\nicefrac{^{#1}}{_{#2}}}
\newcommand{\mf}[2]{^{#1}\scb{0.5}[1]{/}_{#2}}
either of these, though \of
is decidedly nicer and of more common usage for me. So \xof
is displayed formula only. No need to save space there. I agree that thus zoomed they don't look that nice, but that is probably because \bigg
is too tall. On the other hand, \Big
seemed too short to me when I tried it. Maybe I can try combining \left/
and \right.
with something in the middle, \vphantom
maybe. That's to be investigated. I HAVE tried \nicefrac
and xfrac
's \sfrac
, and both looked bad to me. So don't tell me I «don't know about xfrac
» when I have stated, and restate, I have tried it. Using fractions for quotient sets looks bad to me, otherwise I wouldn't be here. As for the supposedly related answers, this looks like a way to do what I'm doing here in text mode, and these commands I'm studying are for math mode, and this has one answer which aligns only the numerator and one which aligns neither so definitely not what I'm looking for.
xfrac
; I don't advocate “slanted fractions”, anyway. Those are simple fractions and should be treated as such:$\frac{A/I}{J/I}\cong A/J$
is as clear and typographically sound.\!
that's just slow and inefficient.\!
is\mskip-\thinmuskip
so if you want 3 times that do\mskip-3\thinmuskip
no need to do\!\!\!