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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to make the fraction line look like the equality (=) sign, i.e., to have two parallel horizontal lines with a little gap in between? Many thanks!

share|improve this question
6  
As a matter of curiosity what does this represent? Disclaimer, mathematically curious but not a mathematician. – Yiannis Lazarides May 16 '12 at 6:15

Use either \Tfrac or \Dfrac (short for Text and Display style "equal fraction") in the following:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\newcommand{\Tfrac}[2]{%
  \ooalign{%
    $\genfrac{}{}{1.2pt}1{#1}{#2}$\cr%
    $\color{white}\genfrac{}{}{.4pt}1{\phantom{#1}}{\phantom{#2}}$}%
}
\newcommand{\Dfrac}[2]{%
  \ooalign{%
    $\genfrac{}{}{1.2pt}0{#1}{#2}$\cr%
    $\color{white}\genfrac{}{}{.4pt}0{\phantom{#1}}{\phantom{#2}}$}%
}
\begin{document}
$f(x)=\Tfrac{1}{2}+\frac{1}{2}$
\end{document}

For a short course on \ooalign, see \subseteq + \circ as a single symbol (“open subset”).


Here is a slightly modified set of commands: \Efrac and \efrac. While both adjust their fraction size based on the math style automatically (using \mathchoice), the former is vertically higher (set based on the height of the two outer black fraction lines) than the latter (set based on the height of a regular fraction).

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\newcommand{\Efrac}[2]{%
  \mathchoice
    {\ooalign{%
      $\genfrac{}{}{1.2pt}0{#1}{#2}$\cr%
      $\color{white}\genfrac{}{}{.4pt}0{\phantom{#1}}{\phantom{#2}}$}}%
    {\ooalign{%
      $\genfrac{}{}{1.2pt}1{#1}{#2}$\cr%
      $\color{white}\genfrac{}{}{.4pt}1{\phantom{#1}}{\phantom{#2}}$}}%
    {\ooalign{%
      $\genfrac{}{}{1.2pt}2{#1}{#2}$\cr%
      $\color{white}\genfrac{}{}{.4pt}2{\phantom{#1}}{\phantom{#2}}$}}%
    {\ooalign{%
      $\genfrac{}{}{1.2pt}3{#1}{#2}$\cr%
      $\color{white}\genfrac{}{}{.4pt}3{\phantom{#1}}{\phantom{#2}}$}}%
}
\newcommand{\efrac}[2]{%
  \mathchoice
    {\ooalign{%
      $\genfrac{}{}{1.2pt}0{\hphantom{#1}}{\hphantom{#2}}$\cr%
      $\color{white}\genfrac{}{}{.4pt}0{\color{black}#1}{\color{black}#2}$}}%
    {\ooalign{%
      $\genfrac{}{}{1.2pt}1{\hphantom{#1}}{\hphantom{#2}}$\cr%
      $\color{white}\genfrac{}{}{.4pt}1{\color{black}#1}{\color{black}#2}$}}%
    {\ooalign{%
      $\genfrac{}{}{1.2pt}2{\hphantom{#1}}{\hphantom{#2}}$\cr%
      $\color{white}\genfrac{}{}{.4pt}2{\color{black}#1}{\color{black}#2}$}}%
    {\ooalign{%
      $\genfrac{}{}{1.2pt}3{\hphantom{#1}}{\hphantom{#2}}$\cr%
      $\color{white}\genfrac{}{}{.4pt}3{\color{black}#1}{\color{black}#2}$}}%
}
\begin{document}
\[ f(x)={\textstyle\Efrac{1}{2}+\frac{1}{2}} \sim \Efrac{3}{4}+\frac{3}{4} \]
\[ f(x)={\textstyle\efrac{1}{2}+\frac{1}{2}} \sim \efrac{3}{4}+\frac{3}{4} \]
\end{document}
share|improve this answer
    
I accidentally made a duplicate here— tex.stackexchange.com/questions/295739/…—because when I searched for existing answers I looked for "double bar" or "double slash." I would like to know how to modify this answer a bit to play with spacing, if you have a moment. Particularly, I'd like to be able to change the spaces between the numerator and denominator and the pair of lines, and the space between the two lines. How could I do that? – jdc Feb 25 at 1:10
1  
The above approach prints the fraction twice: first with a very thick 1.2pt rule, then overprints it with a thin white .4pt rule that also sets the numerator #1 and denominator #2. Since \genfrac is vertically centered on the math axis, the overprinting of the thin white on thick black rule leaves a .4pt black rule at the top and bottom. If you want a thicker rule, you can adjust the 1.2pt value and/or .4pt value. – Werner Feb 25 at 6:47

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.