我如何创建自定义口音?

我如何创建自定义口音?

我需要像这样在上方和下方添加数字重音:

在此处输入图片描述

我该怎么做?

答案1

您需要一种可缩放的字体,因此对于 Computer Modern,我使用fix-cmT1 编码。

\documentclass{article}
\usepackage{fix-cm}
\usepackage[T1]{fontenc}

\makeatletter
\newcommand{\numabove}[2]{% #1 = number, #2 = letter
  \leavevmode
  \vbox{%
    \offinterlineskip
    \ialign{%
      \hfil##\hfil\cr
      \fontsize{0.3\dimexpr\f@size pt\relax}{0}\selectfont #1\cr
      \noalign{\vskip 0.4pt}
      #2\cr
    }%
  }%
}
\newcommand{\numbelow}[2]{% #1 = number, #2 = letter
  \leavevmode
  \vtop{%
    \offinterlineskip
    \ialign{%
      \hfil##\hfil\cr
      #2\cr
      \noalign{\vskip 0.4pt}
      \fontsize{0.3\dimexpr\f@size pt\relax}{0}\selectfont #1\cr
    }%
  }%
}
\makeatother

\begin{document}

\numbelow{2}{T}
\numabove{6}{t}
\numbelow{8}{A}
\numbelow{5}{a}
\numabove{7}{E}
\numabove{2}{e}

\end{document}

在此处输入图片描述

这对于斜体来说确实不太适用,如果需要的话可以进行一些调整。

\documentclass{article}
\usepackage{fix-cm}
\usepackage[T1]{fontenc}

\makeatletter
\newcommand{\numabove}[2]{% #1 = number, #2 = letter
  \leavevmode
  \vbox{%
    \offinterlineskip
    \ialign{%
      \hfil##\hfil\cr
      \ifdim\fontdimen1\font>0pt
        % the font is slanted
        \sbox\z@{#2}%
        \kern\strip@pt\fontdimen1\font\dimexpr\wd\z@*2\relax
      \fi
      {\fontsize{0.3\dimexpr\f@size pt\relax}{0}\selectfont #1}\cr
      \noalign{\vskip 0.4pt}
      #2\cr
    }%
  }%
}
\newcommand{\numbelow}[2]{% #1 = number, #2 = letter
  \leavevmode
  \vtop{%
    \offinterlineskip
    \ialign{%
      \hfil##\hfil\cr
      #2\cr
      \noalign{\vskip 0.4pt}
      {\fontsize{0.3\dimexpr\f@size pt\relax}{0}\selectfont #1}%
      \ifdim\fontdimen1\font>0pt
        % the font is slanted
        \sbox\z@{#2}%
        \kern\strip@pt\fontdimen1\font\dimexpr\wd\z@/2\relax
      \fi\cr
    }%
  }%
}
\makeatother

\begin{document}

\numbelow{2}{T}
\numabove{6}{t}
\numbelow{8}{A}
\numbelow{5}{a}
\numabove{7}{E}
\numabove{2}{e}

\textit{\numbelow{2}{T}
\numabove{6}{t}
\numbelow{8}{A}
\numbelow{5}{a}
\numabove{7}{E}
\numabove{2}{e}}

\end{document}

在此处输入图片描述

答案2

您可以定义宏\accentabove\accentbelow

\font\fiverm=cmr5

\def\accentabove#1#2{\leavevmode
  \vbox{\offinterlineskip
     \halign{\hfil##\hfil\cr\fiverm #2\cr\noalign{\kern.2ex}#1\cr}}%
}
\def\accentbelow#1#2{\leavevmode
  \vtop{\offinterlineskip
     \halign{\hfil##\hfil\cr#1\cr\noalign{\kern.2ex}\fiverm #2\cr}}%
}

%test:

\accentabove t6, \accentbelow T6

\bye

答案3

一个stackengine办法:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{stackengine}
\newcommand{\aup}[2]{\Shortstack[c]{{\tiny #2} {#1}}}
\newcommand{\adn}[2]{\Shortunderstack[c]{{#1} {\tiny #2}}}
\begin{document}
   Text \aup{T}{2}\adn{t}{6} more text
\end{document}

在此处输入图片描述

(你可以根据自己的喜好调整间距,参见stackengine手动的

PS:请注意,如果两个元素是单个标记,则可以避免使用括号,尽管这并不是真正的 LaTeX-ish...

 More text \aup T2 \adn t6 more text

添加,如由@frabjous 推荐\setstackgap{S}{1px}, 你有:

在此处输入图片描述

相关内容