5

I would like to typeset an operator like the one used to specify substitutions of variables with values in computer science. This is a sketch, just keep in mind that all this should span about on a single line, not two:

v /
 / x

v1, v_2 /
       / x1, x2

Obviously a simple v/x does not solve my problem, since v and x are written on the same exact line while I would like to have them smaller, with the v part aligned to the top of the / and the x aligned to the bottom.

Can you help me solving my problem please?

6
  • 1
    Can you point to an actual printed version of this notation? If simple v/x doesn't work, but the expression has to occupy a single line what would that look like?
    – Alan Munn
    Oct 29, 2011 at 15:10
  • Could you explain what is wrong with $v/x$?
    – Seamus
    Oct 29, 2011 at 15:11
  • @AlanMunn, Seamus: Werner already answered my question, thanks you however. I wanted v and x printed on a slightly different heights. Oct 29, 2011 at 15:29
  • I fixed my question in order to clarify this a little bit. Oct 29, 2011 at 15:31
  • @Riccardo The symbol is called a solidus Oct 29, 2011 at 15:32

1 Answer 1

19

It seems like you might be after so-called "vulgar fractions". One such package that provides this is xfrac by means of \sfrac{<num>}{<denom>}. A similar functionality is provided by nicefrac that supplies an analogous \nicefrac{<num>}{<denom>}. With package options one is also able to choose between "ugly" and "nice" (default) fractions. And finally there's faktor that produces similar-style fractions using \faktor{<num>}{<denom>} (it requires the amssymb package though). Here are some comparisons:

enter image description here

\documentclass{article}
\usepackage{xfrac}% http://ctan.org/pkg/xfrac
\usepackage{nicefrac}% http://ctan.org/pkg/nicefrac
\usepackage{faktor}% http://ctan.org/pkg/faktor
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{lmodern}% http://ctan.org/pkg/lmodern
\begin{document}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{lll}
  \verb!\xfrac! & $\sfrac{\mathbf{v}}{x}$ & $\sfrac{\mathbf{v}_1,\mathbf{v}_2}{x_1,x_2}$ \\
  \verb!\nicefrac! & $\nicefrac{\mathbf{v}}{x}$ & $\nicefrac{\mathbf{v}_1,\mathbf{v}_2}{x_1,x_2}$ \\
  \verb!\faktor! & $\faktor{\mathbf{v}}{x}$ & $\faktor{\mathbf{v}_1,\mathbf{v}_2}{x_1,x_2}$
\end{tabular}
\end{document}

The choice of lmodern was because of minor font substitutions when it comes to typesetting the denominator & numerator. It is also possible to write a macro that would typeset these respective entries differently, if needed. My choice of \mathbf{...} for the numerator was just a style choice.

5
  • 2
    Vulgar fractions... it's really difficult to search for the right packages when you don't know the correct keywords. This is exactly what I was looking for, thank you so much :) Oct 29, 2011 at 15:28
  • @Werner Have a look at Algebra and coalgebra in computer science, I am not sure that the correct symbol is used this way. Oct 29, 2011 at 16:04
  • @YiannisLazarides: Either way, this may be personal preference. I am not familiar with fundamental computer science symbols and representations.
    – Werner
    Oct 29, 2011 at 16:06
  • 1
    @Werner I am also not very familiar, especially with the new computer science, in my time it would have been := which we used generally as the assignment variable. Oct 29, 2011 at 16:35
  • 1
    @YiannisLazarides: Well, nowadays we still use := sometimes if we want to define things. The syntax I'm referring to has a different meaning. Suppose you have a formula P in some calculus, where some free variables appear. You write {v/x}P or [v/x] (you can see both, depending on the conventions chosen by the authors) to mean the formula resulting from substituting every free occurrence of x in P with v. Oct 29, 2011 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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