I would do it with a simple tabular
using a few tikzmark
macros.
Code
\documentclass[convert=false]{standalone}
\usepackage{tikz,booktabs,array}
\makeatletter
\newcommand{\markZwicky}[1][]{\pgfutil@ifnextchar({\mark@Zwicky{#1}}{\mark@Zwicky{#1}()}}
\def\mark@Zwicky#1(#2)#3{%
\tikz[every Zwicky picture,#1]{%
\node[every Zwicky node,draw=none,inner sep=+\z@,outer sep=+\z@] {#3};
\def\tikz@Mark@name{#2}%
\ifx\tikz@Mark@name\pgfutil@empty\else
\tikzset{every Zwicky node/.append style={name={#2}}}%
\fi
\node[every Zwicky node,overlay] {\phantom{#3}};
}%
}
\newcommand{\tikzZwicky}[1][]{%
\def\tikz@Zwicky@args{#1}%
\let\tikz@Zwicky@list\pgfutil@gobble
\let\tikz@Zwicky@first\pgfutil@empty
\pgfutil@ifnextchar(\tikz@Zwicky@collect\tikz@Zwicky@finish
}
\def\tikz@Zwicky@collect(#1){%
\ifx\tikz@Zwicky@first\pgfutil@empty
\edef\tikz@Zwicky@first{#1}%
\else
\edef\tikz@Zwicky@list{\tikz@Zwicky@list,#1}%
\fi
\pgfutil@ifnextchar(\tikz@Zwicky@collect\tikz@Zwicky@finish
}
\def\tikz@Zwicky@finish{%
\tikz[remember picture,overlay]
\draw[every Zwicky connector,/expanded=\tikz@Zwicky@args]
(\tikz@Zwicky@first) [/expanded={@Zwicky@list/.list={\tikz@Zwicky@list}}] [every Zwicky connect finish/.try];
}
\pgfkeys{/expanded/.code={\edef\pgfkeys@temp{{#1}}\expandafter\pgfkeysalso\pgfkeys@temp}}
\makeatother
\tikzset{
@Zwicky@list/.style={insert path={to[every Zwicky connector how/.try] (#1)}},
every Zwicky picture/.style={
baseline,
remember picture,
},
every Zwicky node/.style={
remember picture,
anchor=base,
inner sep=+2pt
},
every Zwicky connector/.style={
ultra thick,
red!80!black,
draw opacity=.5,
line cap=round,
line join=round
}
}
\begin{document}
\begin{tabular}{>{\bfseries}lcccc}
\toprule
& \multicolumn{4}{c}{\bfseries Configurations} \\ \cmidrule{2-5}
Parameters & \bfseries Cookie A & \bfseries Cookie B & \bfseries Cookie C & \bfseries Cookie D \\ \midrule
Texture & Smooth & Soft & \markZwicky(1-3){Chunky} & Soft \\
Consistency & \markZwicky(2-1){Chewy} & Goowy & Crunchy & Chewy \\
Size & Medium & Small & Large & \markZwicky(3-4){Huge} \\
Base & Plain & Plain & \markZwicky(4-3){Chocholate} & Oatmeal \\
Topping & Sugar & None & Icing & \markZwicky(5-4){Chocholate} \\
Stuffing & Chocholate & \markZwicky(6-2){Dates and Harda} & Macadamia & Chocholate \\ \bottomrule
\end{tabular}
\tikzZwicky(1-3)(2-1.east)(3-4.west)(4-3.east)(5-4.west)(6-2)
\tikzZwicky[blue](2-1.east)(5-4.west)(3-4.west)(1-3.center)(4-3.center)(6-2)
\end{document}
Output
You need to pass the expression through a math parser first in order to evaluate it. One way of doing this is to use \pgfmathparse{<expression>}
, and then printing the result using \pgfmathprintnumber[<optional number formatting keys>]{\pgfmathresult}
:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\draw[step=0.1cm,black!10,very thin] (-0.1,-0.1) grid (10.2,10.2);%setting up grid and axes
\draw[step=1cm,black!50,help lines] (-0.1,-0.1) grid (10.2,10.2);
\draw[thick,->] (0,0) -- (10.2,0);
\draw[thick, ->] (0,0) -- (0,10.2);
\foreach \x in {0,1,...,10}
\draw[thick] (\x,-2pt) -- (\x,2pt);%drawing tick marks
\foreach \x in {0,2,...,10}
\draw node at (\x, -10pt) {%
\pgfmathparse{0.1*\x}% Evaluate the expression
\pgfmathprintnumber[ % Print the result
fixed,
fixed zerofill,
precision=1
]{\pgfmathresult}%
};
\foreach \y in {1,3,...,9}
\draw node at (-15pt,\y) {%
\pgfmathparse{2.5*\y+272.5}%
\pgfmathprintnumber{\pgfmathresult}%
};
\draw node at (9,-25pt) {Mole Fraction $\chi_{NB}$};
\draw node at (-40pt, 5)[rotate=90]{Temperature[$\si{\celsius}$]};
\draw node at (5,3.2){2 Phases};
\draw node at (1,6.2)[rotate=0]{1 Phase};
\draw node at (9,7.2)[]{1 Phase};
\foreach \y in {0,1,...,10}
\draw[thick](-2pt,\y) -- (2pt,\y);
\draw[very thick] plot[smooth] coordinates{(0.5,0) (2,5)(4,8) (6,9)(7,8.5)(8.5,5)(9,0) };
\end{tikzpicture}
\end{document}
Best Answer
Did I understand correctly?