标记 TikZ 图表 - 问题

标记 TikZ 图表 - 问题

我想标记我的 TikZ ER 图。figure环境显示错误(想要使用标题)。所以我在所需位置创建了一个节点。但是,图形的大小现在减小了。我尝试缩放,但没有改善。我想标记我的图表。请帮帮我。

以下是代码:

\documentclass[12pt]{article}
\usepackage{tikz-er2}
\usepackage{pdflscape}
\usepackage{adjustbox}
\usepackage{ulem}
\usetikzlibrary{shadows,positioning}
\begin{document}
\tikzset{
    every entity/.style = {top color=white,bottom color=blue!30,draw=blue!50!black!100,drop shadow},
    every attribute/.style = {top color=white, bottom color=yellow!20,
                                  draw=yellow, drop shadow},
    every relationship/.style ={top color=white, bottom color=red!20,
                                  draw=red!50!black!100, drop shadow},
    every edge/.style = {link},
    every isa/.style = {top color=white, bottom color=green!20,
                                  draw=green!50!black!100, drop shadow},
}
\begin{landscape}
\vspace*{\stretch{1}}
\thispagestyle{empty}
\begin{adjustbox}{max height=0.5\textwidth}
\begin{tikzpicture}[node distance=10em]
    \node[entity] (student) at (-2,0) {Student};
    \node[isa] (isa1) [below = 2em of student, node distance=5em] {ISA} edge node [auto,swap] {disjoint} (student);
    \node[entity] (mtech-stud) [below left = 2em of isa1] {MTech$-$student} edge (isa1);
    \node[attribute] (btechproj) [below left = 2em and 0em of mtech-stud] {No.-of-BTech-Projects} edge (mtech-stud);
    \node[entity] (btech-stud) [below = 5em of isa1] {BTech$-$student} edge (isa1);
    \node[entity] (phd-stud) [below right = 2em of isa1] {Ph.D.$-$student} edge (isa1);
    \node[attribute] (btechproj1) [above right = 2em of phd-stud] {No.-of-BTech-Projects} edge (phd-stud);
    \node[attribute] (mtechproj) [below right = 2em of phd-stud] {No.-of-MTech-Projects} edge (phd-stud);
    \node[attribute] (stud-id) [left = 0.5cm of student] {\key{student-id}} edge (student);
    \node[attribute] (name) [above left = 0.75cm and -0.5cm of student] {Name} edge (student);
    \node[attribute] (fname) [above left = 0.75cm and 0cm of name] {First-Name} edge (name);
    \node[attribute] (lname) [above right = 0.75cm and 0cm of name] {Last-Name} edge (name);
    \node[attribute] (cgpa)  [above right = 0.75cm and -0.5cm of student] {CGPA} edge (student);
    \node[relationship] (joins) [right = 1.4cm of student] {joins} edge [total] (student);
    \node[entity] (pgroup) [right = 1.4cm of joins] {Project-Group} edge [<-] (joins);
    \node[attribute] (group-id) [above left = 0.75cm and -0.5cm of pgroup] {\key{group-id}} edge (pgroup);
    \node[derived attribute] (group-cgpa) [above = 2cm of pgroup] {group-CGPA} edge (pgroup);
    \node[multi attribute] (areas) [above right = 0.75cm and -0.5cm of pgroup] {areas-of-interest} edge (pgroup);
    \node[relationship] (pgroup-guide) [right = 2.2cm of pgroup] {Project-Group-Guide} edge[<->] (pgroup);
    \node[attribute] (pdomain) [above = 2cm  of pgroup-guide] {Project-Domain} edge (pgroup-guide);
    \node[attribute] (ptitle) [below = 2cm of pgroup-guide] {Project-Title} edge (pgroup-guide);
    \node[entity] (faculty) [right = 1.9cm of pgroup-guide] {Faculty} edge[<->] (pgroup-guide);
    \node[attribute] (facid) [above left = 0.75cm and -0.5cm of faculty] {\key{faculty-d}} edge (faculty);
    \node[attribute] (name) [above = 1.7cm of faculty] {Name} edge (faculty);
    \node[attribute] (fname) [above left = 0.75cm and 0cm of name] {First-Name} edge (name);
    \node[attribute] (lname) [above right = 0.75cm and 0cm of name] {Last-Name} edge (name);
    \node[multi attribute] (specialisation) [above right = 0.75cm and -0.5cm of faculty] {Specialisation} edge (faculty);
    \node[attribute] (email) [below left = 0.75cm and -0.5cm of faculty] {Email} edge (faculty);
    \node[multi attribute] (phoneno) [below right = 0.75cm and -0.5cm of faculty] {Phone-no} edge (faculty);
    %\node[below = 10cm of pgroup] {\uline{some text}};
\end{tikzpicture}
\end{adjustbox}
\vspace{\stretch{1}}
\end{landscape}
\end{document}

我得到了这个:

在此处输入图片描述

在我放置节点之后(删除注释之后)。我得到的结果如下: 在此处输入图片描述

答案1

图表的尺寸缩小了,因为您在下方添加了标题,但所有adjustbox比例都放在一起。

