我想绘制以下ER图:
我正在使用 TikZ-er2 软件包。该软件包可用这里。现在,我已经完成了近 50% 的绘图。但是,我的 TikZ 图片出现在第 2 页(文章类,我已将其设置为横向模式),并且当图表扩展时,它会被切断。我该怎么做?我还想为我的绘图添加标签。我可以为此设置一个单独的节点,但还有其他方法吗?
以下是我所做的:
\documentclass[12pt]{article}
\usepackage{tikz-er2}
\usepackage{lscape}
\usetikzlibrary{shadows}
\begin{document}
\tikzstyle{every entity} = [top color=white,bottom color=blue!30,draw=blue!50!black!100,drop shadow]
\tikzstyle{every attribute} = [top color=white, bottom color=yellow!20,
draw=yellow, drop shadow]
\tikzstyle{every relationship} = [top color=white, bottom color=red!20,
draw=red!50!black!100, drop shadow]
\tikzstyle{every edge} = [link]
\tikzstyle{every isa} = [top color=white, bottom color=green!20,
draw=green!50!black!100, drop shadow]
\begin{landscape}
\begin{tikzpicture}[node distance=10em]
\node[entity] (student) {Student};
\node[isa] (isa1) [below of=student, node distance=5em] {ISA} edge node [auto,swap] {disjoint} (student);
\node[entity] (mtech-stud) [below left of=isa1] {MTech$-$student} edge (isa1);
\node[attribute] (btechproj) [below left of=mtech-stud] {No.-of-BTech-Projects} edge (mtech-stud);
\node[entity] (btech-stud) [below of=isa1] {BTech$-$student} edge (isa1);
\node[entity] (phd-stud) [below right of=isa1] {Ph.D.$-$student} edge (isa1);
\node[attribute] (stud-id) [left of=student] {\key{student-id}} edge (student);
\node[attribute] (name) [above left of=student] {Name} edge (student);
\node[attribute] (fname) [above left of=name] {First-Name} edge (name);
\node[attribute] (lname) [above right of=name] {Last-Name} edge (name);
\node[attribute] (cgpa) [above right of=student] {CGPA} edge (student);
\node[relationship] (joins) [right of=student] {joins} edge [total] (student);
\node[entity] (pgroup) [right of=joins] {Project-Group} edge [<-] (joins);
\node[attribute] (group-id) [above left of=pgroup] {\key{group-id}} edge (pgroup);
\node[derived attribute] (group-cgpa) [above right of=group-id] {group-CGPA} edge (pgroup);
\node[multi attribute] (areas) [above right of=group-cgpa] {areas-of-interest} edge (pgroup);
\node[relationship] (pgroup-guide) [right of=pgroup] {Project-Group-Guide} edge (pgroup);
\end{tikzpicture}
\end{landscape}
\end{document}
答案1
您有很多选择:
首次使用\resizebox
\documentclass[12pt]{article}
\usepackage{tikz-er2}
\usepackage{pdflscape} %% helps to see in upright direction in pdf
\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}
\resizebox{!}{0.9\textheight}{\begin{tikzpicture}[node distance=10em]
\node[entity] (student) {Student};
\node[isa] (isa1) [below = of student, node distance=5em] {ISA} edge node [auto,swap] {disjoint} (student);
\node[entity] (mtech-stud) [below left = of isa1] {MTech$-$student} edge (isa1);
\node[attribute] (btechproj) [below left = of mtech-stud] {No.-of-BTech-Projects} edge (mtech-stud);
\node[entity] (btech-stud) [below = of isa1] {BTech$-$student} edge (isa1);
\node[entity] (phd-stud) [below right = of isa1] {Ph.D.$-$student} edge (isa1);
\node[attribute] (stud-id) [left = of student] {\key{student-id}} edge (student);
\node[attribute] (name) [above left = of student] {Name} edge (student);
\node[attribute] (fname) [above left = of name] {First-Name} edge (name);
\node[attribute] (lname) [above right = of name] {Last-Name} edge (name);
\node[attribute] (cgpa) [above right = of student] {CGPA} edge (student);
\node[relationship] (joins) [right = of student] {joins} edge [total] (student);
\node[entity] (pgroup) [right = of joins] {Project-Group} edge [<-] (joins);
\node[attribute] (group-id) [above left = of pgroup] {\key{group-id}} edge (pgroup);
\node[derived attribute] (group-cgpa) [above right = of group-id] {group-CGPA} edge (pgroup);
\node[multi attribute] (areas) [above right = of group-cgpa] {areas-of-interest} edge (pgroup);
\node[relationship] (pgroup-guide) [right = of pgroup] {Project-Group-Guide} edge (pgroup);
\end{tikzpicture}
}
\end{landscape}
\end{document}
其次从包中放入你的tikzpicture
内部adjustbox
环境:adjustbox
\documentclass[12pt]{article}
\usepackage{tikz-er2}
\usepackage{pdflscape} %% helps to see in upright direction in pdf
\usepackage{adjustbox}
\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}
\begin{adjustbox}{max height=0.9\textwidth}
\begin{tikzpicture}[node distance=10em]
\node[entity] (student) {Student};
\node[isa] (isa1) [below = of student, node distance=5em] {ISA} edge node [auto,swap] {disjoint} (student);
\node[entity] (mtech-stud) [below left = of isa1] {MTech$-$student} edge (isa1);
\node[attribute] (btechproj) [below left = of mtech-stud] {No.-of-BTech-Projects} edge (mtech-stud);
\node[entity] (btech-stud) [below = of isa1] {BTech$-$student} edge (isa1);
\node[entity] (phd-stud) [below right = of isa1] {Ph.D.$-$student} edge (isa1);
\node[attribute] (stud-id) [left = of student] {\key{student-id}} edge (student);
\node[attribute] (name) [above left = of student] {Name} edge (student);
\node[attribute] (fname) [above left = of name] {First-Name} edge (name);
\node[attribute] (lname) [above right = of name] {Last-Name} edge (name);
\node[attribute] (cgpa) [above right = of student] {CGPA} edge (student);
\node[relationship] (joins) [right = of student] {joins} edge [total] (student);
\node[entity] (pgroup) [right = of joins] {Project-Group} edge [<-] (joins);
\node[attribute] (group-id) [above left = of pgroup] {\key{group-id}} edge (pgroup);
\node[derived attribute] (group-cgpa) [above right = of group-id] {group-CGPA} edge (pgroup);
\node[multi attribute] (areas) [above right = of group-cgpa] {areas-of-interest} edge (pgroup);
\node[relationship] (pgroup-guide) [right = of pgroup] {Project-Group-Guide} edge (pgroup);
\end{tikzpicture}
\end{adjustbox}
\end{landscape}
\end{document}
这里的优点是,只有当图片超过最大高度时,才会调整图片大小0.9\textheight
第三,调整每个节点的距离,而不是像你那样全局地给出一个值。这个留给你自己吧。
请注意,我已将tikzstyle
s (已弃用) 更改为 ,tikzset
并添加了positioning
库并将 的所有实例更改of =
为= of
。
答案2
这是一个可能的解决方案,其中使用landscape
特征并将其用于 0.8以防止截止。样式格式在 中定义。geometry
\resizebox
\textwidth
tikzset
代码:
\documentclass[12pt]{article}
\usepackage{tikz-er2}
\usepackage[landscape,margin=1cm]{geometry}
%\usepackage{lscape}
\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 edg/.style={link},
every isa/.style = {top color=white, bottom color=green!20,draw=green!50!black!100, drop shadow}
}
%\begin{landscape}
\resizebox{0.8\textwidth}{!}{%
\begin{tikzpicture}[scale=0.5]
\node[entity] (student) {Student};
\node[isa] (isa1) [below = 1cm of student] {ISA} edge node [auto,swap] {disjoint} (student);
\node[entity] (mtech-stud) [below left = 2em and 3em of isa1] {MTech$-$student} edge (isa1);
\node[attribute] (btechproj) [below left= 2em and -5em of mtech-stud] {No-BTech-Projs} edge (mtech-stud);
\node[entity] (btech-stud) [below = 0.2 em of isa1] {BTech$-$student} edge (isa1);
\node[entity] (phd-stud) [below right = 2em and 3em of isa1] {Ph.D.$-$student} edge (isa1);
\node[attribute] (btechproj1) [below left = 2em and -2em of phd-stud] {No-BTech-Projs} edge (phd-stud);
\node[attribute] (btechproj2) [below right = 2em and -2em of phd-stud] {No-BTech-Projs} edge (phd-stud);
\node[attribute] (stud-id) [above left = 2em of student] {\key{student-id}} edge (student);
\node[attribute] (name) [above = 2em of student] {Name} edge (student);
\node[attribute] (fname) [above left = 2em of name] {First-Name} edge (name);
\node[attribute] (lname) [above right =2em of name] {Last-Name} edge (name);
\node[attribute] (cgpa) [above right = 2em of student] {CGPA} edge (student);
\node[relationship] (joins) [right = 2cm of student] {joins} edge [total] node[above ]{1...1} (student) ;
\node[entity] (pgroup) [right = 2cm of joins] {Project-Group} edge [] node[above ]{1...1} (joins);
\node[relationship] (pgroup-guide) [right = 3cm of pgroup] {Project-Group-Guide} edge node[above ]{1...1} (pgroup);
\node[attribute] (group-id) [above left =1em and 1em of pgroup-guide] {\key{Porject-Domain}} edge (pgroup-guide);
\node[attribute] (group-cgpa) [above right = 1em and 1em of pgroup-guide] {\key{Porject-title}} edge (pgroup-guide);
\node[attribute] (group-id) [below left =1em and 1em of pgroup] {\key{group-id}} edge (pgroup);
\node[derived attribute] (group-cgpa) [below = 4em of pgroup] {group-CGPA} edge (pgroup);
\node[multi attribute] (areas) [below right= 1em and 1em of pgroup] {areas-of-interest} edge (pgroup);
\node[entity] (faculty) [right = 1cm of pgroup-guide] {Faculty} edge node[above ]{1...1} (pgroup-guide);
\node[attribute] (name1) [right = 2em of faculty] {Name} edge (faculty);
\node[attribute] (fsc-id) [above = 2em of name1] {\key{Fsc-ID}} edge (faculty);
\node[multi attribute] (special) [below = 2em of name1] {Specialization} edge (faculty);
\node[attribute] (email) [below = 5em of special] {E-mail} edge (faculty);
\node[multi attribute] (phones) [below = 4em of email] {Phones} edge (faculty);
\node[attribute] (fname) [above right= 0.1em and 1em of name1] {First-Name} edge (name1);
\node[attribute] (lname) [below right= 0.1em and 1em of name1] {Last-Name} edge (name1);
\end{tikzpicture}
}
%\end{landscape}
\end{document}