# Typesetting straight baselines in a circular arrangement

I was wondering how one might go about setting the circular arrangement seen here in Figure "(2)"--i.e.,in a series of straight lines radiating from a central point.

The most useful thing I've been able to find thus far is Rotating a letter (more or less an outright tutorial) on the graphicx package. I'm sure it would be doable with a dauntingly-arduous combination of graphicx and hspace and vspace commands, but I was hoping somebody might know of a more elegant solution.

(I was going to ask about the other type with the circular baselines, but How to fine tune rotation of text along circular path? seems to clear that one up pretty extensively.)

UPDATE: Many thanks to mwibrow for getting me mostly there and going the extra mile to do it with Hebrew characters! Just wanted to let anybody else who might want to weigh in with additional ideas know that Roman characters will suffice in further examples.

-

Decorations aren't that versatile when it comes to right-to-left languages, but the following shows one way of proceeding. It requires compilation with lualatex. Possibly PSTricks could do this better.

Also, I use the font freesans which may or may not be available on your system.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage{fontspec}
\newfontfamily\hebrewfont[Script=Hebrew]{freesans}

\tikzset{
decorate path with hebrew/.style={
decoration={
text along path,
text={|\luatextextdir TRT\hebrewfont|#1},
},
decorate,
},
hebrew text/.style={
font=\hebrewfont,
execute at begin node={\luatextextdir TRT}
}
}

\begin{document}

\begin{tikzpicture}
\path [decorate path with hebrew={מלון אבוקדו מישמש תפוח אבוקדו אבטיח אשכולית גזר}]
\foreach \w [count=\i from 0] in {מלון,אבוקדו,מישמש,תפוח,אבוקדו,אבטיח,אשכולית,גזר}
\node [hebrew text, anchor=west,shift=(\i*45:1.25cm), rotate=\i*45] {\w};

\end{tikzpicture}

\end{document}


To get the baseline on the inside the reverse path key can be used with the decoration. Note that the successful use of this key depends on how the path is drawn internally for the circle (i.e., clockwise). If the circle was manually drawn anticlockwise using four arcs, the reverse path key would be unnecessary (of course if the author of the decoration engine was smart enough he'd figure out a way to determine the direction of the path automatically ;-)

The only way I can think of to stack the letters is to crudely iterate over each letter of the word, which I have done with the macro \stackletters. Note that the align key must be used in the \node options to get the stacking to work. Note also the change in anchor and rotation.

To stack in the other direction (i.e., inwards), change the anchor to south, and use rotate=\i*45-90. This could be tied up in a style.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage{fontspec}
\newfontfamily\hebrewfont[Script=Hebrew]{freesans}

\tikzset{
decorate path with hebrew outside/.style={
postaction={
decoration={
text along path,
text={|\luatextextdir TRT\hebrewfont|#1},
reverse path, % Make decoration go the other way
},
decorate
}
},
hebrew text/.style={
font=\hebrewfont,
execute at begin node={\luatextextdir TRT}
}
}

\def\stackletters#1{\let\flag=\relax\expandafter\dostackletters#1;}
\def\dostackletters#1{%
\ifx#1;%
\else%
\ifx\flag\relax%
#1%
\let\flag=\stackletters%
\else%
\\[-0.25\baselineskip]#1%
\fi%
\expandafter\dostackletters%
\fi}

\begin{document}

\begin{tikzpicture}
\path [decorate path with hebrew outside={מלון אבוקדו מישמש תפוח אבוקדו אבטיח אשכולית גזר}]
\foreach \w [count=\i from 0] in {מלון,אבוקדו,מישמש,תפוח,אבוקדו,אבטיח,אשכולית,גזר}
\node [hebrew text, align=center, anchor=north, shift=(\i*45:1.25cm), rotate=\i*45+90] {\stackletters{\w}};

\end{tikzpicture}

\end{document}


So, as requested a version with roman characters which doesn't require lualatex. The code for stacking the node contents has been changed a bit.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\tikzset{
decorate path with text outside/.style={
postaction={
decoration={
text along path,
text={#1},
reverse path, % Make decoration go the other way
},
decorate
}
},
}

\def\stacknodecontents#1\ignorespaces{%
% #1 contains a whole load of internal TikZ code
% which terminates with an \ignorespaces
% (just before the node text begins)
#1\ignorespaces%
\let\stacknext=\relax%
% \expandafter in case the node text is a macro.
\expandafter\dostacknodecontentslet}

\def\dostacknodecontentslet{%
\afterassignment\dostacknodecontentstypeset%
% Need global.
\global\let\stacktoken=}

\def\dostacknodecontentstypeset{%
\ifx\stacktoken\egroup% <- the } at the end of the node.
\let\stacknext=\stacktoken%
\else%
% If \stacknext is \relax then \stacktoken is the first
% token, and does not require a new line.
\ifx\stacknext\dostacknodecontentslet%
\\[-0.25\baselineskip]% Should parameterise this.
\fi%
\stacktoken%
\let\stacknext=\dostacknodecontentslet%
\fi%
\stacknext}

\tikzset{
stack node text/.style={
align=center,
execute at begin node=\stacknodecontents%
}
}

\begin{document}

\begin{tikzpicture}
\path [decorate path with text outside={apple banana celary date egg fig grape honey}]

Okay, One last question: If I'm just doing this with Roman characters, do I still need to compile it with lualatex or would all this still be doable in standard latex? If so, could you please provide an example? Thank you for clarifying the other stuff! – Isaac Apr 6 '13 at 5:33