我有这个使用库沿路径编写文本的示例decorations.text
,并且我想从右到左插入阿拉伯语文本
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage{fontspec}
\usepackage[rldocument]{bidi}
\setmainfont[Script=Arabic]{Amiri}
\tikzset{decoration={text along path,
text={Very very long text I need to show it from right to left}}}
\begin{document}
\begin{tikzpicture}
\path [decorate] (0,0)..controls +(45:4cm) and +(225:4cm)..(8,0);
\end{tikzpicture}
\end{document}
我希望以同样的方式从右到左显示文本
left to right from it show to need I text long very Very
答案1
正如已经提到的,reverse text
TikZ 手册中描述的效果就是您想要的。
然而,你也想第一的使用效果对字母进行分组group letters
,否则它会反转每一个字母。
请注意,两个键的顺序很重要,在下面提供的示例中,我写了两个顺序来展示差异。
编辑:忘记让文本倾斜以跟随路径。使用时characters={text along path}
请确保文本与路径倾斜。
\documentclass[border=5mm]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\tikzset{
decoration={
text effects along path,
text={Very very long text I need to show it from right to left}
}
}
\begin{document}
\subsection*{Group letters, reverse text}
\begin{tikzpicture}
\path [
decorate,
decoration= {
text effects/.cd,
group letters,
reverse text,
characters={text along path}
}] (0,0)..controls +(45:4cm) and +(225:4cm)..(8,0);
\end{tikzpicture}
\subsection*{Reverse text, group letters}
\begin{tikzpicture}
\path [
decorate,
decoration= {
text effects/.cd,
reverse text,
group letters,
characters={text along path}
}] (0,0)..controls +(45:4cm) and +(225:4cm)..(8,0);
\end{tikzpicture}
\end{document}