I would like to code a pages of notes that has the layout shown in the picture below. My question is the most efficient way to do this with LaTeX. I would think tikz with lots of nodes and edges, but I wonder if there is a more efficiently using tables within LaTeX.
[Tex/LaTex] Table of x-y values with first and second order differences
nodestablestikz-pgf
Related Solutions
If you create a simple "decoration" which simply draws a stroke from the initial to the final point, you can use the raise
option for decorated paths to get a parallel path. Applying shorten >
and shorten <
to this raised path, and putting arrow tips on it, you get the desired result:
Here is the code (the style parallel arrow
takes care of all):
\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{decorations}
\pgfdeclaredecoration{sl}{initial}{
\state{initial}[width=\pgfdecoratedpathlength-1sp]{
\pgfmoveto{\pgfpointorigin}
}
\state{final}{
\pgflineto{\pgfpointorigin}
}
}
\tikzset{parallel arrow/.style={->,
shorten >=2mm, shorten <=2mm,
decoration={sl,raise=1mm},decorate}}
\begin{tikzpicture}
\begin{scope}
\foreach \x/\y/\name/\label/\where in {1.2/1.4/a/{El Paso}/below,
1/3.2/b/Albuquerque/above, 2.5/3/c/Amarillo/below, 3.8/4/d/Wichita/above,
4.3/3.3/e/Tulsa/45, 5.2/2.8/f/{Little Rock}/right, 4.2/2/g/Dallas/left,
4.8/1/h/Houston/right, 3.6/0.6/i/{San Antonio}/below} {
\draw (\x,\y) circle (.4mm);
\node[draw,circle,minimum size=2mm,inner sep=0mm,label=\where:{\footnotesize \label}] (\name) at (\x,\y) {};
}
\foreach \s/\t in {a/b, b/c, c/e, e/d, e/f, f/g, h/g, h/i} {
\path[draw] (\s) edge (\t);
\path[draw] (\s) edge[parallel arrow] (\t);
\path[draw] (\t) edge[parallel arrow] (\s);}
\end{scope}
\end{tikzpicture}
\end{document}
Update
I added the numbers in each route. I had some fun parametrizing their position so that they can be all put in a single loop.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations,calc}
\begin{document}
\pgfdeclaredecoration{sl}{initial}{
\state{initial}[width=\pgfdecoratedpathlength-1sp]{
\pgfmoveto{\pgfpointorigin}
}
\state{final}{
\pgflineto{\pgfpointorigin}
}
}
\tikzset{parallel arrow/.style={latex-,
shorten >=2mm, shorten <=2mm,
decoration={sl,raise=1mm},decorate}}
\begin{tikzpicture}
\begin{scope}
\foreach \x/\y/\name/\label/\where in {1.2/1.4/a/{El Paso}/below,
1/3.2/b/Albuquerque/above, 2.5/3/c/Amarillo/below, 3.8/4/d/Wichita/above,
4.3/3.3/e/Tulsa/45, 5.2/2.8/f/{Little Rock}/right, 4.2/2/g/Dallas/left,
4.8/1/h/Houston/right, 3.6/0.6/i/{San Antonio}/below} {
\draw (\x,\y) circle (.4mm);
\node[draw,circle,minimum size=2mm,inner sep=0mm,label=\where:{\footnotesize \label}] (\name) at (\x,\y) {};
}
\tikzset{edge label/.style={font=\tiny, inner sep=1.6mm},
ab/.style={edge label, left},
ba/.style={edge label, right},
bc/.style={edge label, above},
cb/.style={edge label, below},
ce/.style={bc},
ec/.style={cb},
ed/.style={ab},
de/.style={ba},
ef/.style={edge label, below left, inner sep=1mm},
fe/.style={edge label, above right, inner sep=1mm},
fg/.style={edge label, above left, inner sep=1mm},
gf/.style={edge label, below right, inner sep=1mm},
hg/.style={ab},
gh/.style={ba},
hi/.style={bc},
ih/.style={cb}
}
\foreach \s/\t/\from/\to in {a/b/9/10, b/c/8/11, c/e/7/12, e/d/6/5,
e/f/13/4, f/g/14/3, h/g/15/2, h/i/16/1} {
\path[draw] (\s) edge (\t) ($(\s)!.5!(\t)$) node[\s\t] {\from} node[\t\s]{\to};
\path[draw] (\s) edge[parallel arrow] (\t);
\path[draw] (\t) edge[parallel arrow] (\s);
}
\end{scope}
\end{tikzpicture}
\end{document}
This can give you a starting point:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\definecolor{redi}{RGB}{255,38,0}
\definecolor{redii}{RGB}{200,50,30}
\definecolor{yellowi}{RGB}{255,251,0}
\definecolor{bluei}{RGB}{0,150,255}
\definecolor{blueii}{RGB}{135,247,210}
\definecolor{blueiii}{RGB}{91,205,250}
\definecolor{blueiv}{RGB}{115,244,253}
\definecolor{bluev}{RGB}{1,58,215}
\definecolor{orangei}{RGB}{240,143,50}
\definecolor{yellowii}{RGB}{222,247,100}
\definecolor{greeni}{RGB}{166,247,166}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,draw=black,text width=1.25ex,align=center},
text depth=0.25ex,
text height=1ex,
nodes in empty cells
},
texto/.style={font=\footnotesize\sffamily},
title/.style={font=\small\sffamily}
}
\newcommand\CellText[2]{%
\node[texto,left=of mat#1,anchor=east]
at (mat#1.west)
{#2};
}
\newcommand\SlText[2]{%
\node[texto,left=of mat#1,anchor=west,rotate=75]
at ([xshift=3ex]mat#1.north)
{#2};
}
\newcommand\RowTitle[2]{%
\node[title,left=6.3cm of mat#1,anchor=west]
at (mat#1.north west)
{#2};
}
\begin{document}
\begin{tikzpicture}[node distance =0pt and 0.5cm]
\matrix[table] (mat11)
{
|[fill=redi]| & & & \\
|[fill=redi]| & & & \\
|[fill=redi]| & & & \\
};
\matrix[table,right=of mat11] (mat12)
{
|[fill=orangei]| & |[fill=yellowii]| & |[fill=blueii]| & |[fill=blueiii]| \\
& |[fill=blueii]| & |[fill=greeni]| & |[fill=blueiv]| \\
& & |[fill=bluev]| & |[fill=blueiii]| \\
};
\matrix[table,below=of mat11] (mat21)
{
|[fill=redi]| & & & \\
|[fill=redi]| & & & \\
|[fill=yellowi]| & & & \\
|[fill=yellowi]| & & & \\
};
\matrix[table,below=of mat12] (mat22)
{
|[fill=bluev!95]| & & |[fill=yellowii]| & |[fill=orangei!80]| \\
& |[fill=yellowii]| & |[fill=bluev!80]| & |[fill=blueiii]| \\
|[fill=redii]| & |[fill=blueiii!80]| & & |[fill=bluev]| \\
|[fill=bluev]| & & |[fill=blueiii!80]| & |[fill=bluev]| \\
};
\matrix[table,below=of mat21] (mat31)
{
|[fill=redi]| & & & \\
|[fill=bluei]| & & & \\
};
\matrix[table,below=of mat22] (mat32)
{
|[fill=bluev]| & & |[fill=redii]| & |[fill=redii!90!black]| \\
|[fill=redii!90]| & |[fill=redii!75!black]| & |[fill=bluev]| & |[fill=bluev!80!black]| \\
};
\SlText{11-1-1}{Fibroadenoma [xx]}
\SlText{11-1-2}{Simple Cyst}
\SlText{11-1-3}{Complex Cyst}
\SlText{11-1-4}{Papilloma}
\SlText{12-1-1}{CDI}
\SlText{12-1-2}{CLI}
\SlText{12-1-3}{FA}
\SlText{12-1-4}{Cyst}
\RowTitle{11}{Background echotexture};
\CellText{11-1-1}{Homogeneous adipose-echotexture};
\CellText{11-2-1}{Homogeneous fibroglandular-echotexture};
\CellText{11-3-1}{Hoterogeneous};
\RowTitle{21}{Mass shape};
\CellText{21-1-1}{Oval};
\CellText{21-2-1}{Round};
\CellText{21-3-1}{Irregular};
\RowTitle{31}{Mass orientation};
\CellText{21-4-1}{Lobular};
\CellText{31-1-1}{Parallel to skin};
\CellText{31-2-1}{Non-parallel to skin};
\end{tikzpicture}
\end{document}
Best Answer
You could just use
minipages
to break up the page into its components. To automate the drawing, I used thecollcell
package to place a\tikzmark
at the desired location and then draw the appropriate markers:References:
Code: