
Hago una forma personalizada y necesito poner un texto dentro de ella. Pero el problema es que mi texto no se ajustaba a la longitud del trazado decorado. Entonces, necesito una forma de dividir automáticamente el texto entre dos o tres rutas.
Entonces, esta es mi forma y las líneas dentro de ella son un lugar donde quiero poner mi texto:
Genero esta forma con el siguiente código:
\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}
Planeo poner texto en estas líneas usando la decoración del camino:
\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);
Pero si el texto es largo, no cabe en el espacio proporcionado.
Entonces tengo que encontrar una manera de calcular el espacio proporcionado y luego dividir el texto entre las distintas rutas. ¿Alguna sugerencia?
Respuesta1
Puedes utilizar un único camino (con varios segmentos).(Tenga en cuenta el "error": TikZ usa cada segmento en orden inverso...)
\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}
Aquí una solución completa sin la reverse path
opción (para evitar el "error") y sin (0,0)
(para ajustar la forma en el cuadro delimitador).
\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}