在 texmaker 中绘制一张显示装饰错误的图片

在 texmaker 中绘制一张显示装饰错误的图片

这是我想要在 Tex Maker 中使用的代码。

\documentclass[12pt]{report}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{decorations}



\begin{document}

\begin{tikzpicture}[
    black,
    ultra thick,
    planet/.style = {draw,fill,circle,inner,inner },
    circle label/.style = {
        postaction={
            decoration={
                text along path,
                text = {#1},
                text align=center,
                text color=black,
                reverse path,
            },
        decorate,
    }
    }
]
\filldraw[white] (-7,-7) rectangle (9,7);
 {\path[circle label={Abelian}] (0,-2.1) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (1);}
{\path[circle label={Nilpotent}] (0,-1.2) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (2);}
{\path[circle label={O-group}] (0,-0.1) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (3);}
{\path[circle label={RO-group}] (0,+0.9) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (4);}
{\path[circle label={u.p.-group}] (0,+1.85) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (5);}

\end{tikzpicture}
\end{document}

但它向我显示了错误

pgfkeys do not know the key decorations.

我还需要做什么?

答案1

我不记得什么时候,但decorations图书馆被分成了几个图书馆, text along path属于decorations.text图书馆

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}[
    black,
    ultra thick,
    planet/.style = {draw,fill,circle,inner,inner },
    circle label/.style = {
        postaction={
            decoration={
                text along path,
                text = {#1},
                text align=center,
                text color=black,
                reverse path,
            },
        decorate,
    }
    }
]
\filldraw[white] (-7,-7) rectangle (9,7);
 {\path[circle label={Abelian}] (0,-2.1) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (1);}
{\path[circle label={Nilpotent}] (0,-1.2) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (2);}
{\path[circle label={O-group}] (0,-0.1) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (3);}
{\path[circle label={RO-group}] (0,+0.9) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (4);}
{\path[circle label={u.p.-group}] (0,+1.85) arc (-90:360-90:1.2);
\draw[circle] (0,0) circle (5);}

\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:如果您希望标签跟随内圈,我建议将代码更改为

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}[
    black,
    ultra thick,
    planet/.style = {draw,fill,circle,inner,inner },
    circle label/.style = {
        postaction={
            decoration={
                text along path,
                text = {#1},
                text align=center,
                text color=black,
                reverse path,
            },
        decorate,
    }
    }
]

\path[circle label={Abelian}] (0:1.1) arc (0:180:1.1);
\draw[circle] (0,0) circle (1);

\path[circle label={Nilpotent}] (0:2.1) arc (0:180:2.1);
\draw[circle] (0,0) circle (2);

\path[circle label={O-group}] (0:3.1) arc (0:180:3.1);
\draw[circle] (0,0) circle (3);

\path[circle label={RO-group}] (0:4.1) arc (0:180:4.1);
\draw[circle] (0,0) circle (4);

\path[circle label={u.p.-group}] (0:5.1) arc (0:180:5.1);
\draw[circle] (0,0) circle (5);

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

就像 Ignasi 的补充一样,我制作了一个版本,在中间圆的实圆弧部分上设置标签。致谢休斯还有汤姆·邦巴迪尔!

% arara: pdflatex

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{decorations.text,calc}
\def\centerarc[#1](#2)(#3:#4:#5){ \path[#1] ($(#2)+({#5*cos(#3)},{#5*sin(#3)})$) arc (#3:#4:#5); }

\begin{document}    
    \begin{tikzpicture}[%
        ,ultra thick
        ,circle label/.style = {%
            postaction={%
                ,decoration={%
                    ,text along path,
                    ,text = {#1},
                    ,text align=center,
                    ,reverse path,
                    }
                ,decorate
                }
            }
        ]
    \filldraw[white] (-7,-7) rectangle (9,7);
    {\centerarc[circle label={Abelian}](0,0)(0:180:.5)
        \draw[circle] (0,0) circle (1);}
    {\centerarc[circle label={Nilpotent}](0,0)(0:180:1.5)
        \draw[circle] (0,0) circle (2);}
    {\centerarc[circle label={O-group}](0,0)(0:180:2.5)
        \draw[circle] (0,0) circle (3);}
    {\centerarc[circle label={RO-group}](0,0)(0:180:3.5)
        \draw[circle] (0,0) circle (4);}
    {\centerarc[circle label={u.p.-group}](0,0)(0:180:4.5)
        \draw[circle] (0,0) circle (5);}    
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容