Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to draw the following E-R diagram:

enter image description here

I am using the TikZ-er2 package. The package is available here. Now, I have completed almost 50% of the drawing. But, my TikZ picture appears in page 2 (article class and I have put landscape mode) and when the diagram is extended, it cuts off. How do I proceed? And I want to label my drawing as well. I can have a separate node for that, but are there any other ways.

Here is what I have done:

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

enter image description here

share|improve this question
    
First: don't use tikzstyle, but tikzset for your styles. Second: have a look to How to scale a tikzpicture including texts?, How to scale a tikzpicture to \textwidth and pgfplots: how can I scale to text width? –  Claudio Fiandrino Mar 8 at 9:04

2 Answers 2

up vote 4 down vote accepted

You have quite a few options:

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

Second put your tikzpicture inside adjustbox environment from adjustbox package:

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

Here the advantage is the picture is resized only if it exceeds a max height of 0.9\textheight

Third, is to adjust each node distance instead of globally giving a value as you did. This is left to yourself.

Note that I have changed tikzstyles (which are deprecated) to tikzset and added positioning library and changed all instances of of = to = of.

share|improve this answer

This is a possible solution where landscape feature from geometry is used and \resizeboxis used to 0.8\textwidth to prevent cutoff. style format are defined in tikzset.

enter image description here

Code:

\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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.