
맞춤 모양을 만들고 그 안에 텍스트를 넣어야 합니다. 하지만 문제는 내 텍스트가 장식된 경로의 길이에 맞지 않는다는 것입니다. 그래서 텍스트를 두 개 또는 세 개의 경로로 자동으로 나누는 방법이 필요합니다.
이것이 내 모양이고 그 안의 선은 텍스트를 넣을 위치입니다.
다음 코드를 사용하여 이 모양을 생성합니다.
\begin{tikzpicture}
% shape
\draw (0,0) ++ (45:3) arc (45:135:3);
\draw (0,0) ++ (45:5) arc (45:135:5);
\draw (45:3) -- (45:5);
\draw (135:3) -- (135:5);
%lines for text
\draw (0,0) ++ (50:3.5) arc (50:130:3.5);
\draw (0,0) ++ (50:4) arc (50:130:4);
\draw (0,0) ++ (50:4.5) arc (50:130:4.5);
\end{tikzpicture}
경로 장식을 사용하여 이 줄에 텍스트를 넣을 계획입니다.
\path[
postaction={
decorate,
decoration={
text along path,
reverse path=true,
text={very long long text, which don't fit the shape boundaries}
}
}
] (0,0) ++ (50:4.5) arc (50:130:4.5);
하지만 텍스트가 길면 제공된 공간에 맞지 않습니다.
그래서 제공된 공간을 계산한 다음 텍스트를 여러 경로로 나누는 방법을 찾아야 합니다. 어떤 제안이 있으십니까?
답변1
여러 세그먼트가 포함된 단일 경로를 사용할 수 있습니다.("버그"에 주의하세요: TikZ는 각 세그먼트를 역순으로 사용합니다...)
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
% shape
\draw (0,0) ++ (45:3) arc (45:135:3);
\draw (0,0) ++ (45:5) arc (45:135:5);
\draw (45:3) -- (45:5);
\draw (135:3) -- (135:5);
%lines for text
\draw[blue] (0,0) ++ (50:3.5) arc (50:130:3.5);
\draw (0,0) ++ (50:4) arc (50:130:4);
\draw (0,0) ++ (50:4.5) arc (50:130:4.5);
% text along path
\path[
postaction={
decorate,
decoration={
text along path,
reverse path=true,
text={Very long long text, which don't fit the shape boundaries
and so on. Very long long text... Very long text...}
}
}
]
(0,0) ++ (50:3.5) arc (50:130:3.5)
(0,0) ++ (50:4) arc (50:130:4)
(0,0) ++ (50:4.5) arc (50:130:4.5);
\end{tikzpicture}
\end{document}
reverse path
옵션이 없는("버그"를 방지하기 위해) 완벽한 솔루션과 옵션이 없는 (0,0)
(경계 상자에 모양을 맞추기 위한) 완전한 솔루션이 있습니다 .
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
% shape
\draw (45:3) arc (45:135:3)
-- (135:5) arc (135:45:5)
-- cycle;
% lines for text
\draw
(50:3.5) arc (50:130:3.5)
(50:4) arc (50:130:4)
(50:4.5) arc (50:130:4.5);
% text along path
\path[postaction={decorate,decoration={
text along path,
text={Very long long text, which don't fit the shape boundaries
and so on. Very long long text... Very long text...}
}}]
(130:4.5) arc (130:50:4.5)
(130:4) arc (130:50:4)
(130:3.5) arc (130:50:3.5);
\end{tikzpicture}
\end{document}