5

I need to create a large diagram i.e. a diagram of custom subject correlativities but I am not able to do certain things. To do this I am going to use TikZ.

Ingredients

The ingredients are:

  1. A title. There is not much to say.
  2. Subjects. To create these objects I will use the source code of this very helpful answer:

    Subject picture

  3. Big rectangles. Every rectangle will indicate the year (a.k.a. level) in which the subjects are grouped:

    Rectangle

  4. Arrows. They relate the subjects within the same year of the curriculum and even between different years:

    Arrow

How things are assembled

  1. The subjects are grouped within a rectangle (year career).
  2. Two subjects can be related in the same year, or in different years. The relation between subjects of the same year are always side by side (one on the left, one on the right).

What I have done

MWE:

\documentclass{article}
\usepackage[showframe,margin=0in,footskip=0.25in,paperwidth=100cm,paperheight=20cm]{geometry}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{hyperref}
\usepackage{tikz}
\tikzset{text field/.style={text height=1.5ex,align=center,rounded corners},
title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=4.5cm,align=center,font=\footnotesize\sffamily},
pics/fillable subject/.style={code={%
\node[text field] (-TF) 
{\hspace*{-0.5em}\TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/\hspace*{-0.15em}\TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/\hspace*{-0em}\TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
\node[title field] (-Title) 
at ([yshift=0.4em]-TF.north) {#1};
\draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
 -- cycle;
\draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
 }},
pics/nonfillable subject/.style={code={%
\node[text field] (-TF) 
{\hspace{1.2em}~/~\hspace{1.15em}~/~\hspace{2.35em}{}};
\node[title field] (-Title) 
at ([yshift=0.4em]-TF.north) {#1};
\draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
 -- cycle;
\draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
 }}, 
 }

\begin{document}

\thispagestyle{empty}   % To suppress page number

\noindent
\begin{tikzpicture}
\fill[white,fill=orange] (0,0) rectangle (\paperwidth,-2cm) node[midway,align=center,font=\Huge] {\bfseries Some text here\\\LARGE More text here};
\end{tikzpicture}

\noindent
\begin{Form}    % From https://tex.stackexchange.com/a/478346/152550
    \begin{tikzpicture}
        \path (0,0) pic (Geo)  {nonfillable subject={Subject}} (8.5cm,0) pic (Whatever)  {nonfillable subject={Subject}} (15cm,0) pic[draw=red] (Math)  {nonfillable subject={Math}};
        \draw[-latex] (Geo-Title) -- (Whatever-Title);
        \draw[-latex] (Whatever-Title) -- (Math-Title);
    \end{tikzpicture}
\end{Form}

\noindent
\begin{tikzpicture}
    \fill[fill=orange!30,rounded corners=50pt] (0,0) rectangle (11.5cm,-14cm) node[midway,align=center,font=\LARGE] {\bfseries Level $0$};
\end{tikzpicture}

\end{document}

What I have done

Final result

This is what I want:

What I want

You are not obliged to copy the image textually but some subjects and some rectangles.

What I need

  1. The number of rectangles varies between 6 and 7 (not like the last image where they are four). The code should be as simple as possible to be able to add subjects easily.
  2. At most each rectangle has 8 or 9 vertical subjects, and at most each rectangle has 2 horizontal subjects.
  3. The current year's label must be centered superiorly and not centered in the middle:

    Top center

  4. As much as the rectangles and the subjects within the rectangles must be centered horizontally and vertically, not like my MWE that are aligned to the left. Briefly, everything has to be centered:

    Everything has to be centered

  5. There must be an appropriate space between all the objects, and the space between year and year must be the most important thing to take care of since, if there is little space, the arrows will be very close together and the document will look ugly. As a reference, you can take the measurements (in centimeters) that I have calculated:

    Measurements that I have calculated

    If they are 7 years (i.e. the largest amount), then the width of the page will be: (0.5+4.5+1.5+4.5+0.5+3)*7-(3)+(1+1), which is equal to 100.5cm. I have not calculated the height, but it must be around 20cm (considering the maximum of vertical subjects i.e. 8/9).

    As long as the length of the sheet is smaller it is much better, but without worsening the diagram visually (because I would also like to adapt the diagram to an A4 format).

The last thing that could happen:

The last thing that could happen

(Optional requirement)

Automate the color of the arrows. Each subject has its own arrow color. As you see in "Final result", there are a lot of arrows for each subject, so the ideal would be to have a command that by passing the total number of subjects, say n, divide the gradient of colors in n equal parts, in order to homogenize the colors. If this seems crazy, there is no problem in coloring the arrows manually.

Thanks!!

6
+50

After correspondence this is a refined version.

  1. You can use pics in a matrix, not just nodes. This helps a lot here.
  2. For the horizontal and vertical centering of the tikzpicture you can just use \centering and \vfill.
  3. The appearance of the thingy is determined by some pgf keys and styles. This is marked in the code.
  4. I added just very few arrows, but this shows in principle how to go. I am not aware of a fool-proof way of avoiding that these arrows cross nodes.
  5. You will have to add \begin{Form}...\end{Form} where appropriate. I am essentially clueless what this concerns. This post focuses on the TikZ part.

\documentclass{article}
\usepackage[showframe,margin=0in,footskip=0.25in,paperwidth=50cm,paperheight=20cm]{geometry}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage{globalvals}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{positioning,backgrounds,fit}
\tikzset{text field/.style={text height=1.5ex,align=center,rounded corners},
title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=4.5cm,align=center,font=\footnotesize\sffamily},
pics/fillable subject/.style={code={%
\node[text field] (-TF) 
{\hspace*{-0.5em}\TextField[align=1,name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/\hspace*{-0.15em}\TextField[align=1,name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~~/\hspace*{-0em}\TextField[align=1,name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]{}~};
\node[title field] (-Title) 
at ([yshift=0.4em]-TF.north) {#1};
\draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
 -- cycle;
\draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
 }},
pics/nonfillable subject/.style={code={%
\node[text field] (-TF) 
{\hspace{1.2em}~/~\hspace{1.15em}~/~\hspace{2.35em}{}};
\node[title field] (-Title) 
at ([yshift=0.4em]-TF.north) {#1};
\draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
 -- cycle;
\draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
 }}, 
 manoooh/.style={column sep=-2cm,row sep=5mm}
 }

\begin{document}

\thispagestyle{empty}   % To suppress page number

\noindent
\begin{tikzpicture}
\fill[white,fill=orange] (0,0) rectangle (\paperwidth,-2cm) node[midway,align=center,font=\Huge] {\bfseries Some text here\\\LARGE More text here};
\end{tikzpicture}

\vfill
\centering
\begin{tikzpicture}[node distance=3.14cm]
 % step 1: add the matrices, name them mat0, mat1 etc.
 \begin{scope}[local bounding box=matrices] 
  \matrix[manoooh] (mat0)  {
         \pic (A)  {nonfillable subject={Subject}}; & & 
         \pic (B)  {nonfillable subject={Subject}}; \\
         & \pic (C)  {nonfillable subject={Subject}}; & \\
         };
  \matrix[manoooh,right=of mat0] (mat1){
         \pic (D)  {nonfillable subject={Subject}}; \\ 
         \pic (E)  {nonfillable subject={Subject}}; \\
         \pic (F)  {nonfillable subject={Subject}}; \\ 
         \pic (G)  {nonfillable subject={Subject}}; \\ 
         };
  \matrix[manoooh,right=of mat1] (mat2)  {
         \pic (H)  {nonfillable subject={Subject}}; & & 
         \pic (I)  {nonfillable subject={Subject}}; \\
         & \pic (J)  {nonfillable subject={Subject}};  & \\
         \pic (K)  {nonfillable subject={Subject}}; 
         & &
         \pic (L)  {nonfillable subject={Subject}}; \\
         };
  \matrix[manoooh,right=of mat2] (mat3)  {
         & \pic (M)  {nonfillable subject={Subject}};  & \\
         \pic (N)  {nonfillable subject={Subject}}; & & 
         \pic (O)  {nonfillable subject={Subject}}; \\
         \pic (P)  {nonfillable subject={Subject}}; 
         & &
         \pic (Q)  {nonfillable subject={Subject}}; \\
         };
 \end{scope}
 \foreach \X in {0,...,3} %<- if you have more or less matrices, adjust 3       
 {\node[anchor=south,yshift=1cm,align=center,font=\LARGE\bfseries\boldmath] 
 at (mat\X |-matrices.north) (L\X) {Level $\X$};
 \begin{scope}[on background layer]
  % the fit parameters determine the shape of the background rectangles
  \node[fit=(L\X) (mat\X) (matrices.south-|mat\X.south),inner ysep=5mm,
  inner xsep=5mm,fill=orange!30,rounded corners=50pt](F\X){};
 \end{scope}}
 % now add the arrows 
 \foreach \X in {D,...,G}
 {\draw[blue,-latex] (B-Title) to[out=0,in=180] (\X-Title);}
\end{tikzpicture}

\vfill
\end{document}

enter image description here

  • 1
    @manooooh I added a revised answer. Please have a look. – user121799 Mar 11 at 1:58
  • Oh no! The same problem appears: if we add \begin{Form}...\end{Form} and change nonfillable subject by fillable subject then all the TextField's input are the same. – manooooh Mar 12 at 0:22
  • 1
    @manooooh Did you give all the fillable subjects the same ID, i.e. fillable subject=<same key> for more than one fillable subject? – user121799 Mar 12 at 2:02
  • I am not able to change subject's color. I am using for example \pic (A) {nonfillable subject={Subject},draw=red}; \\ but it says: "! Package pgfkeys Error: I do not know the key '/tikz/pics/draw', to which you passed 'red', and I am going to ignore it. Perhaps you misspelled it". Any suggestion? – manooooh Mar 12 at 6:46
  • 1
    @manooooh Does \pic [draw=red](A) {nonfillable subject={Subject}}; work? – user121799 Mar 12 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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