![上付き文字の位置を変えずに関係の上にシンボルを配置する](https://rvso.com/image/449632/%E4%B8%8A%E4%BB%98%E3%81%8D%E6%96%87%E5%AD%97%E3%81%AE%E4%BD%8D%E7%BD%AE%E3%82%92%E5%A4%89%E3%81%88%E3%81%9A%E3%81%AB%E9%96%A2%E4%BF%82%E3%81%AE%E4%B8%8A%E3%81%AB%E3%82%B7%E3%83%B3%E3%83%9C%E3%83%AB%E3%82%92%E9%85%8D%E7%BD%AE%E3%81%99%E3%82%8B.png)
上付き文字の配置場所を変更せずに、関係の上に記号を配置したいと思います。
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{accents}
\newcommand{\rel}{\rhd}
\newcommand{\symb}{\text{I}}
\newcommand{\testmyrel}[1]{%
\begin{center}%
\begin{minipage}{\linewidth/2}%
\noindent Text text text\\%
$\text{T} #1^* \text{U}$\\%
$\text{T} \rel^* \text{U}$\\%
\end{minipage}%
\end{center}%
}%
\begin{document}
My goal is to place a symbol (e.g. $\symb$) over a rel (e.g. $\rel$) that can be used in text without overlapping with text above, and handles superscripts as if it did not have a symbol:
\begin{center}%
\begin{minipage}{\linewidth/2}%
\noindent Text text text\\%
$\text{T} \mathrel{\overset{\symb}{\rel}\vphantom{\rel}^*} \text{U}$\\%
$\text{T} \rel^* \text{U}$\\%
\end{minipage}%
\end{center}%
However, I do not want the superscript to be an argument of the command, which rules out the code above.
\begin{itemize}
\item Using overset makes the star too high:%
\testmyrel{%
\mathrel{%
\overset{%
\symb%
}{%
\mathord{\rel}%
}%
}%
}%
%
\item Smashing the rel makes it go over the text:%
\testmyrel{%
\mathrel{%
\smash{
\overset{\symb}{\mathord{\rel}}%
}%
}%
}%
%
\item Smashing the symbol makes it go over the text:%
\testmyrel{%
\mathrel{%
\overset{%
\smash{\symb}%
}{%
\mathord{\rel}%
}%
}%
}%
%
\item Adding a vphantom inside mathrel leads to the star being too high:%
\testmyrel{%
\mathrel{%
\overset{\symb}{\mathord{\rel}}%
\vphantom{\symb}%
}%
}%
%
\item Adding a vphantom after mathrel leads to the star being misplaced to the right:%
\testmyrel{%
\mathrel{%
\overset{\symb}{\mathord{\rel}}%
}%
\vphantom{\symb}%
}%
\item Accentset without mathrel does not have the spacing due to mathrel:
\testmyrel{%
\accentset{\symb}{\mathord{\rel}}%
}%
\item Accentset with mathrel puts the star too high:
\testmyrel{%
\mathrel{\accentset{\symb}{\mathord{\rel}}}%
}%
\end{itemize}
\end{document}
答え1
\text
数式で縦書きのものをタイプセットする際にはを使用しないでください。通常は機能しません。 を使用してください\mathrm
。
も、\rhd
またない関係シンボルですが、それを作るのは難しくありません。
\documentclass{article}
\usepackage{amsmath,amssymb,accents}
% \rhd is not a relation symbol
\mathchardef\rel=\numexpr\rhd+"1000
\newcommand{\overrel}[2]{%
\mathrel{\accentset{#1}{#2}}%
\mathrel{\vphantom{#2}}%
}
\begin{document}
\begin{center}
Text text text\\
$T \overrel{\mathrm{I}}{\rel}^* U$\\
$T \rel^* U$
\end{center}
\end{document}
あるいは、次のようにします\overset
:
\newcommand{\overrel}[2]{%
\overset{#1}{#2}%
\mathrel{\vphantom{#2}}%
}
秘訣は、TeX が連続する関係アトム間にスペースも改行ポイントも追加しないことです。そのため、ファントム関係に下付き文字/上付き文字を追加できます。