双线分数

双线分数

有没有办法让分数线看起来像等号 (=),即有两条平行的水平线,中间有一点间隙?非常感谢!

答案1

在下列情况下使用\Tfrac\Dfrac(文本和显示样式“等分分数”的缩写):

在此处输入图片描述

\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}

有关简短课程\ooalign,请参阅\subseteq+\circ作为单个符号(“开子集”)


以下是一组略作修改的命令:\Efrac\efrac。虽然两者都会根据数学样式自动调整分数大小(使用\mathchoice),但前者在垂直方向上高于后者(根据两个外部黑色分数线的高度设置)(根据常规分数的高度设置)。

在此处输入图片描述

\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}

答案2

一种没有颜色的解决方案,在有颜色的背景的情况下可能会中断。

分数排版两次:第一次是凸起的,分母是虚线;第二次是凹陷的,分子是虚线。两者借助 叠加在一起\ooalign

间隙可通过参数定制\doublefracgap

\documentclass{article}
\usepackage[fleqn]{amsmath}

\makeatletter
\newlength{\doublefracgap}
\setlength{\doublefracgap}{0.75pt}
\DeclareRobustCommand{\doublefrac}[2]{%
  \mathinner{\mathpalette\doublefrac@{{#1}{#2}}}%
}
\newcommand{\doublefrac@}[2]{\doublefrac@@#1#2}
\newcommand{\doublefrac@@}[3]{%
  \ooalign{%
    \raisebox{\doublefracgap}{$\m@th#1\frac{#2}{\phantom{#3}}$}\cr
    \raisebox{-\doublefracgap}{$\m@th#1\frac{\phantom{#2}}{#3}$}\cr
  }%
}
\newcommand{\ddoublefrac}[2]{{\displaystyle\doublefrac{#1}{#2}}}
\newcommand{\tdoublefrac}[2]{{\textstyle\doublefrac{#1}{#2}}}
\makeatother

\setlength{\mathindent}{0pt} % just for the example
\setlength{\parindent}{0pt} % just for the example

\begin{document}

\[
\doublefrac{1}{2}\ne\frac{1}{2} \qquad \sqrt{\doublefrac{x^2+2}{x^2-1}}
\]
\[
\frac{1}{2}\ne\doublefrac{1}{2}
\]
$\doublefrac{1}{2}\ne\frac{1}{2}$

$\frac{1}{2}\ne\doublefrac{1}{2}$

$\ddoublefrac{1}{2}\ne\dfrac{1}{2}$

$\dfrac{1}{2}\ne\ddoublefrac{1}{2}$

\end{document}

在此处输入图片描述

相关内容