Skip to content

Instantly share code, notes, and snippets.

@gipi
Last active April 14, 2022 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gipi/cd2cf9163cee6be2329acaa2bbaa8463 to your computer and use it in GitHub Desktop.
Save gipi/cd2cf9163cee6be2329acaa2bbaa8463 to your computer and use it in GitHub Desktop.
Algorithmic thinking - Living quality diagram
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
% https://tex.stackexchange.com/questions/376528/how-to-shade-or-highlight-the-lower-triangular-part-in-a-matrix-with-tikzpicture
% https://www.bu.edu/math/files/2013/08/tikzpgfmanual.pdf
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath,amsthm,amssymb}
\usetikzlibrary{backgrounds, matrix}
\usetikzlibrary{patterns}
\begin{document}
\begin{figure}[htb]
\centering
\resizebox{0.5\textwidth}{!}{%
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,
left delimiter = |,
right delimiter = |,
nodes={minimum size=2em},
ampersand replacement=\&]
{
* \& * \& *\\
* \& C \& B \\
* \& A \& ? \\
};
\begin{pgfonlayer}{background}
\begin{scope}[blend group = soft light]
\draw[rounded corners, pattern=north east lines, opacity=.2]
(m-1-1.north) -| (m-1-2.east) -| (m-3-2.east) |- (m-3-1.south) -| (m-3-1.west) |- (m-1-1.north);
%\draw[rounded corners, dotted, fill=red!10!white, opacity=0.8]
% (m-1-1.north) -| (m-1-2.east) -| (m-2-2.east) |- (m-2-1.south) -| (m-2-1.west) |- (m-1-1.north);
\draw[rounded corners, pattern=north west lines, opacity=.2]
(m-1-1.north) -| (m-1-3.east) -| (m-2-3.east) |- (m-2-1.south) -| (m-2-1.west) |- (m-1-1.north);
\end{scope}
\end{pgfonlayer}
\end{tikzpicture}
}
\end{figure}
Let $\Delta$ be the sum of the values in the last row of interest, i.e.
\newcommand{\boxA}{%
\begin{tikzpicture}[scale=0.5]\node[rectangle,draw, pattern=north east lines] (r) at (0,0) {}; \end{tikzpicture}%
}
% https://tex.stackexchange.com/questions/569100/how-can-i-overlap-patterns-in-a-venn-diagram-legend
\newcommand{\boxC}{%
\begin{tikzpicture}[scale=0.5]\node[rectangle,draw, pattern=north west lines,postaction={pattern=north east lines}] (r) at (0,0) {}; \end{tikzpicture}%
}
\begin{align}
\Delta &=\boxA - \boxC \cr
&= A - C \cr
\end{align}
we have for the final value in the entry $?$
\begin{align}
? &= B + \Delta + v \cr
&= B + A - C + v \cr
\end{align}
where $v$ is the value from table 6.2
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment