答案1
这里实现了非常简化的metrix
功能。所有使用的工具都只是 TeX 基元或普通的 TeX 宏。
\def\replspace #1 #2{\ifx#2\end
\else\space #1-\expandafter\replspace\expandafter#2\fi}
\long\def\isnextchar#1#2#3{\begingroup\toks0={\endgroup#2}\toks1={\endgroup#3}%
\let\tmp= #1\futurelet\next\isnextcharA
}
\def\isnextcharA{\the\toks\ifx\tmp\next0\else1\fi\space}
\def\metrix #1#2{\leavevmode \def\tmpa{#1}%
\edef\tmpb{\replspace #2 \end}\expandafter\meA\tmpb\end}
\def\meA #1#2-{\meB{#1#2}\isnextchar{ }{ \meA}{\isnextchar\end{\meE}{\meA}}}
\def\meB#1{\expandafter\nextA\tmpa\relax\end
\ifx\next*\meC{$\bullet$}{\bf #1}\fi
\ifx\next.\meC{$\cdot$}{#1}\fi
}
\def\nextA #1#2\end{\let\next=#1\def\tmpa{#2}}
\def\meC#1#2{\vbox{\halign{\hfil##\hfil\cr#1\cr#2\cr}}}
\def\meE{\let\next=}
\metrix { . * * . . . . . * * . }
{flos ve-te-ris vi-ni meis na-ri-bus ob}
\bigskip
\metrix { . . * . * . . * . }
{Can you come in-side for a min-ute}?
\bye
答案2
使用更方便的标记:\?{...}
表示非音调音节,\?*{...}
表示音调音节。
\documentclass{article}
\usepackage[T1]{fontenc}
\NewDocumentCommand{\?}{sm}{%
\begin{tabular}[b]{@{}c@{}}
\IfBooleanTF{#1}{\textbullet}{\textbf{\textperiodcentered}}\\
\IfBooleanT{#1}{\bfseries}#2
\end{tabular}%
}
\begin{document}
\?{Do} \?{you} \?*{want} \?{some} \?*{break}\?{fast}?
\?{Can} \?{you} \?*{come} \?{in}\?*{side} \?{for} \?{a} \?*{min}\?{ute}?
\end{document}
您还可以调整间距:
\documentclass{article}
\usepackage[T1]{fontenc}
\NewDocumentCommand{\?}{sm}{%
\begin{tabular}[b]{@{}c@{}}
\IfBooleanTF{#1}{\textbullet}{\textbf{\textperiodcentered}}\\[-0.5ex]
\IfBooleanT{#1}{\bfseries}#2
\end{tabular}%
}
\begin{document}
\?{Do} \?{you} \?*{want} \?{some} \?*{break}\?{fast}?
\?{Can} \?{you} \?*{come} \?{in}\?*{side} \?{for} \?{a} \?*{min}\?{ute}?
\end{document}
对于 Charis SIL (以及 XeLaTeX 或 LuaLaTeX):
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Charis SIL}
\NewDocumentCommand{\?}{sm}{%
\begin{tabular}[b]{@{}c@{}}
\IfBooleanTF{#1}{\textbullet}{\textbf{\textperiodcentered}}\\[-0.5ex]
\IfBooleanT{#1}{\bfseries}#2
\end{tabular}%
}
\begin{document}
\?{Do} \?{you} \?*{want} \?{some} \?*{break}\?{fast}?
\?{Can} \?{you} \?*{come} \?{in}\?*{side} \?{for} \?{a} \?*{min}\?{ute}?
\end{document}
以下是如何在上下文中使用短语。请为自己提供音标。
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Charis SIL}
\newfontfamily{\bulletfont}{DejaVu Serif}
\NewDocumentCommand{\?}{sm}{%
\begin{tabular}[b]{@{}c@{}}
\bulletfont\IfBooleanTF{#1}{\textbullet}{\textbf{\textperiodcentered}}\\[-0.5ex]
\IfBooleanT{#1}{\bfseries}#2
\end{tabular}%
}
\NewDocumentCommand{\phrase}{mm}{%
\par\addvspace{1ex}
\noindent\begin{tabular}{@{}l@{}}#1\\#2\end{tabular}%
\par\addvspace{1ex}
}
\begin{document}
Some explanatory text without any real meaning, just to show the phrases
in context; sorry, but I'm not going to look for those IPA symbols.
\phrase{\?{Do} \?{you} \?*{want} \?{some} \?*{break}\?{fast}?}
{Abcdefghijk}
\phrase{\?{Can} \?{you} \?*{come} \?{in}\?*{side} \?{for} \?{a} \?*{min}\?{ute}?}
{Abcdefghijk}
Some explanatory text without any real meaning, just to show the phrases
in context; sorry, but I'm not going to look for those IPA symbols.
\end{document}
答案3
实际上,我认为 stackengine 应该能够很好地做到这一点:
\documentclass{article}
% Make sure to use a font that supports
% the bullets you need:
\usepackage{fontspec}
\setmainfont{Source Sans Pro}
\usepackage{stackengine}
\renewcommand\stacktype{L}
\begin{document}
\stackon{Can}{•} \stackon{you}{•} \stackon{come}{●}
\stackon{in}{•}\stackon{side}{•} \stackon{for}{•}
\stackon{a}{•} \stackon{min}{●}\stackon{ute?}{•}
\end{document}
答案4
如果你不想使用 luatex,这里有一个使用 Ti 的简单方法钾Z:
\documentclass{article}
\usepackage{tikz}
\usepackage{stackengine}
\renewcommand\stacktype{L}
\newcommand{\lstress}[1]
{%
\stackon{#1}{%
\begin{tikzpicture}
\fill[opacity=0] circle (0.5ex);
\fill circle (0.25ex);
\end{tikzpicture}
}%
}
\newcommand{\hstress}[1]
{%
\stackon{\bfseries{#1}}{\tikz \fill circle (0.5ex);}%
}
\begin{document}
\lstress{Can} \lstress{you} \hstress{come} \lstress{in}\hstress{side}?
\end{document}
请注意,% 对于避免不必要的空格非常重要。