使用 TikZ 时未定义的控制序列

使用 TikZ 时未定义的控制序列

我查找了如何使用 TikZ 制作使用鱼尾纹符号的 ERD,并找到了。当我复制那里提供的代码时,没有任何问题,但是当将序言粘贴到我的代码中并将文档代码粘贴到文档部分时,我得到了使用 的每一行的一长串错误列表\draw

其中大部分都与单位使用错误有关。修复这些错误后,我最终得到了底部的序言。但是我仍然收到“未定义控制序列”错误,我似乎无法修复。此外,即使我收到错误,我的最终 .pdf.document 也可以正常编译,我觉得这很奇怪。

谁能告诉我什么地方出了问题?

编辑:Marijn,指出我刚刚忘记了 \makeatletter% Crowsfoot notation。添加它并撤消我所做的更改解决了这个问题。可以找到需要它的解释这里

\documentclass[a4paper,11pt,openany, oneside]{memoir}
\let\footruleskip\undefined %footruleskip is set to undefined because both momoir and fancyhdr defines this
\usepackage{fancyhdr} % includes fancy to control header and footer
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{color}
\usepackage{amsfonts}
\usepackage{placeins} % Controls floats
\usepackage{pgf-umlsd} % UML and sequence diagrams
\usepackage{enumitem} % to enable roman letters in alternate usecase flows
% TiKz packages to diagrams
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\usetikzlibrary{shadows}
\usetikzlibrary{calc}
% Definition of state for a statemachine
\tikzset{
    state/.style={
        rectangle,
        rounded corners,
        draw=black, very thick,
        minimum height=2em,
        inner sep=2pt,
        text centered,
    },
    %Definition af initial node
    initiator/.style={
        circle,
        draw,
    } 
}

% Crowsfoot notation 

\pgfarrowsdeclare{crow's foot}{crow's foot}
{
    \pgfarrowsleftextend{+-.5\pgflinewidth}%
    \pgfarrowsrightextend{+.5\pgflinewidth}%
}
{
    \pgfutil@tempdima=0.5pt%
    %   \advance\pgfutil@tempdima by .25\pgflinewidth%
    \pgfsetdash{}{+0pt}%
    \pgfsetmiterjoin%
    \pgfpathmoveto{\pgfqpoint{0pt}{-6pt\pgfutil@tempdima}}%
    \pgfpathlineto{\pgfqpoint{-6pt\pgfutil@tempdima}{+0pt}}%
    \pgfpathlineto{\pgfqpoint{0pt}{6pt\pgfutil@tempdima}}%
    \pgfusepathqstroke%
}

{
    \pgfpathmoveto{\pgfpoint{-2pt}{0pt}}
    \pgfpatharc{150}{30}{1.8pt}
    \pgfpatharc{-30}{-150}{1.8pt}
    \pgfusepathqfill
}





\tikzset{
    entity/.code={
        \tikzset{
            label=above:#1,
            name=#1,
            inner sep=0pt,
            every entity/.try,
            fill=white,
            general shadow={
                shadow xshift=0.0625in,
                shadow yshift=-0.0625in,
                opacity=0.5,
                fill=black!50
            }
        }%
        \def\entityname{#1}%
    },
    entity anchor/.style={matrix anchor=#1.center},
    every entity/.style={
        draw,
    },
    every property/.style={
        inner xsep=0.25cm, inner ysep=0.125cm, anchor=west, text width=1in
    },
    zig zag to/.style={
        to path={(\tikztostart) -| ($(\tikztostart)!#1!(\tikztotarget)$) |- (\tikztotarget)}
    },
    zig zag to/.default=0.5,
    one to many/.style={
        -crow's foot, zig zag to
    },
    many to one/.style={
        crow's foot-, zig zag to
    },
    many to many/.style={
        crow's foot-crow's foot, zig zag to
    }
}
\def\property#1{\node[name=\entityname-#1, every property/.try]{#1};}
\def\properties{\begingroup\catcode`\_=11\relax\processproperties}
\def\processproperties#1{\endgroup%
    \def\propertycode{}%
    \foreach \p in {#1}{%
        \expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\propertycode%
        \expandafter\expandafter\expandafter{\expandafter\propertycode\expandafter\property\expandafter{\p}\\}%
    }%
    \propertycode%
}
% /Crow's foot notation



\begin{document}

\begin{tikzpicture}[every node/.style={font=\ttfamily}, node distance=1.25in]
\matrix [entity=Class] {
    \properties{
        classkey, 
        class_type,
        class_desc
    }
};

\matrix [entity=Product, right=of Class-classkey, entity anchor=Product-classkey]  {
    \properties{
        classkey, 
        prodkey, 
        prod_name, 
        pkg_type
    }
};

\matrix  [entity=Sales, right=of Product-classkey, entity anchor=Sales-classkey]  {
    \properties{
        perkey,
        classkey,
        prodkey,
        prod_name, 
        storekey,
        promokey, 
        quantity,
        dollars
    }
};

\matrix  [entity=Period, right=of Sales-perkey, entity anchor=Period-perkey]  {
    \properties{
        perkey,
        date,
        day,
        week,
        month,
        qtr,
        year
    }
};

\matrix  [entity=Promotion, below=of Period, entity anchor=Promotion-promokey]  {
    \properties{
        promokey,
        promo_type,
        promo_desc,
        value,
        start_date,
        end_date
    }
};

\matrix  [entity=Store, below=of Product, entity anchor=Store-storekey]  {
    \properties{
        storekey,
        mktkey,
        store_type,
        store_name,
        street,
        city,
        state,
        zip
    }
};

\matrix  [entity=Market, left=of Store-mktkey, entity anchor=Market-mktkey]  {
    \properties{
        mktkey,
        hq_city,
        hq_state,
        district,
        region
    }
};

\draw [one to many] (Class-classkey)   to (Product-classkey);
\draw [one to many] (Product-classkey) to (Sales-classkey);
\draw [one to many] (Product-prodkey)  to (Sales-prodkey);
\draw [many to one] (Sales-perkey)     to (Period-perkey);
\draw [one to many] (Market-mktkey)    to (Store-mktkey);
\draw [many to one] (Sales-storekey)   to (Store-storekey);
\draw [many to one] (Sales-promokey)   to (Promotion-promokey);

\end{tikzpicture}

\end{document}

这是错误输出:

Undefined control sequence. ...] (Product-classkey) to (Sales-classkey);
Undefined control sequence. ...] (Product-classkey) to (Sales-classkey);
Undefined control sequence. ...] (Product-classkey) to (Sales-classkey);
Undefined control sequence. ...] (Product-classkey) to (Sales-classkey);
Overfull \hbox (136.25331pt too wide) in paragraph

相关内容