samedi 29 novembre 2014

How to make a function inside the tikzpicture behave like outside


I have a makro which generates a structure(rule) and a reference to that structure. It does not behave when inside a tikzpicture. How to make the function robust to reference the structure even when inside tikzpicture? (I also want to get rid of the error message "mevp not defined")



\documentclass[12pt,a4paper]{book}
\makeatletter
%\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{tikz}
\newcounter{strctz}
\DeclareRobustCommand{\strct}[1]{%
% \ifthenelse{\isundefined{\c#1}} %
% {
\refstepcounter{strctz}%
\textbf{#1}\textbf{\Large({\thestrctz})}%
\\[2mm]%
\rule{2cm}{5mm}%
\begingroup
\expandafter\protected@edef\csname c#1\endcsname{\thestrctz}%
\expandafter\endgroup
\expandafter\DeclareRobustCommand
\csname c#1\expandafter\expandafter\expandafter\endcsname
\expandafter\expandafter\expandafter{\csname c#1\endcsname}%
% }
% {#1%
% \\[2mm]%
% \rule{2cm}{5mm}%
% (\c#1)%
% }
}
\makeatother
\begin{document}
\strct{mevalonate}
(\cmevalonate) and

\strct{ohpregnenolone}

Structure (\cohpregnenolone) and structure (\cmevalonate) and
Structure (\cohpregnenolone)

\strct{alanine} and (\calanine) (\cmevalonate) (\cohpregnenolone)

\strct{mevalonate}

%Isoprenyl-Bildung, Dimethyl-Allyl-Bildung aus Mevalonat
%
\tikzstyle{prenPP}= [rectangle,minimum size=2.4cm,text width=3.8cm,text centered,inner sep=.05cm]
\begin{tikzpicture}
\node [prenPP%
,text width=4.6cm%
] (mev) at (0,8) {\strct{mevalonate}};
node [prenPP%
,text width=4.6cm%
] (mevP) at (8,8) {\strct{mevalonateP}};
\draw[->,shorten >=0.5cm,shorten <=0.5cm,very thick]
(mev) -- node[below=0.5pt] {\parbox{2.5cm}{%
\begin{center}%
enzym{mevalonate kinase}
\end{center}}}%
(mevP) ;
\end{tikzpicture}
\cmelonalonateP
\end{document}




Aucun commentaire:

Enregistrer un commentaire