如何建立新的重音符號

如何建立新的重音符號

我需要使用新的重音符號來表示我自己定義的操作。它是一個在左/右端有兩個點的條。

\documentclass{article}
\begin{document}
\[myaccents{A}\]
\end{document}

在此輸入影像描述

答案1

\documentclass{article}
\usepackage{amsmath,xcolor}
\begin{document}
\[\overset{\textcolor{red}{\cdot}\!-\!\textcolor{red}{\cdot}}{A}\]
\end{document}

或用\myaccent命令來簡化:

\documentclass{article}
\usepackage{amsmath,xcolor}

\def\myaccent#1{\overset{\textcolor{red}{\cdot}\!-\!\textcolor{red}{\cdot}}{#1}}

\begin{document}
\[\myaccent{A}\]
\end{document}

微量元素

可以透過加 來調整條的垂直距離\raisebox。此外,使用較小的條形和直立字元看起來會更好,因為斜體的條形似乎不居中。例子:

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\def\myaccent#1{\overset{%
\hskip0pt   
\raisebox{-.2ex}[0ex][0ex]{%   
$_{\textcolor{red}{\cdot}\text{-}\textcolor{red}{\cdot}}$%
}}{\text{#1}}}
\begin{document}
\[\myaccent{t} \neq \myaccent{\i} \neq \myaccent{m} \neq \myaccent{e} \]
\[\myaccent{T} = \myaccent{I} = \myaccent{M} = \myaccent{E} \]
\end{document}

\begin{document}
\[\myaccent{t} \myaccent{m} \myaccent{M}  \myaccent{g} \]
\end{document}

微量元素

為了使欄位與字元一樣長,可以使用\widthtof{}套件中的 calc.在範例中, 2pt由於點的存在,我將該規則縮短了。可能應該更短一些,但是在窄字符中規則很少,例如\i。根據您的意願調整:

\documentclass{article}
\usepackage{xcolor,calc}
\usepackage{amsmath}
\def\myaccent#1{\overset{
\hskip0pt % add 2 or 3 pt if you change \text{#1} to #1 to use italics 
\raisebox{-.3ex}[0ex][0ex]{%   
$_{\textcolor{red}{\cdot}\rule[.35ex]{\widthof{#1}-2pt}{.4pt}\textcolor{red}{\cdot}}$%
}}{\text{#1}}}
\begin{document}
\[\myaccent{t} \neq \myaccent{\i} \neq \myaccent{m} \neq \myaccent{e} \]
\[\myaccent{T} = \myaccent{I} = \myaccent{M} = \myaccent{E} \]
\end{document}

MWE3

答案2

如果我理解這個問題,你需要將你的重音放在數學變數之上。它們通常採用斜體(數學斜體)。此\mathaccent基元透過緊排在基本字元和 之間進行重音的水平放置\skewchar。我們可以透過宏來模擬這種行為。那麼你的口音在斜體變項之上看起來會更好。

\mathchardef\myskewchar="717F 

\def\myaccent#1{\vbox{\offinterlineskip \lineskip=-.066em
   \setbox0=\hbox{$#1\myskewchar$}\dimen0=\wd0
   \setbox0=\hbox{$#1\kern0pt\myskewchar$}\advance\dimen0 by-\wd0
   \setbox0=\hbox{$#1$}\dimen1=\wd0 \advance\dimen1 by-.3em
                       \ifdim\dimen1<.2em \dimen1=.2em \fi
   \ialign{\hfil##\hfil\cr \hbox to0pt{\hss\kern2\dimen0
       ${\cdot}\hbox to\dimen1{\leaders\vrule height .28em depth-.23em\hfil}{\cdot}$%
       \hss}\cr$#1$\cr}}}

$\myaccent A \dot A + \myaccent x + \dot x + \myaccent t + \myaccent {xx}$.

傾斜字元02

我編輯了程式碼,以便根據底座的寬度來改變重音的寬度。

留下三個問題作為練習:

  • 添加點的顏色(這取決於另一個使用的宏,OPmac,xcolor.sty等)
  • 使巨集複雜化,以便它可以在下標和下標中工作,即使用\mathchoiceor \mathpalette
  • 嘗試\accent在文字模式下模擬斜體字母上方的原始行為。

相關內容