以圓形排列排版直線基線

以圓形排列排版直線基線

我想知道如何設定所看到的圓形排列這裡在圖「(2)」中-即從中心點輻射出的一系列直線。

文字的圓形排列

到目前為止我能找到的最有用的東西是旋轉字母(或多或少是一個徹底的教程)在graphicx包裝上。我確信通過graphicxhspace和命令的極其艱鉅的組合是可行的vspace,但我希望有人可能知道一個更優雅的解決方案。

(我本來想問另一種帶有圓形基線的類型,但是如何微調文字沿圓形路徑的旋轉?似乎已經相當廣泛地澄清了這一點。

更新:非常感謝姆維布羅謝謝你們讓我大部分時間都到了那裡,並付出了額外的努力來處理希伯來字符!只是想讓其他可能想要參與其他想法的人知道羅馬字符足以作為進一步的示例。

答案1

當涉及從右到左的語言時,裝飾並不是那麼通用,但以下顯示了一種處理方法。它需要使用 進行編譯lualatex。也許PSTricks可以做得更好。

另外,我使用的字體freesans可能在您的系統上可用,也可能無法使用。

\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}

在此輸入影像描述

為了獲得內部的基線,reverse path可以將鑰匙與裝飾一起使用。請注意,此鍵的成功使用取決於內部如何繪製圓的路徑(即順時針)。如果使用四個弧線逆時針手動繪製圓,則reverse path不需要關鍵點(當然,如果裝飾引擎的作者足夠聰明,他會找到一種自動確定路徑方向的方法;-)

我能想到的堆疊字母的唯一方法是粗略地迭代單字的每個字母,這是我使用巨集完成的\stackletters。請注意,align關鍵必須在選項中使用\node以使堆疊發揮作用。還要注意變化anchor和旋轉。

若要沿著另一個方向(即向內)堆疊,請將 變更為anchorsouth然後使用rotate=\i*45-90。這可以與一種風格聯繫起來。

\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}

在此輸入影像描述

因此,根據要求,帶有羅馬字符的版本不需要lualatex.用於堆疊節點內容的程式碼已進行了一些更改。

\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}

在此輸入影像描述

相關內容