Position of text and arrows in TikZ matrix
Concerning your example, there are some issues:
- A
\matrix
already creates nodes, so I don't think that nesting nodes is advisable. - You need to enclose each
\item
inside curly braces when inside a\matrix
, like:\item{<content goes here>}
- For coloring a cell, use
|[fill=<color>]|
Output
Code
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\usepackage{amsmath,amssymb}
\usetikzlibrary{
arrows, chains, matrix,
positioning,
shadows,
shapes, shapes.callouts,
graphs, calc,
shapes.geometric,
shapes.misc,
intersections,
matrix,fit,
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture, anchor=base west] \node[text depth=, text width=] (#1) {#2};}
\begin{document}
\begin{tikzpicture}
\matrix [
matrix of nodes,
nodes in empty cells,
every node/.style={align=left},
row 1/.style={text width=.45\linewidth,text depth=2ex},
row 2/.style={nodes={font=\footnotesize, text width=.45\linewidth,text depth=6cm}}
]
{
|[fill=Orange!30]| Local Case & |[fill=Green!30]| Global case \\
|[fill=Yellow!30]|
\begin{itemize}
\item{We have \[\left[\bar \theta\right]=\left[\bar\partial (h^{-1}\partial h)\right]=c_1(\mathcal L)\,
=\left[K\right]\]}
\item{Since $h=\exp(\mathcal K)$ we have:
\[\theta = \exp(-\mathcal K)\partial (\exp(\mathcal K))\,
=\tikzmark{Kpot}{$\partial\mathcal K$}\]}
\end{itemize}
\tikzmark{Kpot2}{\scriptsize So a K\"ahler transf. corresponds to a gauge transformation}
&
|[fill=Cyan!30]|
\begin{itemize}
\item{$\mathcal L$ is a flat bundle i.e $h=cst$}
\item{Since $\theta \sim \partial h$, we can choose a vanishing connection:
\[
\theta=\bar \theta=0
\]}
\end{itemize}\\
};
\end{tikzpicture}
\tikz[overlay, remember picture]{%
\draw[->,red] (Kpot.south) -- (Kpot2.north);
}
\end{document}
Instead of TiKZ-matrix
you prefer to use tcolorboxes
. Text is easily compound inside a tcolorbox
than inside a node
. With a tcbraster
your boxes can be distributed like a matrix. And, of course, tikzmark
is compatible with them.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usetikzlibrary{tikzmark}
\begin{document}
\lipsum[1]
\begin{tcbitemize}[raster columns=2,
raster column skip=0pt,
raster row skip=0pt,
raster equal height=rows,
arc=0mm,
boxrule=0pt,
coltitle=black,
]
\tcbitem[colbacktitle=Orange!30, colback=Yellow!20, adjusted title= Local Case]
\begin{itemize}
\item We have \[\left[\bar \theta\right]=\left[\bar\partial (h^{-1}\partial h)\right]=c_1(\mathcal L)\,
=\left[K\right]\]
\item Since $h=\exp(\mathcal K)$ we have:
\[\theta = \exp(-\mathcal K)\partial (\exp(\mathcal K))\,
=\partial\mathcal K\tikzmark{Kpot}\]
\end{itemize}
\tikzmark{Kpot2}So a Kähler transf. corresponds to a gauge transformation.
\begin{tikzpicture}[remember picture, overlay]
\draw[red, shorten >=1mm, shorten <=1mm, ->] ([yshift=1mm]pic cs:Kpot) -- ++(0:3mm) |- ([shift={(-3mm,5mm)}]pic cs:Kpot2)|-([shift={(0mm,1mm)}]pic cs:Kpot2);
\end{tikzpicture}
\tcbitem[colbacktitle=Green!30, colback=Cyan!30, adjusted title=Global Case]
\begin{itemize}
\item $\mathcal L$ is a flat bundle i.e $h=cst$
\item Since $\theta \sim \partial h$, we can choose a vanishing connection:
\[
\theta=\bar \theta=0
\]
\end{itemize}
\tcbitem[colbacktitle=Red!30, colback=Orange!40, adjusted title= Local Case]
\begin{itemize}
\item We have \[\left[\bar \theta\right]=\left[\bar\partial (h^{-1}\partial h)\right]=c_1(\mathcal L)\,
=\left[K\right]\]
\item Since $h=\exp(\mathcal K)$ we have:
\[\theta = \exp(-\mathcal K)\partial (\exp(\mathcal K))\,
=\partial\mathcal K\]
\end{itemize}
So a Kähler transf. corresponds to a gauge transformation.
\begin{tikzpicture}[remember picture, overlay]
\draw[red, shorten >=1mm, shorten <=1mm, ->] ([yshift=1mm]pic cs:Kpot) -- ++(0:3mm) |- ([shift={(-3mm,5mm)}]pic cs:Kpot2)|-([shift={(0mm,1mm)}]pic cs:Kpot2);
\end{tikzpicture}
\tcbitem[colbacktitle=Purple!30, colback=Blue!30, adjusted title=Global Case]
\begin{itemize}
\item $\mathcal L$ is a flat bundle i.e $h=cst$
\item Since $\theta \sim \partial h$, we can choose a vanishing connection:
\[
\theta=\bar \theta=0
\]
\end{itemize}
\end{tcbitemize}
\end{document}
Update:
Consider this like a long comment instead of an answer. OP comments about using a matrix
for multiline colored tables like this one. I think this is just a colorful tabular and package colortbl
can be used for this:
\documentclass{article}
\usepackage[table,svgnames]{xcolor}
%\usepackage{colortbl}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\def\arraystretch{2}
\setlength\arrayrulewidth{0.6pt} % see http://tex.stackexchange.com/a/53935/1952
\begin{tabular}{l|l}
\rowcolor{Orange!30}Local Case & Global Case \\ \hline
\rowcolor{Red!30}\ \textbullet\ \# $\text{vector multiplets}\equiv n = \dim \mathcal{M}$
&
\ \textbullet\ \# $\text{vector multiplets}\equiv n = \dim \mathcal{M}$
\\\hline
\rowcolor{Cyan!30}\ \textbullet\ \# $\text{vector fields}\equiv \overline{n} = n$
&
\ \textbullet\ \# $\text{vector fields}\equiv \overline{n} = n + \textcolor{red}{1}\tikzmark{a}$\tikz[remember picture, overlay]\draw[red] ([yshift=0.75ex]pic cs:a)--++(0.25,.25) node[right]{graviphoton};
\\\hline
\rowcolor{Blue!30}\ \textbullet\ \# $\text{Rank of SV} \equiv 2\overline{n} = 2n$
&
\ \textbullet\ \# $\text{Rank of SV} \equiv 2\overline{n} = 2n+2$
\\
\end{tabular}
\end{document}