5

I'd like to be able to write math that looks a little like this:

Logical formula

So it is a bit like a fraction, but there's a also a top line, and there's an arbitrary symbol or formula immediately left of where the top line begins. Can this kind of thing be created in latex? I'd like to have a command \varfrac{}{}{} so that the above formula can be written as \varfrac{\forall}{x:X}{P(x) \& Q(x)}.

(I couldn't think of any appropriate tags for the question.)

  • curiosity kills the duck ... but nevertheless I have to ask: What it is supposed to be? What it is used for? – yo' Feb 2 '15 at 10:29
  • 1
    @yo', don't worry, goblins don't kill; in fact we are all vegetarians and hippies. Haha. Its meant to be a slight variant on the usual notation of first-order logic that improves readability in certain contexts. – goblin Feb 2 '15 at 10:31
  • ah ok, FO is cryptic anyways, doesn't hurt making it even more cryptic :p Just one more thing: where is the centerline supposed to be? If it was like $X=\varfrac{\forall}{x:X}{P(x) \& Q(x)}$, where would $X=$ go? – yo' Feb 2 '15 at 10:33
  • @yo', good question. It should be aligned with the "usual" fraction line, if that makes sense. – goblin Feb 2 '15 at 10:34
5

Very basic one.

\documentclass{scrartcl}

\usepackage{mathtools,graphicx}

\newcommand*\varfrac[3]
  {\frac{\hphantom{#1}\overset{\mathllap{\raisebox{-.5ex}{$#1$}}\hrulefill}{#2}\hphantom{#1}}{#3}}

\begin{document}

\[
  \varfrac{\forall}{x : X}{P(x) \mathbin{\&} Q(x)}
\]

\end{document}

enter image description here

|improve this answer|||||
  • Be careful with \varfrac{\forall}{x:X}{P(x)}, the \mathllap makes some troubles there. – yo' Feb 2 '15 at 10:56
  • You are right. I think it's solved. I didn't care about fractions in \textstyle, I think it's too much to put inline. – Manuel Feb 2 '15 at 10:57
8

Use a nested \dfrac:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\deduction}[4][]{%
  \dfrac{#1\dfrac{#2}{\mathstrut #3}\hphantom{#1}}{\mathstrut #4}%
}

\renewcommand{\land}{\mathbin\&}

\begin{document}
\[
x\quad\deduction[\forall]{}{x:X}{P(x)\land Q(x)}\quad x 
\]
\end{document}

Instead of using \& in the formula, I'd prefer to redefine \land (that usually gives a wedge symbol). Actually I'd avoid the ampersand for denoting the “and” connective, but the document is yours.

For generating the picture, I used \boxed in order to show that the bounding box is correct. The two x's on the sides are just to show what's the main fraction line.

enter image description here

|improve this answer|||||
4

You can simply go with multiple \frac and a bit of tweaking to get the right font size. Note that this way, the symbol \forall will be always properly vertically centered.

As well, you probably want \mathbin{\&} since it's a binary operator in your context, and you may want to add some horizontal spacing around x:X as I did, to separate it slightly from the \forall.

enter image description here

\documentclass{article}

\usepackage{mathtools}

\makeatletter
% \samefrac: typeset the inside without style change
\newcommand*\@samefrac[3]{\frac{#2\,#1\,}{#2\,#3\,}}
\newcommand*\samefrac[2]{\mathpalette{\@samefrac{#1}}{#2}}
% \varfrac: the requested command
\newcommand*\varfrac[3]{\frac{#1\samefrac{}{#2}}{#3}}
% \band: binary operator `&`
\newcommand*\band{\mathbin{\&}}
\makeatother

\pagestyle{empty}
\usepackage{lipsum}

\begin{document}

\lipsum*[4]
\(
    X = \varfrac{\forall}{x : X}{P(x) \mathbin{\&} Q(x)}
\)
\lipsum[4]
\[
    X = \varfrac{\forall}{x : X}{P(x) \mathbin{\&} Q(x)}
\]
\lipsum[4]

\end{document}
|improve this answer|||||

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.