答案1
您只需使用\rule
它即可。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\linterval}{\mathbin{\rule[1ex]{0.1ex}{0.7ex}\rule[1.2ex]{1ex}{0.3ex}}}
\newcommand{\rinterval}{\mathbin{\rule[1.2ex]{1ex}{0.3ex}\rule[1ex]{0.1ex}{0.7ex}}}
\newcommand{\binterval}{\mathbin{\rule[1ex]{0.1ex}{0.7ex}\rule[1.2ex]{1ex}{0.3ex}\rule[1ex]{0.1ex}{0.7ex}}}
\begin{document}
$a\binterval b$, $a\linterval b$ and $a\rinterval b$.
\end{document}
它们可以很容易地适应周围环境的大小。
\documentclass{article}
\usepackage{amsmath,scalerel}
\newcommand{\linterval}{\mathbin{\scalerel*{\rule[1ex]{0.2ex}{0.7ex}\rule[1.25ex]{1ex}{0.2ex}}{Q}}}
\newcommand{\rinterval}{\mathbin{\scalerel*{\rule[1.25ex]{1ex}{0.2ex}\rule[1ex]{0.2ex}{0.7ex}}{Q}}}
\newcommand{\binterval}{\mathbin{\scalerel*{\rule[1ex]{0.2ex}{0.7ex}\rule[1.25ex]{1ex}{0.2ex}\rule[1ex]{0.2ex}{0.7ex}}{Q}}}
\begin{document}
$a\binterval b$, $a\linterval b$ and $a\rinterval b$.
\Large $a\binterval b$, $a\linterval b$ and $a\rinterval b$.
\tiny $a\binterval b$, $a\linterval b$ and $a\rinterval b$.
\end{document}
答案2
我建议使用\mapstochar
和mapsfromchar
字形mathabx
(不加载包):
\documentclass{article}
\usepackage{mathtools}
\usepackage{rotating, graphicx}
\usepackage[export]{adjustbox}
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{%
<-6> matha5
<6-7> matha6
<7-8> matha7
<8-9> matha8
<9-10> matha9
<10-12> matha10
<12-> matha12 }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\mapsfromchar}{\mathrel}{matha}{"DF}
\DeclareMathSymbol{\varmapstochar}{\mathrel}{matha}{"DE}
\newcommand{\ccintv}{\raisebox{1\jot}{\boldmath$\,\varmapstochar\mkern-0.3mu\relbar\mkern-0.3mu\mapsfromchar\,$}}
\newcommand{\cointv}{\raisebox{1\jot}{\,\boldmath$\varmapstochar\mkern-0.4mu\relbar\mkern1.5mu$}}
\newcommand{\ocintv}{\raisebox{1\jot}{\boldmath$\mkern1.5mu\relbar\mkern-0.3mu\mapsfromchar $\,}}
\begin{document}
\begin{alignat*}{3}
& a \ccintv b &\qquad & a \cointv b &\qquad & a \ocintv b
\end{alignat*}
\end{document}
答案3
另一个基于规则的解决方案,它不会尝试猜测符号相对于基线的高度,因为它将其视为上标。您可以轻松自定义宽度、横向条的高度和中间条的厚度的参数。这些取决于数学模式之外的当前字体,因此它们会自动调整为更大或更小的尺寸(不过,在给定的实现中,横向条的宽度不是这样,但您也可以决定用em
单位来表示它)。
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\intoo}{\peano@interval00}
\newcommand{\intco}{\peano@interval10}
\newcommand{\intoc}{\peano@interval01}
\newcommand{\intcc}{\peano@interval11}
% the width of all symbols em in the current font before the math formula started
\newcommand{\peano@intervalwd}{0.5em}
% the thickness of the bar is 0.25ex in the font for superscripts
\newcommand{\peano@intervalthickness}{0.125ex}% half of the thickness
% the height of the lateral bars is 0.7ex in the font for superscripts
\newcommand{\peano@intervalht}{0.35ex}
\newcommand{\peano@intervalbar}{%
\vrule height \dimexpr\fontdimen22\scriptfont2+\peano@intervalht\relax
depth -\dimexpr\fontdimen22\scriptfont2-\peano@intervalht\relax
width 0.4pt
}
\newcommand{\peano@interval}[2]{{% a mathord
{\mathstrut}^{%
\mkern1mu
\makebox[\peano@intervalwd][s]{%
\fontsize\sf@size{0}\selectfont
$\m@th\scriptstyle
\ifnum#1=1 \peano@intervalbar\fi
\peano@intervalrule
\ifnum#2=1 \peano@intervalbar\fi
$%
}% end of \makebox
\mkern1mu
}% end of superscript
% remove the \scriptspace
\kern-\scriptspace
}}
\newcommand{\peano@intervalrule}{%
\leaders
\hrule height \dimexpr\fontdimen22\scriptfont2+\peano@intervalthickness\relax
depth -\dimexpr\fontdimen22\scriptfont2-\peano@intervalthickness\relax
\hfill
}
\makeatother
\begin{document}
$a\intoo b$
$a\intco b$
$a\intoc b$
$a\intcc b$
\Large
$a\intoo b$
$a\intcc b$
\end{document}