워크시트로 빈 상자가 있는 ER 다이어그램

워크시트로 빈 상자가 있는 ER 다이어그램

학생들을 위한 워크시트를 만드는 중입니다. ER 다이어그램에 관한 것입니다. Word를 사용하면 상대적으로 쉽지만 그다지 좋아 보이지는 않습니다.)

나는 이미 ER 다이어그램을 만드는 방법을 알고 있습니다. 제가 갖고 싶은 것은 학생들이 작성해야 하는 분야입니다. 내 코드는 다음과 같습니다.

\documentclass[10pt,letterpaper]{article}
\usepackage[lmargin=1in,rmargin=1in,tmargin=1in,bmargin=1in]{geometry}
\usepackage{tikz-er2}
\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{adjustbox}{width=\columnwidth,center}
\begin{tikzpicture}[node distance=8em]
    \node[entity] (student) {Kunde};
    \node[attribute] (stud-id) [left = of student] {\key{KNR}} edge (student);
    \node[attribute] (name) [above  = of student] {Name} edge (student);
    \node[relationship] (joins) [right = of student] {kauft} edge (student);
    \node[entity] (pgroup) [right = of joins] {Artikel} edge  (joins);
    \node[attribute] (group-id) [above = of pgroup] {Bezeichnung} edge (pgroup);
    \node[attribute] (group-id) [right = of pgroup] {\key{ANR}} edge (pgroup);
\end{tikzpicture}
\end{adjustbox}
\end{document}

결과는 다음과 같습니다.

여기에 이미지 설명을 입력하세요

Word에서는 다음과 같이 표시됩니다.

여기에 이미지 설명을 입력하세요

그렇다면 ER 다이어그램에 빈 상자와 빈 말풍선을 추가하는 방법은 무엇일까요? 당신의 도움에 정말 감사드립니다!

답변1

\TextField[options}{}다음은 from package 를 사용하는 두 번째 버전입니다 hyperref.

추가 구성은 다음을 참조하세요.Ch. 설명서에 9개, 예를 들어 테두리 색상을 변경합니다. (해당 콜아웃 노드에 대해 설정할 수도 있습니다 inner sep=0pt.)

이제 학생들은 답변을 입력하고 PDF를 저장한 후 교사에게 보낼 수 있습니다. 당신은 그것을 읽을 수도 있고, 어떤 식으로든 그들의 답을 추출할 수도 있습니다.

변경사항:

  • \usepackage{hyperref}
  • 다음 두 노드에 한 줄과 여러 줄의 TextField를 추가했습니다.
...
    % ~~~ callouts ~~~~~~~~~~~~~~~~~~~
    \node[ca,callout absolute pointer={(stud-id.330)}] 
                        at ([shift=(-50:15mm)]stud-id) {\TextField[name=q1]{}};
                        
    \node[ca,callout absolute pointer={(name.west)},anchor=east,fill=teal!20]
                        at ([shift=(180:15mm)]name) {\TextField[name=q2, width=22mm, height=10mm, multiline=true]{}};
...

뷰어(FireFox)에서 답변을 입력하거나 검토하세요.

결과

%\documentclass[10pt,letterpaper]{article}
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage[lmargin=1in,rmargin=1in,tmargin=1in,bmargin=1in]{geometry}
\usepackage{tikz-er2}   % https://github.com/harrisony/tikz-er2/blob/usyd/tikz-er2.sty
%\usepackage{adjustbox}
\usetikzlibrary{shadows,positioning}
\usetikzlibrary{shapes.callouts}
\usepackage{hyperref}

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\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{adjustbox}{width=\columnwidth,center}
  \begin{tikzpicture}[
    node distance=8em,
    ca/.style={draw,rectangle callout,minimum width=3cm,minimum height=10mm},
  ]
    % ~~~ ER-diagram ~~~~~~~~~~~~~~~~~~~~~~~~~~
    \node[entity]       (student)                       {Kunde};
    \node[attribute]    (stud-id)   [left  = of student]{\key{KNR}}     edge (student);
    \node[attribute]    (name)      [above = of student]{Name}      edge (student);
    \node[relationship] (joins)     [right = of student]{kauft}         edge (student);
    \node[entity]       (pgroup)    [right = of joins]  {Artikel}       edge  (joins);
    \node[attribute]    (group-id)  [above = of pgroup] {Bezeichnung}   edge (pgroup);
    \node[attribute]    (group-id)  [right = of pgroup] {\key{ANR}}     edge (pgroup);
       
    % ~~~ callouts ~~~~~~~~~~~~~~~~~~~
    \node[ca,callout absolute pointer={(stud-id.330)}] 
                        at ([shift=(-50:15mm)]stud-id) {\TextField[name=q1]{}};
                        
    \node[ca,callout absolute pointer={(name.west)},anchor=east,fill=teal!20]
                        at ([shift=(180:15mm)]name) {\TextField[name=q2, width=22mm, height=10mm, multiline=true]{}};
                        
    \node[ca,callout absolute pointer={(joins.south)},anchor=north,dashed,draw=purple]
                        at ([yshift=-20mm, xshift=5mm)]joins) {};
  \end{tikzpicture}
