I'm just starting out with Tikz, and find it amazing - but a bit overwhelming too. So here is an absolute beginners question:
I copied this form somebody:
% Draw inside tables:
% Some options common to all the nodes and paths
\tikzstyle{every picture}+=[remember picture,baseline]
\tikzstyle{every node}+=[inner sep=0pt,anchor=base,
minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt]
\tikzstyle{every path}+=[thick, rounded corners]
here
It was meant for drawing circles around tables or columns in a LaTeX table like this (there is a counter defined, so I can use numbers in referencing the tabnodes):
\begin{table}[htbp]
\begin{tabular}{ ...
\tabnode{$null?(s)$} & \tabnode{true} & \tabnode{false} ...
\end{tabular}
\begin{tikzpicture}[overlay]
% Define the circle paths
\draw [black](3.north west) -- (5.north east) --
(5.south east) -- (3.south west) -- cycle;
...
\end{tikzpicture}
\end{table}
This worked just fine, until I started to add other, independent, Tikz graphics to the document. Then, of course, the "options common to all the nodes and paths" caused problems, since they should not apply to the new independent graphs too.
So my question is: how do I, after changing the "every picture", "every node","every path" definitions to, say, "overlay_picture", "overlay_node" and "overlay_path", apply these new definitions to the table definition?
EDIT:
(1) tabular overlay works, independent graphics not:
\documentclass[german, a4paper, table]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\usepackage{tkz-graph}
\usepackage{tabularx}
%% (1) Draw inside tables :
%% Some options common to all the nodes and paths
\tikzstyle{every picture}+=[remember picture,baseline]
\tikzstyle{every node}+=[inner sep=0pt,anchor=base,
minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt]
\tikzstyle{every path}+=[thick, rounded corners]
%% (2) Draw inside tables :
% \tikzset{mytablestyle/.style={% Now everything inside these braces are local to mytablestyle
% every picture/.style={remember picture,baseline},
% every node/.append style={
% inner sep=0pt,anchor=base,
% minimum width=1.8cm,align=center,
% text depth=.25ex,outer sep=1.5pt},
% every path/.append style={thick, rounded corners}
% }
% }
% tikz definitions for other, independent pictures
\tikzstyle{abstract}=[rectangle, draw=black, rounded corners,
fill=blue!40, drop shadow, text centered, anchor=north, text=white,
text width=3cm]
\tikzstyle{comment}=[rectangle, draw=black, rounded corners,
fill=green, drop shadow, text centered, anchor=north, text=white, text
width=3cm]
\tikzstyle{myarrow}=[->, >=open triangle 90, shorten >=3mm, thick]
\tikzstyle{line}=[-, thick]
\begin{document}
%%% table with overlay
% Introduce a new counter for counting the nodes needed for circling
\newcounter{nodecount}
% Command for making a new node and naming it according to the nodecount counter
\newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};}
% table
\begin{table}[htbp]
\centering
\begin{tabular}{ l@{\hspace{8mm}} !{\vrule width 1.5pt}
@{\hspace{10mm}} c@{\hspace{10mm}} c@{\hspace{10mm}}}
& \multicolumn{2}{l}{\large{constructor of s}} \\
\large{observations} & \tabnode{$nil$} & \tabnode{$adjoin(s', n)$}\\
\noalign{\hrule height 1.5pt}
\tabnode{$null?(s)$} & \tabnode{true} & \tabnode{false} \\
\tabnode{$head(s)$} & \tabnode{\textbf{error}} & \tabnode{n\vphantom{h}}\\
\tabnode{$tail(s)$} & \tabnode{\textbf{error}} & \tabnode{s'} \\
\end{tabular}
\begin{tikzpicture}[overlay]
% Define the circle paths
\draw [black](3.north west) -- (5.north east) --
(5.south east) -- (3.south west) -- cycle;
\draw [black](6.north west) -- (8.north east) --
(8.south east) -- (6.south west) -- cycle;
\draw [black](9.north west) -- (11.north east) --
(11.south east) -- (9.south west) -- cycle;
\end{tikzpicture}
\end{table}
% independent tikz graphic
\begin{figure}[htp]
\centering
\begin{tikzpicture}[node distance=2cm]
\node (Fahrzeug) [abstract, rectangle split, rectangle split parts=2]
{
\textbf{Fahrzeug}
\nodepart{second}fortbewegen()
};
\node (Landfahrzeug) [abstract, rectangle split, rectangle split
parts=2, below left=of Fahrzeug]
{
\textbf{Landfahrzeug}
\nodepart{second}override \\ fortbewegen()
};
\node (Wasserfahrzeug) [abstract, rectangle split, rectangle split
parts=2, below right=of Fahrzeug]
{
\textbf{Wasserfahrzeug}
\nodepart{second}override \\ fortbewegen()
};
\node (Amphibienfahrzeug) [abstract, rectangle split, rectangle
split parts=2, below right=of Landfahrzeug]
{
\textbf{Amphibien-}\\
\textbf{fahrzeug}
\nodepart{second}\phantom{()}
};
\draw[myarrow] (Landfahrzeug.north) -- (Fahrzeug.south);
\draw[myarrow] (Wasserfahrzeug.north) -- (Fahrzeug.south);
\draw[myarrow] (Amphibienfahrzeug.north) -- (Landfahrzeug.south);
\draw[myarrow] (Amphibienfahrzeug.north) -- (Wasserfahrzeug.south);
\end{tikzpicture}
\end{figure}
\end{document}
Output:

(2) Independent graphics work, but table overlays not:
\documentclass[german, a4paper, table]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\usepackage{tkz-graph}
\usepackage{tabularx}
%% (1) Draw inside tables :
%% Some options common to all the nodes and paths
% \tikzstyle{every picture}+=[remember picture,baseline]
% \tikzstyle{every node}+=[inner sep=0pt,anchor=base,
% minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt]
% \tikzstyle{every path}+=[thick, rounded corners]
% (2) Draw inside tables :
\tikzset{mytablestyle/.style={% Now everything inside these braces are local to mytablestyle
every picture/.style={remember picture,baseline},
every node/.append style={
inner sep=0pt,anchor=base,
minimum width=1.8cm,align=center,
text depth=.25ex,outer sep=1.5pt},
every path/.append style={thick, rounded corners}
}
}
% tikz definitions for other, independent pictures
\tikzstyle{abstract}=[rectangle, draw=black, rounded corners,
fill=blue!40, drop shadow, text centered, anchor=north, text=white,
text width=3cm]
\tikzstyle{comment}=[rectangle, draw=black, rounded corners,
fill=green, drop shadow, text centered, anchor=north, text=white, text
width=3cm]
\tikzstyle{myarrow}=[->, >=open triangle 90, shorten >=3mm, thick]
\tikzstyle{line}=[-, thick]
\begin{document}
%%% table with overlay
% Introduce a new counter for counting the nodes needed for circling
\newcounter{nodecount}
% Command for making a new node and naming it according to the nodecount counter
\newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};}
% table
\begin{table}[htbp]
\centering
\begin{tabular}{ l@{\hspace{8mm}} !{\vrule width 1.5pt}
@{\hspace{10mm}} c@{\hspace{10mm}} c@{\hspace{10mm}}}
& \multicolumn{2}{l}{\large{constructor of s}} \\
\large{observations} & \tabnode{$nil$} & \tabnode{$adjoin(s', n)$}\\
\noalign{\hrule height 1.5pt}
\tabnode{$null?(s)$} & \tabnode{true} & \tabnode{false} \\
\tabnode{$head(s)$} & \tabnode{\textbf{error}} & \tabnode{n\vphantom{h}}\\
\tabnode{$tail(s)$} & \tabnode{\textbf{error}} & \tabnode{s'} \\
\end{tabular}
\begin{tikzpicture}[overlay]
% Define the circle paths
\draw [black](3.north west) -- (5.north east) --
(5.south east) -- (3.south west) -- cycle;
\draw [black](6.north west) -- (8.north east) --
(8.south east) -- (6.south west) -- cycle;
\draw [black](9.north west) -- (11.north east) --
(11.south east) -- (9.south west) -- cycle;
\end{tikzpicture}
\end{table}
% independent tikz graphic
\begin{figure}[htp]
\centering
\begin{tikzpicture}[node distance=2cm]
\node (Fahrzeug) [abstract, rectangle split, rectangle split parts=2]
{
\textbf{Fahrzeug}
\nodepart{second}fortbewegen()
};
\node (Landfahrzeug) [abstract, rectangle split, rectangle split
parts=2, below left=of Fahrzeug]
{
\textbf{Landfahrzeug}
\nodepart{second}override \\ fortbewegen()
};
\node (Wasserfahrzeug) [abstract, rectangle split, rectangle split
parts=2, below right=of Fahrzeug]
{
\textbf{Wasserfahrzeug}
\nodepart{second}override \\ fortbewegen()
};
\node (Amphibienfahrzeug) [abstract, rectangle split, rectangle
split parts=2, below right=of Landfahrzeug]
{
\textbf{Amphibien-}\\
\textbf{fahrzeug}
\nodepart{second}\phantom{()}
};
\draw[myarrow] (Landfahrzeug.north) -- (Fahrzeug.south);
\draw[myarrow] (Wasserfahrzeug.north) -- (Fahrzeug.south);
\draw[myarrow] (Amphibienfahrzeug.north) -- (Landfahrzeug.south);
\draw[myarrow] (Amphibienfahrzeug.north) -- (Wasserfahrzeug.south);
\end{tikzpicture}
\end{figure}
\end{document}
Here is the output again, after compiling two times (sorry for the overly big output graphics):
