我想要得到如这篇文章所示的螺旋: 使用 TikZ 制作螺旋状文本 同时,我需要使用西里尔字母: “示例:未经审查就删除此摘要。”
我找到了一种将语言改为希腊语的方法: 使用希腊文本通过 TikZ 制作螺旋状文本
通过类比,我意识到我应该使用如下语句:
\usepackage[english,russian]{babel}
\usepackage[T2A]{fontenc}
\selectlanguage{russian}
但我没有得到结果
\documentclass[tikz,border=5]{standalone}
\usepackage[english,russian]{babel}
\usepackage[T2A]{fontenc}
\usetikzlibrary{decorations.text}
\begin{document}
\selectlanguage{russian}
\begin{tikzpicture}[
decoration={
reverse path,
text effects along path,
text={Пример: нужно написать по спирали это предложение.},
text effects/.cd,
text along path,
character count=\i, character total=\n,
characters={scale=1-\i/\n}
}
]
\draw [decorate] (0,0)
\foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
\end{tikzpicture}
\end{document}
答案1
您需要用括号括起每个字母,这可以使用 来完成\text_map_function:nN
,从而充分扩展结果。
\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\bracetext}{m}
{
\text_map_function:nN {#1} \__anton_brace:n
}
\cs_new:Nn \__anton_brace:n { {#1} }
\ExplSyntaxOff
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text effects along path,
text/.expanded=\bracetext{Пример: нужно написать по спирали это предложение.},
text effects/.cd,
text along path,
character count=\i,
character total=\n,
characters={scale=1-\i/\n}
}
]
\draw [decorate] (0,0)
\foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
\end{tikzpicture}
\end{document}