不影响框缩放的一个可能的解决方案是将标题节点放置tikzpicture在其自己的tikzpicture环境中。使用remember pictureoverlay选项可以引用图中的节点,并且不添加空间。

\begin{tikzpicture}[node distance=10em, remember picture]
    \node[entity] (student) at (-2,0) {Student};
    ...
\end{tikzpicture}
\end{adjustbox}
\begin{tikzpicture}[overlay, remember picture]
  \node[below = 10cm of pgroup] {\uline{some text}};
\end{tikzpicture}

请注意,我强烈建议使用figurecaption,尽管您的问题是关于缩放而没有参考之前的错误figure

没有错误:

\documentclass[12pt]{article}
\usepackage{tikz-er2}
\usepackage{pdflscape}
\usepackage{adjustbox}
\usepackage{ulem}
\usetikzlibrary{shadows,positioning}
\begin{document}
<\tikzset{
    every entity/.style = {top color=white,bottom color=blue!30,draw=blue!50!black!100,drop shadow},
    every attribute/.style = {top color=white, bottom color=yellow!20,
                                  draw=yellow, drop shadow},
    every relationship/.style ={top color=white, bottom color=red!20,
                                  draw=red!50!black!100, drop shadow},
    every edge/.style = {link},
    every isa/.style = {top color=white, bottom color=green!20,
                                  draw=green!50!black!100, drop shadow},
}
\begin{landscape}
\vspace*{\stretch{1}}
\thispagestyle{empty}
\begin{figure}[!htbp]
\begin{adjustbox}{max height=0.5\textwidth}
\begin{tikzpicture}[node distance=10em,remember picture]
    \node[entity] (student) at (-2,0) {Student};
    \node[isa] (isa1) [below = 2em of student, node distance=5em] {ISA} edge node [auto,swap] {disjoint} (student);
    \node[entity] (mtech-stud) [below left = 2em of isa1] {MTech$-$student} edge (isa1);
    \node[attribute] (btechproj) [below left = 2em and 0em of mtech-stud] {No.-of-BTech-Projects} edge (mtech-stud);
    \node[entity] (btech-stud) [below = 5em of isa1] {BTech$-$student} edge (isa1);
    \node[entity] (phd-stud) [below right = 2em of isa1] {Ph.D.$-$student} edge (isa1);
    \node[attribute] (btechproj1) [above right = 2em of phd-stud] {No.-of-BTech-Projects} edge (phd-stud);
    \node[attribute] (mtechproj) [below right = 2em of phd-stud] {No.-of-MTech-Projects} edge (phd-stud);
    \node[attribute] (stud-id) [left = 0.5cm of student] {\key{student-id}} edge (student);
    \node[attribute] (name) [above left = 0.75cm and -0.5cm of student] {Name} edge (student);
    \node[attribute] (fname) [above left = 0.75cm and 0cm of name] {First-Name} edge (name);
    \node[attribute] (lname) [above right = 0.75cm and 0cm of name] {Last-Name} edge (name);
    \node[attribute] (cgpa)  [above right = 0.75cm and -0.5cm of student] {CGPA} edge (student);
    \node[relationship] (joins) [right = 1.4cm of student] {joins} edge [total] (student);
    \node[entity] (pgroup) [right = 1.4cm of joins] {Project-Group} edge [<-] (joins);
    \node[attribute] (group-id) [above left = 0.75cm and -0.5cm of pgroup] {\key{group-id}} edge (pgroup);
    \node[derived attribute] (group-cgpa) [above = 2cm of pgroup] {group-CGPA} edge (pgroup);
    \node[multi attribute] (areas) [above right = 0.75cm and -0.5cm of pgroup] {areas-of-interest} edge (pgroup);
    \node[relationship] (pgroup-guide) [right = 2.2cm of pgroup] {Project-Group-Guide} edge[<->] (pgroup);
    \node[attribute] (pdomain) [above = 2cm  of pgroup-guide] {Project-Domain} edge (pgroup-guide);
    \node[attribute] (ptitle) [below = 2cm of pgroup-guide] {Project-Title} edge (pgroup-guide);
    \node[entity] (faculty) [right = 1.9cm of pgroup-guide] {Faculty} edge[<->] (pgroup-guide);
    \node[attribute] (facid) [above left = 0.75cm and -0.5cm of faculty] {\key{faculty-d}} edge (faculty);
    \node[attribute] (name) [above = 1.7cm of faculty] {Name} edge (faculty);
    \node[attribute] (fname) [above left = 0.75cm and 0cm of name] {First-Name} edge (name);
    \node[attribute] (lname) [above right = 0.75cm and 0cm of name] {Last-Name} edge (name);
    \node[multi attribute] (specialisation) [above right = 0.75cm and -0.5cm of faculty] {Specialisation} edge (faculty);
    \node[attribute] (email) [below left = 0.75cm and -0.5cm of faculty] {Email} edge (faculty);
    \node[multi attribute] (phoneno) [below right = 0.75cm and -0.5cm of faculty] {Phone-no} edge (faculty);
\end{tikzpicture}
\end{adjustbox}
\caption{\uline{some text}}
\end{figure}
\vspace{\stretch{1}}
\end{landscape}
\end{document}

相关内容