I'm writing examples how to calculate a concentration for my students, but I stuck at mixing rule. I thought to draw this by tikz, but I don't have an idea how to do this. It should looks like on this photo.
Can someone help me, please?
I'm writing examples how to calculate a concentration for my students, but I stuck at mixing rule. I thought to draw this by tikz, but I don't have an idea how to do this. It should looks like on this photo.
Can someone help me, please?
Here's a suggestion using the tikz-cd
package/library.
The generic anchor text right
allows us to add a label to the right of the last column without it messing up the placement of the lines between the cells (which always point to the center of a node).
I'm not defining \C
globally but only with install C shortcut
inside the picture as to not overwrite any other \C
macros.
The commands \drar
, \urar
etc. are shortucuts to \ar[dr]
or \arrow[dr]
where d
stands for down and r
stands for right. Meaning, \drar
draws an arrow to the cell down and right of it.
If the lines actually need to land on the most nothern and southern tip of C
and m
a little bit more work is necessary.
\documentclass[tikz]{standalone}
\usetikzlibrary{cd}
\makeatletter
\pgfdeclaregenericanchor{text right}{%
\pgf@sh@reanchor{#1}{base}%
\multiply\pgf@x by 2
}
\makeatother
\tikzcdset{install C shortcut/.code=\newcommand*\C[1]{C_{\%_{##1}}}}
\begin{document}
\begin{tikzcd}[
install C shortcut, sep=tiny, arrows={-, gray},
cells={font=\strut, inner xsep=.2ex, inner ysep=.1ex},
/tikz/mlabel/.style={label={[anchor=text]text right:{}=|\C{#1}-C_\%|}}
]
\C{1} \drar & & |[ mlabel = 2 ]| m_{r_1} \dlar \\
& C_{\%} \\
\C{2} \urar & & |[ mlabel = 1 ]| m_{r_2} \ular
\end{tikzcd}
\end{document}
\usepackage{tikz}\usetikzlibrary{cd}
or \usepackage{tikzcd}
. tikzcd
loads tikz
and its own cd
library.
Commented
Sep 16, 2022 at 17:56