Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

circular arrangement of text

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.

share|improve this question

1 Answer 1

up vote 13 down vote accepted

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={מלון אבוקדו מישמש תפוח אבוקדו אבטיח אשכולית גזר}]
    circle [radius=1.25cm];
\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}

enter image description here

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={מלון אבוקדו מישמש תפוח אבוקדו אבטיח אשכולית גזר}]
    circle [radius=1cm];
\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}

enter image description here

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}]
    circle [radius=1.1212cm];
\foreach \w [count=\i from 0] in {apple, banana, celary, date, egg, fig, grape, honey}
    \node [stack node text, anchor=north, shift=(\i*45:1.3636cm), rotate=\i*45+90] {\w};

\end{tikzpicture}


\end{document}

enter image description here

share|improve this answer
    
Thank you, this is an excellent start and mostly answers my original question. A couple of specifics: 1) How would I go about rotating the text in the middle circle so that the baseline is inside rather than outside? and 2) Is it possible to rotate the orientation of the characters in on the radial lines by 90 degrees so that they look like they're stacked on top of each other vertically? A Roman alphabet example would be just fine; just going for the basic mechanics now. (Those two things are all I need to get the full range of possibilities here.) Thanks again for all your help so far! –  Isaac Apr 4 '13 at 16:08
    
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
    
Excellent, many thanks! –  Isaac Apr 8 '13 at 22:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.