![源自 [a, b] 的新符號](https://rvso.com/image/423835/%E6%BA%90%E8%87%AA%20%5Ba%2C%20b%5D%20%E7%9A%84%E6%96%B0%E7%AC%A6%E8%99%9F.png)
答案1
在有人帶著Ti到來之前kZ解:-)
...
\documentclass{article}
% \usepackage{amsmath}
\makeatletter
\newcommand*{\foo}[1]{{\mathpalette\foo@{#1}}}
\newcommand*{\foo@}[2]{%
\@tempdima=.5\fontdimen5
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi\tw@
\@tempdimb=\fontdimen8
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi\thr@@
\setbox\z@=\vtop{\hbox{$\m@th#1#2$}\kern\@tempdima}%
\setbox\tw@=\vbox{\hrule\@width\@tempdima\@height\@tempdimb\kern\ht\z@\kern\@tempdima}%
\vtop{\hbox{\vrule\@width\@tempdimb\copy\tw@\copy\z@\copy\tw@\vrule\@width\@tempdimb}\hrule\@height\@tempdimb}%
}
\makeatother
\begin{document}
$\foo{a,b}$
$\scriptstyle\foo{a,b}$
$\scriptscriptstyle\foo{a,b}$
\medskip
$\displaystyle\foo{-\frac{a}{2},\frac{a}{2}}$
$\foo{-\frac{a}{2},\frac{a}{2}}$
$\scriptstyle\foo{-\frac{a}{2},\frac{a}{2}}$
$\scriptscriptstyle\foo{-\frac{a}{2},\frac{a}{2}}$
\end{document}
這兩個長度根據當前的數學風格進行縮放:\@tempdimb
是分數規則的厚度,\@tempdima
而是一半ex
(後者可以不借助 來修復\fontdimen
)。
如果您取消註釋amsmath
,那麼結果將在\scriptscriptstyle
您獲得的位置略有不同
使用較短的程式碼
\newcommand*{\foo@}[2]{%
\@tempdima=.5\fontdimen5
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi\tw@
\setbox\z@=\vtop{\hbox{$\m@th#1#2$}\kern\@tempdima}%
\setbox\tw@=\vbox{\hrule\@width\@tempdima\kern\ht\z@\kern\@tempdima}%
\vtop{\hbox{\vrule\copy\tw@\copy\z@\copy\tw@\vrule\@width\@tempdimb}\hrule}%
}
「盒子」0.4pt
在每種樣式中的預設厚度都是 。
答案2
如果您的符號沒有過多的深度(例如沒有分數),您可以逃脫
\documentclass{article}
\usepackage{amsmath,array}
\makeatletter
\newcommand{\segment}[1]{%
\big\lceil\colas@segment{#1}\big\rceil
}
\newcommand{\colas@segment}[1]{%
\mspace{-4.85mu}%
\underline{\mspace{5mu}#1\vphantom{j}\mspace{5mu}}%
\mspace{-4.85mu}%
}
\makeatother
\begin{document}
\Huge
\indent\rlap{\vrule height0pt depth0.1pt width 4cm}%
$\segment{a,b}=\{ta+(1-t)b: t\in[0,1]\}$
\indent\rlap{\vrule height0pt depth0.1pt width 4cm}%
$\segment{p,q}=\{tp+(1-t)q: t\in[0,1]\}$
\end{document}