ich habe mir einen Befehl für eine Markierungsbox mit Textfeld für eine tikzpicture-Umgebung gebastelt, welche ein Standardlayout beinhaltet, welches ich aber gegebenfalls anpassen kann. Entweder kann ich diese über die optionalen Parameter bei jeder "MarkBox" angeben oder für alle folgenden "MarkBoxes" mit dem Befehl "MarkBoxSet" ändern.
Das klappt soweit auch alles gut, mein einziges Problem ist, dass ich die "background opacity" nicht neudefinieren kann, da diese keine dimension besitzt und ich nicht herausfinden konnte, wie ich diese für ein gesamtes dokument/gesamte Umgebung ändern kann. Daher kann ich zwar bei jeder "MarkBox" die background opacity ändern, aber nicht über den "MarkBoxSet"-Befehl. Kann mir jemand sagen wie ich diese in den "MarkBoxSet"-Befehl einbauen kann? Und was zwar nicht ganz so wichtig ist, aber auch noch fehlt ist, wie ich über den "MarkBoxSet"-Befehl die optionen "draw" und "line width" übergeben könnte.
Das "minimal"-Beispiel müsste komplett kompilierbar sein, hoffe ich habe das soweit richtig gemacht, ist ja mein erster post

Wahrscheinlich könnte man die beiden Befehle anders viel besser definieren, als ich das getan habe, aber mit meinem Wissen über LaTeX ist mir das noch nicht möglich.

Danke schon mal für mögliche Antworten und Hilfestellungen.

\documentclass{article} \usepackage[table,usenames,dvipsnames]{xcolor} \usepackage{ifthen} \usepackage{tikz} \usepackage{keycommand} \definecolor{backgroundcolor}{named}{red} \definecolor{bordercolor}{named}{red} \definecolor{backgroundtextcolor}{named}{red} \definecolor{textcolor}{named}{white} \newdimen\xshift \xshift=0pt \newdimen\yshift \yshift=0pt \newdimen\shift \shift=0pt \newkeycommand\MarkBoxSet[draw=,line=thick,border color=bordercolor,background color=backgroundcolor,background text color=backgroundtextcolor,text color=textcolor,xshift=\xshift,yshift=\yshift,shift=\shift]{ \definecolor{backgroundcolor}{named}{\getcommandkey{background color}} \definecolor{bordercolor}{named}{\getcommandkey{border color}} \definecolor{backgroundtextcolor}{named}{\getcommandkey{background text color}} \definecolor{textcolor}{named}{\getcommandkey{text color}} \yshift=\getcommandkey{yshift} \xshift=\getcommandkey{xshift} \shift=\getcommandkey{shift} } \newkeycommand\MarkBox[draw=,line=ultra thick,border color=bordercolor,background color=backgroundcolor,background text color=backgroundtextcolor,background opacity=0.2,background text opacity =0.8,text color=textcolor,xshift=\xshift,yshift=\yshift,shift=\shift][7]{ \ifthenelse{\equal{#1}{inside}}{ \ifthenelse{\equal{#2}{bottom left}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south west, xshift=\getcommandkey{xshift}, yshift=\getcommandkey{shift}] at (#3,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{bottom right}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south east, xshift=\getcommandkey{xshift}, yshift=\getcommandkey{shift}] at (#5,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{top left}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north west, xshift=\getcommandkey{xshift}, yshift=-\getcommandkey{shift}] at (#3,#4) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{top right}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north east, xshift=\getcommandkey{xshift}, yshift=-\getcommandkey{shift}] at (#5,#4) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{left bottom}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south west, xshift=\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#3,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{right bottom}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south east, xshift=-\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#5,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{left top}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north west, xshift=\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#3,#4) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{right top}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north east, xshift=-\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#5,#4) {\vphantom{g}#7};}{\empty} }{\empty} \ifthenelse{\equal{#1}{outside}}{ \ifthenelse{\equal{#2}{bottom left}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south east, xshift=\getcommandkey{xshift}, yshift=\getcommandkey{shift}] at (#3,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{bottom right}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south west, xshift=\getcommandkey{xshift}, yshift=\getcommandkey{shift}] at (#5,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{top left}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north east, xshift=\getcommandkey{xshift}, yshift=-\getcommandkey{shift}] at (#3,#4) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{top right}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north west, xshift=\getcommandkey{xshift}, yshift=-\getcommandkey{shift}] at (#5,#4) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{left bottom}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north west, xshift=\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#3,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{right bottom}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=north east, xshift=-\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#5,#6) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{left top}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south west, xshift=\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#3,#4) {\vphantom{g}#7};}{\empty} \ifthenelse{\equal{#2}{right top}} { \draw [\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background color},fill opacity=\getcommandkey{background opacity}](#3,#4) rectangle (#5,#6); % \node[font=\sffamily,rectangle,\getcommandkey{draw},\getcommandkey{line},color=\getcommandkey{border color}, fill=\getcommandkey{background text color}, fill opacity=\getcommandkey{background text opacity}, text opacity=1,text=\getcommandkey{text color},anchor=south east, xshift=-\getcommandkey{shift}, yshift=\getcommandkey{yshift}] at (#5,#4) {\vphantom{g}#7};}{\empty} }{\empty} } \begin{document} \begin{figure} \centering \begin{tikzpicture} \MarkBox{outside}{top left}{-2}{2}{2}{-2}{text} \end{tikzpicture} \caption{A} \end{figure} \begin{figure} \centering \begin{tikzpicture} \MarkBoxSet[background color=green, background text color=yellow, text color=blue] \MarkBox{outside}{top left}{-2}{2}{2}{-2}{text} \end{tikzpicture} \caption{B} \end{figure} \begin{figure} \centering \begin{tikzpicture} \MarkBoxSet[background color=green, background text color=yellow, text color=blue] \MarkBox[background opacity=0.6]{outside}{top left}{-2}{2}{2}{-2}{text} \end{tikzpicture} \caption{C} \end{figure} \end{document} [\code]