Further automation is certainly possible (foreach
tweaks, label placement, using a tikzstyle
definition for all matrix
nodes instead of repeating etc. ) but I think you can furnish it more properly anyway.
Update: Added a matrix node style. You only need to input the matrices.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{table matrix/.style={draw=black,thick,inner sep=0,fill=blue!25,matrix of nodes, nodes in empty cells,%
nodes={minimum width=30mm,minimum height=3mm,draw,outer sep=0,inner sep=0},
}
}
\begin{document}
\begin{tikzpicture}
\matrix (dbtable) at (0,0) [table matrix,label={[align=center]90:{Per Process File\\Descriptor Table}}]
{
\\
\\
\\
\\
|[minimum height = 3cm]|{}\\
\\
};
\matrix (filetable) at (4,0) [table matrix,label={[align=center]90:{File Table}}]
{
\\
\\
\\
|[minimum height = 12mm]|{}\\
\\
|[minimum height = 12mm]|{}\\
\\
\\
\\
};
\foreach \x/\y in {1/0,2/1,3/2,4/3,6/OPEN\_MAX$-$1} {
\node[anchor=east] at (dbtable-\x-1.west) {\textsf{\y}};
}
\draw[yellow,-latex,ultra thick] (dbtable-3-1.center) -- (filetable-5-1.center);
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/8D8eR.png)
Square roots are often a cause for small, but annoying, problems. Something like
$\sqrt{a}+\sqrt{b}+\sqrt{y}$
will show a variety of ways the surd is typeset
![enter image description here](https://i.stack.imgur.com/xfxdE.png)
Particularly problematic are the characters with a descender, but also "j":
$\sqrt{d}+\sqrt{j}+\sqrt{y}$
![enter image description here](https://i.stack.imgur.com/gL2Ds.png)
The decision about how to treat such a formula depends on the symbol involved; for example, if there are only characters with descenders, a \smash[b]
(requires amsmath
) can solve the problem:
$\sqrt{\smash[b]{g}}+\sqrt{\smash[b]{y}}$
![enter image description here](https://i.stack.imgur.com/gkytu.png)
One can see that the white space above the letter is not too much (and the lower angle of the surd is slighly below the baseline).
However this can't be the solution for the first formula, where there's a letter with an ascender: we need to pretend that the ascender is in all square roots, but the depth of y
should be masked off
$\sqrt{\vphantom{b}a}+\sqrt{b}+\sqrt{\vphantom{b}\smash[b]{y}}$
![enter image description here](https://i.stack.imgur.com/HlUiW.png)
Alternatively, one can use \mathstrut
that inserts a "phantom parenthesis":
$\sqrt{\mathstrut a}+\sqrt{\mathstrut b}+\sqrt{\mathstrut y}$
![enter image description here](https://i.stack.imgur.com/Dq3sl.png)
but this uses a sligthly larger surd.
Beware of a related problem:
$\sqrt{\sin x}+\sqrt{\cos x}$
gives the wrong
![enter image description here](https://i.stack.imgur.com/keKFV.png)
If such formulas are possible in our document, I recommend to change the definition of \cos
:
\let\cos\relax % to make LaTeX happy with the following line
\DeclareMathOperator{\cos}{cos\vphantom{i}}
so that the formula will by typeset correctly as
![enter image description here](https://i.stack.imgur.com/k8tzj.png)
As it can be clearly seen, there's little hope to get an automatic solution, as a good treatment depends on what's in the formula, not only on the particular square root.
Best Answer
EDIT: This answer contains 3 versions, the first one based on my misunderstanding of the approach given above, and the second one is (I hope) a more correct interpretation. The third version allows conversions for bases up to base 36(!) (but restricted to the range of numbers for the
pgfmath
engine, i.e., 0-16383).The first one:
The second one:
Third version. I think it works correctly. It's all a teensy bit kludgy anyway.