我打算在字符之间创建“关联线”,其中线的开头是单词内的一个或多个字符,线的结尾是单个字符。类似以下(在 MS Word 中创建):
我正在尝试模仿/复制书中的某些内容,它看起来像这样:
对于我的目的而言,线条是在文字下方还是上方并不重要(但如果我知道如何做,那就太好了)。我认为最好将这些图画作为图形(即在环境figure
或类似的东西内)。
我确信有很多不同的方法可以实现这一点,但我(到目前为止)没有理由偏爱这种方式或那种方式(只是因为我不知道如何做到这一点)。我愿意接受所有建议。
编辑pst-asr
:基于 Alan Munn 的建议的问题。
梅威瑟:
\documentclass{article}
\usepackage{pst-asr, fontspec}
\setmainfont{Linux Libertine O}
\begin{document}
\psset{
reptype = nots, % representation type = no timing slots
xgap = 0.5em, % set width of space between each character (how can this be set to the 'normal' space between characters?)
sysym = L, % what does this do? I changed it to 'H', but the output is the same
syB = 2em, % set the distance between the top of the phoneme tier and the bottom of the syllable tier?
everyph = \normalfont % the format of every character on the phoneme tier
}
\asr[syB = 2em] asa| % why does syB need to be set independently for this one?
\tierput(1,sy){H} % put what's in {} in character position 1 on the syllable tier
\assoc(1,sy)(1,ts) % draw association line from the bottom of character position 1 on the syllable tier to the bottom of character position 1 on the time slot tier
\endasr
\hspace{3em}
\asr asta|
\tierput(1,sy){H}
\assoc(1,sy)(1,ts)
\assoc(1,sy)(2,ts)
\endasr
\end{document}
答案1
如果您需要做很多这样的工作,那么该pst-asr
软件包非常强大,但有点复杂。使用 XeLaTeX 编译以下内容。(由于它使用pstricks
它不能直接用 pdfLaTeX 编译,并且需要 XeLaTeX(如本例所示)或 LaTeX+dvips(在这种情况下,您将使用该tipa
包而不是加载fontspec
等)。层上元素之间的间距由参数决定xgap
。将其设置为.5em
似乎会产生合理的间距。
\documentclass[png,convert,border=4pt]{standalone}
\usepackage{pst-asr}
\usepackage{fontspec}
\newfontfamily\IPAfont{Doulos SIL}
\begin{document}
\psset{reptype=nots,xgap=.5em,sysym=L,syB=2.5em,everyph=\IPAfont}
\asr[syB=2.5em] asa|
\tierput(1,sy){H}\assoc(1,sy)(1,ts)
\endasr
\hspace{3em}
\asr asta|
\tierput(1,sy){H}\assoc(1,sy)(1,ts)\assoc(1,sy)(2,ts)
\endasr
\hspace{3em}
\asr /h{ɛ̆}s.tʏr/|
\tierput(4,sy){H}\assoc(4,sy)(2,ts)\assoc(4,sy)(6,ts)|
\endasr
\end{document}
如果您只需要执行其中几个,那么学习该软件包可能不值得pst-asr
,在这种情况下,您可以使用 TikZ 及其库手动轻松完成它们matrix
。通过设置节点的inner
和outer sep
,我们可以充分减少它们之间的间距。
\documentclass[png,border=4pt]{standalone}
\usepackage{fontspec}
\setmainfont{Doulos SIL}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes,nodes={inner sep=0pt,outer sep=1pt}] {
& H &\\[3ex]
a & s & a\\
};
\draw (A-1-2) -- (A-2-2);
\begin{scope}[xshift=4cm]
\matrix (B) [matrix of nodes, nodes={inner sep=0pt,outer sep=1pt}]{
/ & h & ɛ̆ & s &. & t & ʏ & r &/\\[3ex]
& & & & H & & & & \\
};
\draw (B-2-5.north) -- (B-1-3.south);
\draw (B-2-5.north) -- (B-1-7.south);
\end{scope}
\end{tikzpicture}
\end{document}
答案2
这是简单的节点连接,可以通过表格完成\rnode
:
\documentclass[12pt]{article}
\usepackage{libertine}
\usepackage{pst-node}
\newcommand\rNode[3][c]{\rnode[#1]{#2}{\strut#3}}%Use \strut to get the same height for every node
\newcommand\expl[2]{{\def\arraystretch{1.7}\tabular{@{}c@{}}\strut#1\strut\endtabular%
#2}}% stretch the tabular and execute the connections #2
\begin{document}
\expl{\rNode[b]{A}{H} \\ a\rNode[t]{a}{s}a}% [b] bottom, [t] top node
{\ncline{A}{a}}
\expl{\rNode[b]{A}{H} \\ a\rNode[t]{a}{s}\rNode[t]{b}{t}a}%
{\ncline{A}{a}\ncline{A}{b}}
\expl{/h{ɛ̆}\rNode[b]{A}{s}.\rNode[b]{B}{t}ʏr/ \\ \rNode[t]{a}{H}}%
{\ncline{A}{a}\ncline{B}{a}}
\end{document}
答案3
本质上与 Alan Munn 的 TikZ 答案相同,只是文本的规范变得更容易一些,并且每个字母都使用包进行排版tipa
。请注意,字符是单独排版的,因此没有字距调整或连字,并且涉及宏的字符(例如\v{E}
)必须完全包含在括号内(例如{\v{E}}
),否则将造成严重破坏。
\documentclass[12pt]{standalone}
\usepackage{tipa}
\usepackage{tikz}
\usetikzlibrary{matrix}
% These macro's just iterate over every character in the
% string passed as a macro and executes \dochar{<character>}\inchar
% for each character.
%
% Try:
%
% \def\dochar#1{#1}\dorow{ABCDEF}
%
% Result:
%
% A&B&C&D&E&F
%
\def\dorow#1{\expandafter\DoRow#1\dorow}
\def\DoRow#1{\ifx#1\dorow\else\dochar{#1}\inchar\expandafter\DoRow\fi}
% Inside a matrix \& shifts to the next cell
\def\inchar{\&}
% Inside a matrix \dochar adds a node with the character inside it
\def\dochar#1{\node[every asr node/.try]{\strut\textipa{#1}};}
\tikzset{%
% This style is executed for every asr node.
% Every asr node contains a single character, and is
% named according to \asrprefix and the current matrix column.
%
% If \asrprefix is A, then the characters are named A-1, A-2, A-3... etc
every asr node/.style={
inner sep=0pt,
anchor=base,
name=\asrprefix-\the\pgfmatrixcurrentcolumn,
},
asr/.style={/tikz/asr/.cd, #1,
/tikz/.cd,
insert path={%
node [matrix, column sep=0pt, ampersand replacement=\&] {\dorow{\asrtext}\\}
}
},
asr/.cd,
% The next for the association
text/.store in=\asrtext,
text=,
% The prefix for every node.
prefix/.store in=\asrprefix,
prefix=,
}
\begin{document}
\begin{tikzpicture}
% Draw the H node
\node (H) {H};
% Draw the asr matrix below the H node
\path (H)++(0,1) [asr={prefix=A, text=/h{\v{E}}s.tYr/}];
\draw (H) -- (A-4) (H) -- (A-6);
\node (H) at (1,0) {H};
\path (H)++(0,-1) [asr={prefix=B, text=asa}];
\draw (H) -- (B-2);
\path (2, -1) [asr={prefix=C, text=asta}];
% Align the H node above the third character
\node [above of=C-3] (H) {H};
\draw (H.south) -- (C-2)
(H.south) -- (C-3);
\end{tikzpicture}
\end{document}
答案4
为了在最后一个 asr 中获得正确的空间,您可以使用连接字符'
。
\documentclass[png,convert,border=4pt]{standalone}
\usepackage{pst-asr}
\psset{everyasr=\tiershortcuts} % this allows you to use \@ and \- instead of \tierput and \assoc
\usepackage{fontspec}
\newfontfamily\IPAfont{Doulos SIL}
\begin{document}
\psset{reptype=nots,xgap=.5em,sysym=L,syB=2.5em,everyph=\IPAfont}
\asr[syB=2.5em] asa|
\@(1,sy){H}\-(1,ts)
\endasr
\hspace{3em}
\asr asta|
\@(1,sy){H}\-(1,ts)\-(2,ts)
\endasr
\hspace{3em}
\asr /h{ɛ̆}s'.tʏr/| % here is the juncture trick
\@(3.5,sy){H}\-(2,ts)\-(5,ts)|
\endasr
\end{document}
这就是结果。
使用更简单的代码:
\psset{reptype=nots,xgap=.4em,sysym=H,syB=2.5em,everyph=\IPAfont}
\asr a\1sa \endasr
\hspace{3em}
\asr a\2sta \endasr
\hspace{3em}
\asr /h{ɛ̆}s'.tʏr/|
\@(3.5,sy){H}\-(2,ts)\-(5,ts)|
\endasr