![[a, b]から派生した新しいシンボル](https://rvso.com/image/423835/%5Ba%2C%20b%5D%E3%81%8B%E3%82%89%E6%B4%BE%E7%94%9F%E3%81%97%E3%81%9F%E6%96%B0%E3%81%97%E3%81%84%E3%82%B7%E3%83%B3%E3%83%9C%E3%83%AB.png)
答え1
誰かがTiを持って来る前にけZソリューション:-)
...
\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}
2 つの長さは、現在の数学スタイルに従ってスケールされます。\@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}