%\end{adjustbox}
\end{document}

답변2

한번 해볼 수 있는 방법이 있어요tikz-er2.sty 예를 들어 다음에서 문서 디렉토리로 다운로드하면 됩니다.깃허브.

몇 가지 참고사항:

  • 코드 노이즈를 미리 줄였습니다 ;-)
  • 라이브러리를 사용하고 shapes.callouts(그리고 pgfmanual에서 찾아보세요)
  • {}콜아웃 관련 스타일을 사용하여 빈 텍스트가 있는 노드 위치 지정
  • 절대 포인터를 사용하여 노드 이름(내가 찾은 이름)을 재사용하고 콜아웃을 한 방향 또는 다른 방향으로 이동했습니다.
  • 노드 스타일의 리팩토링은 계속될 수 있고 계속되어야 합니다. 예를 들어 일부 스타일로 교체해야 합니다.\newcommand
  • 여기서는 비슷한 스타일 패턴을 반복하면서 어느 정도 읽기 쉬운 코드로 제한했습니다.
  • 평소와 같이 스타일 Tikz을 로컬에서 덮어쓸 수 있습니다.tealdashed
  • 그림을 개발할 때 나는 수업을 선호합니다 standalone. 필요에 따라 주석을 달거나 패키지를 통해 경로를 따르십시오.graphicx .이 쿼리를 통해 예제를 찾으세요

결과

%\documentclass[10pt,letterpaper]{article}
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage[lmargin=1in,rmargin=1in,tmargin=1in,bmargin=1in]{geometry}
\usepackage{tikz-er2}   % https://github.com/harrisony/tikz-er2/blob/usyd/tikz-er2.sty
%\usepackage{adjustbox}
\usetikzlibrary{shadows,positioning}
\usetikzlibrary{shapes.callouts}

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\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{adjustbox}{width=\columnwidth,center}
  \begin{tikzpicture}[
    node distance=8em,
    ca/.style={draw,rectangle callout,minimum width=3cm,minimum height=10mm},
  ]
    % ~~~ ER-diagram ~~~~~~~~~~~~~~~~~~~~~~~~~~
    \node[entity]       (student)                       {Kunde};
    \node[attribute]    (stud-id)   [left  = of student]{\key{KNR}}     edge (student);
    \node[attribute]    (name)      [above = of student]{Name}      edge (student);
    \node[relationship] (joins)     [right = of student]{kauft}         edge (student);
    \node[entity]       (pgroup)    [right = of joins]  {Artikel}       edge  (joins);
    \node[attribute]    (group-id)  [above = of pgroup] {Bezeichnung}   edge (pgroup);
    \node[attribute]    (group-id)  [right = of pgroup] {\key{ANR}}     edge (pgroup);
       
    % ~~~ callouts ~~~~~~~~~~~~~~~~~~~
    \node[ca,callout absolute pointer={(stud-id.330)}] 
                        at ([shift=(-50:15mm)]stud-id) {};
                        
    \node[ca,callout absolute pointer={(name.west)},anchor=east,fill=teal!20]
                        at ([shift=(180:15mm)]name) {};
                        
    \node[ca,callout absolute pointer={(joins.south)},anchor=north,dashed,draw=purple]
                        at ([yshift=-20mm, xshift=5mm)]joins) {};
  \end{tikzpicture}
%\end{adjustbox}
\end{document}

관련 정보