Position von Text und Pfeilen in der TikZ-Matrix

Position von Text und Pfeilen in der TikZ-Matrix

Ich möchte einen Text in ein TikZ einfügen matrix, aber er beginnt immer unten! Meine Frage ist also, wie ich ihn zwingen kann, oben zu beginnen?

Mein MWE:

\documentclass{article}    
\usepackage[svgnames]{xcolor}
\usepackage{tikz}

        \usetikzlibrary{
                arrows, chains, matrix, 
                positioning, 
                shadows,
                shapes, shapes.callouts,graphs, calc,
                shapes.geometric,
                shapes.misc,
                intersections,
               matrix, % to draw a table
              fit                  
                }

 %\newcommand{\vlab}[2]{%
        %           \tikz[baseline,inner sep=0] \node[anchor=base] (#1){#2};
            %       }

\begin{document}


 \begin{tikzpicture}[every node/.style={anchor=base,text depth=.5ex},baseline]
  \matrix %[draw=red]
   {
     \node[text height=2ex,fill=Orange!30,text width=6cm] {Local case}; & \node[text height=2ex,fill=Green!30,text width=7cm]{Global case}; \\
     \node[text height=6cm,fill=Yellow!30,align=left,text width=6cm] (noda) {
        \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))= \tikz[baseline,inner sep=0] 
                    \node[anchor=base](Kpot){$\partial\mathcal K$};
                    \tikz[baseline,inner sep=0] \node[below= of Kpot](Kpot2){\scriptsize So a K\"ahler transf. corresponds to a gauge 
                          transformation };
                     \tikz[overlay]\draw[->,red] (Kpot) to (Kpot2);
                \]
        \end{itemize}        
          }; 
     & \node[fill=Cyan!30,text height=6cm,,text width=7cm] {
      \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}       
               };\\
        %\node[fill=Purple] {a}; & \node[fill=LightBlue] {X}; & \node[fill=Aquamarine] {g}; \\
    };
\end{tikzpicture}

Antwort1

In Bezug auf Ihr Beispiel gibt es einige Probleme:

  • A \matrixerstellt bereits Knoten, daher halte ich das Verschachteln von Knoten nicht für ratsam.
  • \itemSie müssen jedes in geschweifte Klammern einschließen, wenn es sich innerhalb eines befindet \matrix, etwa:\item{<content goes here>}
  • Zum Einfärben einer Zelle verwenden Sie|[fill=<color>]|

Ausgabe

Bildbeschreibung hier eingeben

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}

Antwort2

Anstelle von TiKZ-matrixverwenden Sie lieber tcolorboxes. Text lässt sich in einem einfacher zusammensetzen tcolorboxals in einem node. Mit einem tcbrasterkönnen Sie Ihre Boxen wie eine Matrix verteilen. Und ist natürlich tikzmarkmit ihnen kompatibel.

\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}

Bildbeschreibung hier eingeben

Aktualisieren:

Betrachten Sie dies als einen langen Kommentar und nicht als eine Antwort. OP-Kommentare zur Verwendung von a matrixfür mehrzeilige farbige Tabellen wieDieses hier. Ich denke, das ist nur eine bunte Tabelle und das Paket colortblkann dafür verwendet werden:

\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}

Bildbeschreibung hier eingeben

verwandte Informationen